Skip to content

Commit bb5b360

Browse files
tornariaantonio-rojas
authored andcommitted
singular: compatibility for 4.3.2p10 and before
Add two fallback compatibility `#define`s: - `ringorder_ip` - `BIGINTVEC_CMD` Also for old singular: - patch the term_order mappings to send `rp` to singular instead of `ip` - patch the display of a ring so it prints `ip` instead of `rp`
1 parent c33a96b commit bb5b360

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/sage/interfaces/singular.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,13 @@ def _repr_(self):
14021402
if self._name in s:
14031403
if self.get_custom_name() is None and self.type() == 'matrix':
14041404
s = self.parent().eval('pmat(%s,20)' % (self.name()))
1405+
# compatibility for singular 4.3.2p10 and before
1406+
if s.startswith("polynomial ring,"):
1407+
from sage.rings.polynomial.term_order import singular_name_mapping
1408+
# this is our cue that singular uses `rp` instead of `ip`
1409+
if singular_name_mapping['invlex'] == 'rp':
1410+
s = re.sub('^(// .*block.* : ordering )rp$', '\\1ip',
1411+
s, 0, re.MULTILINE);
14051412
return s
14061413

14071414
def __copy__(self):

src/sage/libs/singular/decl.pxd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ cdef extern from "factory/factory.h":
4949
cdef int SW_USE_NTL_SORT
5050

5151
cdef extern from "singular/Singular/libsingular.h":
52+
"""
53+
// compatibility for singular 4.3.2p10 and before
54+
#if SINGULAR_VERSION <= 4330
55+
#define ringorder_ip ringorder_rp
56+
#define BIGINTVEC_CMD INTVEC_CMD
57+
#endif
58+
"""
5259

5360
#
5461
# OPTIONS

src/sage/libs/singular/ring.pyx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ AUTHORS:
1717
# https://www.gnu.org/licenses/
1818
# ****************************************************************************
1919

20-
from sage.cpython.string cimport str_to_bytes
20+
from sage.cpython.string cimport str_to_bytes, bytes_to_str
2121

2222
from sage.libs.gmp.types cimport __mpz_struct
2323
from sage.libs.gmp.mpz cimport mpz_init_set_ui
@@ -72,6 +72,16 @@ order_dict = {
7272
"a": ringorder_a,
7373
}
7474

75+
cdef extern from "singular/Singular/libsingular.h":
76+
cdef char * rSimpleOrdStr(rRingOrder_t)
77+
78+
if bytes_to_str(rSimpleOrdStr(ringorder_ip)) == "rp":
79+
# compatibility for singular 4.3.2p10 and before
80+
order_dict["rp"] = ringorder_ip
81+
# also patch term_order mappings
82+
from sage.rings.polynomial import term_order
83+
term_order.singular_name_mapping['invlex'] = 'rp'
84+
term_order.inv_singular_name_mapping['rp'] = 'invlex'
7585

7686
#############################################################################
7787
cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:

0 commit comments

Comments
 (0)