sage: don't pin singular

This commit is contained in:
Timo Kaufmann 2018-07-25 18:59:14 +02:00
parent 289173366b
commit e82c26af9b
3 changed files with 281 additions and 10 deletions

View File

@ -119,16 +119,7 @@ let
giac = nixpkgs.giac.override { inherit ntl; };
arb = nixpkgs.arb.override { inherit flint; };
# update causes issues
# https://groups.google.com/forum/#!topic/sage-packaging/cS3v05Q0zso
# https://trac.sagemath.org/ticket/24735
singular = (nixpkgs.singular.override { inherit ntl flint; }).overrideAttrs (oldAttrs: {
name = "singular-4.1.0p3";
src = fetchurl {
url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/4-1-0/singular-4.1.0p3.tar.gz";
sha256 = "105zs3zk46b1cps403ap9423rl48824ap5gyrdgmg8fma34680a4";
};
});
singular = nixpkgs.singular.override { inherit ntl flint; };
# *not* to confuse with the python package "pynac"
pynac = nixpkgs.pynac.override { inherit singular flint; };

View File

@ -0,0 +1,274 @@
diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
index 9d65c9fa6c..a028bbe719 100644
--- a/src/sage/interfaces/singular.py
+++ b/src/sage/interfaces/singular.py
@@ -654,7 +654,7 @@ class Singular(ExtraTabCompletion, Expect):
s = Expect.eval(self, x, **kwds)
- if s.find("error") != -1 or s.find("Segment fault") != -1:
+ if s.find("error occurred") != -1 or s.find("Segment fault") != -1:
raise SingularError('Singular error:\n%s'%s)
if get_verbose() > 0:
@@ -1079,7 +1079,7 @@ class Singular(ExtraTabCompletion, Expect):
sage: S = singular.ring('real', '(a,b)', 'lp')
sage: singular.current_ring()
polynomial ring, over a field, global ordering
- // coefficients: float
+ // coefficients: Float()
// number of vars : 2
// block 1 : ordering lp
// : names a b
@@ -1157,7 +1157,7 @@ class Singular(ExtraTabCompletion, Expect):
sage: singular._tab_completion()
['exteriorPower',
...
- 'flintZ']
+ 'crossprod']
"""
p = re.compile("// *([a-z0-9A-Z_]*).*") #compiles regular expression
proclist = self.eval("listvar(proc)").splitlines()
@@ -1183,7 +1183,7 @@ class Singular(ExtraTabCompletion, Expect):
EXAMPLES::
sage: singular.version()
- "Singular ... version 4.1.0 ...
+ "Singular ... version 4...
"""
return singular_version()
@@ -1562,7 +1562,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
elif charstr[0] in ['0', 'QQ']:
from sage.all import QQ
br = QQ
- elif charstr[0]=='real':
+ elif charstr[0].startswith('Float'):
from sage.all import RealField, ceil, log
prec = singular.eval('ringlist(basering)[1][2][1]')
br = RealField(ceil((ZZ(prec)+1)/log(2,10)))
@@ -1750,7 +1750,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
# Singular 4 puts parentheses around floats and sign outside them
charstr = self.parent().eval('charstr(basering)').split(',',1)
- if charstr[0] in ['real', 'complex']:
+ if charstr[0]=='complex' or charstr[0].startswith('Float'):
for i in range(coeff_start, 2 * coeff_start):
singular_poly_list[i] = singular_poly_list[i].replace('(','').replace(')','')
@@ -1992,7 +1992,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
sage: S = singular.ring('real', '(a,b)', 'lp')
sage: singular.current_ring()
polynomial ring, over a field, global ordering
- // coefficients: float
+ // coefficients: Float()
// number of vars : 2
// block 1 : ordering lp
// : names a b
@@ -2072,7 +2072,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
sage: R._tab_completion()
['exteriorPower',
...
- 'flintZ']
+ 'crossprod']
"""
return self.parent()._tab_completion()
@@ -2358,7 +2358,7 @@ def singular_version():
EXAMPLES::
sage: singular.version()
- "Singular ... version 4.1.0 ...
+ "Singular ... version 4...
"""
return singular.eval('system("--version");')
diff --git a/src/sage/libs/singular/decl.pxd b/src/sage/libs/singular/decl.pxd
index 4b658c4807..d863740419 100644
--- a/src/sage/libs/singular/decl.pxd
+++ b/src/sage/libs/singular/decl.pxd
@@ -170,7 +170,7 @@ cdef extern from "singular/Singular/libsingular.h":
int n_NumberOfParameters(const n_Procs_s* r)
- ctypedef struct poly "polyrec":
+ ctypedef struct poly "spolyrec":
poly *next
number *coef
unsigned long exp[1]
@@ -630,9 +630,13 @@ cdef extern from "singular/Singular/libsingular.h":
# return p*q, destroys p and q
poly *p_Mult_q(poly *p, poly *q, ring *r)
+ # polynomial division, ignoring the rest
+ # via singclap_pdivide resp. idLift, destroys p,q
+ poly *p_Divide(poly *p, poly *q, ring *r)
+
# divide monomial p by monomial q, p,q const
- poly *pDivide(poly *p,poly *q)
+ poly *pMDivide(poly *p,poly *q)
# return the i-th power of p; p destroyed, requires global ring
diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
index 2a8d9ae021..aeff53af6c 100644
--- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
+++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
@@ -190,8 +190,8 @@ from sage.libs.singular.decl cimport (
n_IsUnit, n_Invers,
p_ISet, rChangeCurrRing, p_Copy, p_Init, p_SetCoeff, p_Setm, p_SetExp, p_Add_q,
p_NSet, p_GetCoeff, p_Delete, p_GetExp, pNext, rRingVar, omAlloc0, omStrDup,
- omFree, pDivide, p_SetCoeff0, n_Init, p_DivisibleBy, pLcm, p_LmDivisibleBy,
- pDivide, p_IsConstant, p_ExpVectorEqual, p_String, p_LmInit, n_Copy,
+ omFree, pMDivide, p_Divide, p_SetCoeff0, n_Init, p_DivisibleBy, pLcm, p_LmDivisibleBy,
+ pMDivide, p_IsConstant, p_ExpVectorEqual, p_String, p_LmInit, n_Copy,
p_IsUnit, p_Series, p_Head, idInit, fast_map_common_subexp, id_Delete,
p_IsHomogeneous, p_Homogen, p_Totaldegree,pLDeg1_Totaldegree, singclap_pdivide, singclap_factorize,
idLift, IDELEMS, On, Off, SW_USE_CHINREM_GCD, SW_USE_EZGCD,
@@ -1693,8 +1693,8 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
if not g._poly:
raise ZeroDivisionError
- if r!=currRing: rChangeCurrRing(r) # pDivide
- res = pDivide(f._poly, g._poly)
+ if r!=currRing: rChangeCurrRing(r) # pMDivide
+ res = pMDivide(f._poly, g._poly)
if coeff:
if r.cf.type == n_unknown or r.cf.cfDivBy(p_GetCoeff(f._poly, r), p_GetCoeff(g._poly, r), r.cf):
n = r.cf.cfDiv( p_GetCoeff(f._poly, r) , p_GetCoeff(g._poly, r), r.cf)
@@ -1853,8 +1853,8 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
and (<MPolynomial_libsingular>g) \
and g.parent() is self \
and p_LmDivisibleBy((<MPolynomial_libsingular>g)._poly, m, r):
- if r!=currRing: rChangeCurrRing(r) # pDivide
- flt = pDivide(f._poly, (<MPolynomial_libsingular>g)._poly)
+ if r!=currRing: rChangeCurrRing(r) # pMDivide
+ flt = pMDivide(f._poly, (<MPolynomial_libsingular>g)._poly)
#p_SetCoeff(flt, n_Div( p_GetCoeff(f._poly, r) , p_GetCoeff((<MPolynomial_libsingular>g)._poly, r), r), r)
p_SetCoeff(flt, n_Init(1, r), r)
return new_MP(self,flt), g
@@ -4023,16 +4023,6 @@ cdef class MPolynomial_libsingular(MPolynomial):
Traceback (most recent call last):
...
NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
-
- TESTS::
-
- sage: P.<x,y> = ZZ[]
- sage: p = 3*(-x^8*y^2 - x*y^9 + 6*x^8*y + 17*x^2*y^6 - x^3*y^2)
- sage: q = 7*(x^2 + x*y + y^2 + 1)
- sage: p*q//q == p
- True
- sage: p*q//p == q
- True
"""
cdef MPolynomialRing_libsingular parent = self._parent
cdef ring *r = self._parent_ring
@@ -4052,13 +4042,18 @@ cdef class MPolynomial_libsingular(MPolynomial):
_right = <MPolynomial_libsingular>right
if r.cf.type != n_unknown:
+ if r.cf.type == n_Z:
+ P = parent.change_ring(RationalField())
+ f = P(self)//P(right)
+ CM = list(f)
+ return parent(sum([c.floor()*m for c,m in CM]))
if _right.is_monomial():
p = _self._poly
quo = p_ISet(0,r)
- if r != currRing: rChangeCurrRing(r) # pDivide
+ if r != currRing: rChangeCurrRing(r) # pMDivide
while p:
if p_DivisibleBy(_right._poly, p, r):
- temp = pDivide(p, _right._poly)
+ temp = pMDivide(p, _right._poly)
p_SetCoeff0(temp, n_Copy(p_GetCoeff(p, r), r), r)
quo = p_Add_q(quo, temp, r)
p = pNext(p)
@@ -4794,6 +4789,8 @@ cdef class MPolynomial_libsingular(MPolynomial):
sage: p = -x*y + x*z + 54*x - 2
sage: (5*p^2).lcm(3*p) == 15*p^2
True
+ sage: lcm(2*x,2*x*y)
+ 2*x*y
"""
cdef ring *_ring = self._parent_ring
cdef poly *ret
@@ -4821,9 +4818,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
if _ring!=currRing: rChangeCurrRing(_ring) # singclap_gcd
gcd = singclap_gcd(p_Copy(self._poly, _ring), p_Copy(_g._poly, _ring), _ring )
prod = pp_Mult_qq(self._poly, _g._poly, _ring)
- ret = singclap_pdivide(prod , gcd , _ring)
- p_Delete(&prod, _ring)
- p_Delete(&gcd, _ring)
+ ret = p_Divide(prod, gcd, _ring)
if count >= 20:
sig_off()
return new_MP(self._parent, ret)
@@ -4866,7 +4861,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
sage: f.quo_rem(y)
(2*x^2, x + 1)
sage: f.quo_rem(3*x)
- (2*x*y + 1, -4*x^2*y - 2*x + 1)
+ (0, 2*x^2*y + x + 1)
TESTS::
@@ -4888,7 +4883,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
if right.is_zero():
raise ZeroDivisionError
- if not self._parent._base.is_field() and not is_IntegerRing(self._parent._base):
+ if not self._parent._base.is_field():
py_quo = self//right
py_rem = self - right*py_quo
return py_quo, py_rem
diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx
index d5439f7f08..ad20ebcca0 100644
--- a/src/sage/rings/polynomial/plural.pyx
+++ b/src/sage/rings/polynomial/plural.pyx
@@ -998,7 +998,7 @@ cdef class NCPolynomialRing_plural(Ring):
if not g._poly:
raise ZeroDivisionError
- res = pDivide(f._poly,g._poly)
+ res = pMDivide(f._poly,g._poly)
if coeff:
if (r.cf.type == n_unknown) or r.cf.cfDivBy(p_GetCoeff(f._poly, r), p_GetCoeff(g._poly, r), r.cf):
n = r.cf.cfDiv( p_GetCoeff(f._poly, r) , p_GetCoeff(g._poly, r), r.cf)
@@ -1193,7 +1193,7 @@ cdef class NCPolynomialRing_plural(Ring):
if isinstance(g, NCPolynomial_plural) \
and (<NCPolynomial_plural>g) \
and p_LmDivisibleBy((<NCPolynomial_plural>g)._poly, m, r):
- flt = pDivide(f._poly, (<NCPolynomial_plural>g)._poly)
+ flt = pMDivide(f._poly, (<NCPolynomial_plural>g)._poly)
#p_SetCoeff(flt, n_Div( p_GetCoeff(f._poly, r) , p_GetCoeff((<NCPolynomial_plural>g)._poly, r), r), r)
p_SetCoeff(flt, n_Init(1, r), r)
return new_NCP(self,flt), g
diff --git a/src/sage/rings/polynomial/polynomial_singular_interface.py b/src/sage/rings/polynomial/polynomial_singular_interface.py
index 9331169f8b..f753610fd3 100644
--- a/src/sage/rings/polynomial/polynomial_singular_interface.py
+++ b/src/sage/rings/polynomial/polynomial_singular_interface.py
@@ -81,8 +81,8 @@ class PolynomialRing_singular_repr:
sage: R.<x,y> = PolynomialRing(CC)
sage: singular(R)
polynomial ring, over a field, global ordering
- // coefficients: float[I](complex:15 digits, additional 0 digits)/(I^2+1)
- // number of vars : 2
+ // coefficients: real[I](complex:15 digits, additional 0 digits)/(I^2+1)
+ // number of vars : 2
// block 1 : ordering dp
// : names x y
// block 2 : ordering C
@@ -90,8 +90,8 @@ class PolynomialRing_singular_repr:
sage: R.<x,y> = PolynomialRing(RealField(100))
sage: singular(R)
polynomial ring, over a field, global ordering
- // coefficients: float
- // number of vars : 2
+ // coefficients: Float()
+ // number of vars : 2
// block 1 : ordering dp
// : names x y
// block 2 : ordering C

View File

@ -96,6 +96,12 @@ stdenv.mkDerivation rec {
# Only formatting changes.
# https://trac.sagemath.org/ticket/25260
./patches/numpy-1.14.3.patch
# https://trac.sagemath.org/ticket/25862
./patches/eclib-20180710.patch
# https://trac.sagemath.org/ticket/24735
./patches/singular-4.1.1p2.patch
];
patches = nixPatches ++ packageUpgradePatches ++ [