Skip to content

Commit

Permalink
Trac #25993: Upgrade Singular
Browse files Browse the repository at this point in the history
Tarball: `see checksums.ini` on the branch

Use `make SAGE_SPKG="sage-spkg -o" singular-clean sagelib-clean build`
to automatically download and install.

"Critical" because it enables supporting newer versions of FLINT.

We use the Singular development branch (`spielwiese`) + PR
Singular/Singular#1058 in order to build
documentation. The tarball is made from
https://github.com/mkoeppe/Singular/tree/Release-4-2-0-p1%2Bsage

URL: https://trac.sagemath.org/25993
Reported by: jdemeyer
Ticket author(s): Antonio Rojas, Markus Wageringel, Matthias Koeppe
Reviewer(s): Matthias Koeppe, Dima Pasechnik
  • Loading branch information
Release Manager committed Mar 18, 2021
2 parents 941137b + ec471e0 commit ca83d06
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 247 deletions.
7 changes: 4 additions & 3 deletions build/pkgs/pysingular/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tarball=PySingular-VERSION.tar.gz
sha1=760ccdd20c869c5a874100df02e9031fc0c6157a
md5=f2698b633915199fc27c9772e4688754
cksum=1655432975
sha1=c8d4bbe4552490aac37afe6d87a2cd3a7b445a7e
md5=84a8639d33a5b03637a7ca3ea322b085
cksum=822399760
upstream_url=https://pypi.io/packages/source/p/pysingular/PySingular-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/pysingular/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.5
0.9.7
3 changes: 2 additions & 1 deletion build/pkgs/singular/SPKG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Dependencies
Special Update/Build Instructions
---------------------------------

See spkg-src to create the source tarball.
The current upstream tarball is made from the branch at
https://github.com/mkoeppe/Singular/tree/Release-4-2-0-p1%2Bsage

Other notes:

Expand Down
7 changes: 4 additions & 3 deletions build/pkgs/singular/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tarball=singular-VERSION.tar.gz
sha1=5c6b6c3d2b5ebaca164967eec67e59ebb4e6142f
md5=cb50d64ab1b2b49a0c3f519e5c87639e
cksum=4294037094
sha1=eeb0b250e481e710daea45c2f78ccff9b84e6f15
md5=88c4500c2d6ac3eb9b112111fc9404ad
cksum=3131197750
upstream_url=https://trac.sagemath.org/raw-attachment/ticket/25993/singular-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/singular/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1p2.p0
4.2.0p1+2021-03-13+sage
26 changes: 0 additions & 26 deletions build/pkgs/singular/patches/configure-no-ntl-header-check.patch
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,4 @@ index db6423d..c0a2260 100755
+## fi
done

if test "x$ntl_found" = "xyes" ; then
diff --git a/libpolys/configure b/libpolys/configure
index 41b0928..9a4b9f5 100755
--- a/libpolys/configure
+++ b/libpolys/configure
@@ -20660,7 +20660,7 @@ fi

for NTL_HOME in ${NTL_HOME_PATH}
do
-if test -r "$NTL_HOME/include/NTL/ZZ.h"; then
+## if test -r "$NTL_HOME/include/NTL/ZZ.h"; then

if test "x$NTL_HOME" != "x/usr"; then
NTL_CPPFLAGS="-I${NTL_HOME}/include"
@@ -20731,9 +20731,9 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-else
- ntl_found="no"
-fi
+## else
+## ntl_found="no"
+## fi
done

if test "x$ntl_found" = "xyes" ; then
31 changes: 0 additions & 31 deletions build/pkgs/singular/patches/fix-building-with-nodebug.patch

This file was deleted.

75 changes: 0 additions & 75 deletions build/pkgs/singular/patches/singular-ntl-error-handler.patch

This file was deleted.

20 changes: 19 additions & 1 deletion build/pkgs/singular/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ remove_old_version()

config()
{
if [ "$UNAME" = "CYGWIN" ]; then
# from Hans Schoenemann - https://github.com/Singular/Singular/issues/1017
SINGULAR_CONFIGURE="$SINGULAR_CONFIGURE --disable-p-procs-dynamic --enable-p-procs-static --with-builtinmodules=gfanlib,gitfan,interval,loctriv,partialgb,syzextra,customstd,cohomo,subsets,freealgebra,systhreads --disable-cf-inline --disable-Order-module --disable-bigintm-module --disable-pyobject-module"
fi

# configure notes (dates from Singular 3.x, maybe outdated for 4.x):
# 1) We really need to add --exec-prefix and --bindir as Singular
# uses some weird defaults.
Expand All @@ -76,15 +81,28 @@ config()
--disable-doc \
--disable-polymake \
--without-python \
--without-pythonmodule \
--disable-python \
--disable-python_module \
--disable-python-module \
--disable-static \
$SINGULAR_CONFIGURE
}


build_singular()
{
sdh_make
for subdir in omalloc gfanlib resources omalloc factory libpolys gfanlib IntegerProgramming; do
sdh_make -w -C $subdir
done
# Possible parallelization bugs in subdirectory Singular
sdh_make -j1
sdh_make_install

# Singular tarballs made using "make dist" do not contain built documentation.
if [ ! -e doc/doc.tbz2 ]; then
(cd doc && make singular.hlp && sdh_install singular.hlp "$SAGE_SHARE/info/") || sdh_die "Building documentation failed"
fi
}


Expand Down
4 changes: 2 additions & 2 deletions src/doc/en/constructions/algebraic_geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Other methods

sage: singular.lib("brnoeth.lib")
sage: s = singular.ring(2,'(x,y)','lp')
sage: I = singular.ideal('[x^4+x, y^4+y]')
sage: I = singular.ideal('x^4+x', 'y^4+y')
sage: L = singular.closed_points(I)
sage: # Here you have all the points :
sage: L # random
Expand Down Expand Up @@ -329,7 +329,7 @@ Singular itself to help an understanding of how the wrapper works.
sage: X = Curve(f); pts = X.rational_points()
sage: D = X.divisor([ (3, pts[0]), (-1,pts[1]), (10, pts[5]) ])
sage: X.riemann_roch_basis(D)
[(-x - 2*y)/(-2*x - 2*y), (-x + z)/(x + y)]
[(-2*x + y)/(x + y), (-x + z)/(x + y)]

- Using Singular's ``BrillNoether`` command (for details see the section
Brill-Noether in the Singular online documentation
Expand Down
16 changes: 13 additions & 3 deletions src/sage/algebras/free_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@
Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F
sage: I.groebner_basis(degbound=4)
Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
Twosided Ideal (x*y + y*z,
x*x - y*x - y*y - y*z,
y*y*y - y*y*z + y*z*y - y*z*z,
y*y*x + y*y*z + y*z*x + y*z*z,
y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z,
y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z,
y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z,
y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z) of Free Associative Unital
Algebra on 3 generators (x, y, z) over Rational Field
sage: y*z*y*y*z*z + 2*y*z*y*z*z*x + y*z*y*z*z*z - y*z*z*y*z*x + y*z*z*z*z*x in I
True
Expand Down Expand Up @@ -232,7 +240,7 @@ class FreeAlgebraFactory(UniqueFactory):
a*b^2*c^3
"""
def create_key(self, base_ring, arg1=None, arg2=None,
sparse=None, order='degrevlex',
sparse=None, order=None,
names=None, name=None,
implementation=None, degrees=None):
"""
Expand Down Expand Up @@ -263,6 +271,8 @@ def create_key(self, base_ring, arg1=None, arg2=None,
return tuple(degrees),base_ring
# test if we can use libSingular/letterplace
if implementation == "letterplace":
if order is None:
order = 'degrevlex' if degrees is None else 'deglex'
args = [arg for arg in (arg1, arg2) if arg is not None]
kwds = dict(sparse=sparse, order=order, implementation="singular")
if name is not None:
Expand All @@ -273,7 +283,7 @@ def create_key(self, base_ring, arg1=None, arg2=None,
if degrees is None:
return (PolRing,)
from sage.all import TermOrder
T = PolRing.term_order() + TermOrder('lex',1)
T = TermOrder(PolRing.term_order(), PolRing.ngens() + 1)
varnames = list(PolRing.variable_names())
newname = 'x'
while newname in varnames:
Expand Down
16 changes: 10 additions & 6 deletions src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AUTHOR:
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.groups.perm_gps.all import CyclicPermutationGroup
from sage.libs.singular.function import lib, singular_function
from sage.misc.repr import repr_lincomb
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
Expand All @@ -25,7 +26,6 @@ from cpython.object cimport PyObject_RichCompare
# Define some singular functions
lib("freegb.lib")
poly_reduce = singular_function("NF")
singular_system=singular_function("system")

#####################
# Free algebra elements
Expand Down Expand Up @@ -445,9 +445,10 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
cdef int i
if P.monomial_divides(s_poly,p_poly):
return True
realngens = A._commutative_ring.ngens()
CG = CyclicPermutationGroup(P.ngens())
for i from 0 <= i < p_d-s_d:
s_poly = singular_system("stest",s_poly,1,
A._degbound,A.__ngens,ring=P)
s_poly = s_poly * CG[realngens]
if P.monomial_divides(s_poly,p_poly):
return True
return False
Expand Down Expand Up @@ -601,7 +602,9 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
# we must put the polynomials into the same ring
left._poly = A._current_ring(left._poly)
right._poly = A._current_ring(right._poly)
rshift = singular_system("stest",right._poly,left._poly.degree(),A._degbound,A.__ngens, ring=A._current_ring)
realngens = A._commutative_ring.ngens()
CG = CyclicPermutationGroup(A._current_ring.ngens())
rshift = right._poly * CG[left._poly.degree() * realngens]
return FreeAlgebraElement_letterplace(A,left._poly*rshift, check=False)

def __pow__(FreeAlgebraElement_letterplace self, int n, k):
Expand All @@ -627,10 +630,11 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
self._poly = A._current_ring(self._poly)
cdef int d = self._poly.degree()
q = p = self._poly
realngens = A._commutative_ring.ngens()
cdef int i
CG = CyclicPermutationGroup(A._current_ring.ngens())
for i from 0<i<n:
q = singular_system("stest",q,d,A._degbound,A.__ngens,
ring=A._current_ring)
q = q * CG[d * realngens]
p *= q
return FreeAlgebraElement_letterplace(A, p, check=False)

Expand Down
7 changes: 7 additions & 0 deletions src/sage/algebras/letterplace/free_algebra_letterplace.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ from sage.rings.ring cimport Algebra
from sage.structure.element cimport AlgebraElement, ModuleElement, RingElement, Element
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular, MPolynomial_libsingular
from sage.algebras.letterplace.free_algebra_element_letterplace cimport FreeAlgebraElement_letterplace
from sage.libs.singular.decl cimport ring


cdef class FreeAlgebra_letterplace_libsingular():
cdef ring* _lp_ring
cdef MPolynomialRing_libsingular _commutative_ring
cdef MPolynomialRing_libsingular _lp_ring_internal
cdef object __ngens

cdef class FreeAlgebra_letterplace(Algebra):
cdef MPolynomialRing_libsingular _commutative_ring
cdef MPolynomialRing_libsingular _current_ring
Expand Down
Loading

0 comments on commit ca83d06

Please sign in to comment.