# Sage Days 23.5 Coding Sprint Projects

## Fix Sage's wrapping of Singular's Brill-Noether

• (done, sort of) It seems there is still a problem with Singular. The Sage ticket is updated correspondingly, Trac #8997.

## Python <--> Singular Linking Discussion

How: Dinner and beer.

Have a technical discussion of linking Python and Singular and Sage.

We tried to use the PSICO-approach to import sage into Singular. It failed (inifinite loop at integer.pyx), despite inidividual Cython modules can be loaded. Further investigations will follow.

## Singular Parallel Build

People: Hans S. + A. Dreyer

Goals:

1. Tell us which components of singular build in parallel via some testing.
• Trac #9497: Fix the Singular spkg so it can take advantage of building in parallel. But fix Singular SPKG first (3-1-1-3)!

We fixed this upstream (added dependencies to build system), Hans made anew release. The spkg was fixed by malb last night.

## Doctest the Free Algebra Quotient code

People: Gabriel Pannwitz

The file SAGE_ROOT/devel/sage/sage/algebras/free_algebra_quotient.py has no doctests. Get it to 100% coverage. The point of this is that it is related to wrapping something like letterplace.

## Letterplace

People: Martin Albrecht will review.

Do a very basic wrapping of letterplace for Sage. Use this to replace some of the lame old code in the SAGE_ROOT/devel/sage/sage/algebras/ directory. See here: #7797

## error: out of memory

People: William Stein, Hans S.

• (done, in that patches are up for everything) Trac #5313. Patch singular so that when it runs out of memory the error message says "singular" in it. Moreover, replace the exit(1) or whatever by something that can be trapped via _sig_on/_sig_off.

## Relative number field arithmetic

People: Mohamed, Andrew, William Stein

Goal:

1. (done) Explain how to compute inverses.

3. (done) Post a patch to the above ticket.
• Arithmetic in relative numbers fields is sometimes very slow. This could be done using multivariate polynomial ring quotients via libsingular, which would be extremely fast in some cases. There is some cleverness that I do *not* know how to do for inverting elements -- hence it would be good to do this here with singular people around.

People: William Stein

• (done -- patch up) This is trac 9498. There is a stupid function that William Stein wrote during bug days, which may as well be removed.

## (Done) Gröbner bases in Sage: Optional parameters

People: Simon King, with a help from Martin and Hannes (more than minutes...)

• (patch with positive review at #1396) In Singular, one can use various options (redTail, e.g.) and also a degree bound (degBound) for Gröbner basis computations. Aim: Allow the same for libSingular. As a courtesy, one can name the options both in Python style (deg_bound) and Singular style (degBound). A decorator ensures that all relevant methods work under default options unless explicitly requested by the user. Here are examples in Singular and libSingular:

```sage: R.<x,y> = QQ[]
sage: I = R*[x^3+y^2,x^2*y+1]
sage: I.groebner_basis(prot=True, deg_bound=2)
std in (0),(x,y),(dp(2),C)
[4294967295:2]3ss
(S:1)-
product criterion:0 chain criterion:0
[x^3 + y^2, x^2*y + 1]
sage: I.groebner_basis()
[x^3 + y^2, x^2*y + 1, y^3 - x]
sage: Rlocal.<x,y,z> = PolynomialRing(QQ, order='ds')
sage: J = [x^7+y^7+z^6,x^6+y^8+z^7,x^7+y^5+z^8, x^2*y^3+y^2*z^3+x^3*z^2,x^3*y^2+y^3*z^2+x^2*z^3]*Rlocal
sage: J.groebner_basis(mult_bound=100)
[x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6 + x*y^4*z^5, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6 - x*y^4*z^4 - x^3*y*z^5]
sage: J.groebner_basis(algorithm='singular',mult_bound=100)
[x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6 + x*y^4*z^5, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6 - x*y^4*z^4 - x^3*y*z^5]
sage: J.groebner_basis(prot=True)
std in basering
[1048575:2]5(4)s(3)s6s7s8s(4)s(5)sH(13)9(3)sH(12)8(4)s(5).s.s9....sH(11)8.10
(S:10)-----------
product criterion:9 chain criterion:30
[x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6, y^4*z^3 - y^3*z^4 - x^2*z^5, x^3*y*z^4 - x^2*y^2*z^4 + x*y^3*z^4, x^3*z^5, x^2*y*z^5 + y^3*z^5, x*y^3*z^5]
sage: J.groebner_basis(algorithm='singular')
[x^3*y^2 + y^3*z^2 + x^2*z^3, x^2*y^3 + x^3*z^2 + y^2*z^3, y^5, x^6, x^4*z^2 - y^4*z^2 - x^2*y*z^3 + x*y^2*z^3, z^6, y^4*z^3 - y^3*z^4 - x^2*z^5, x^3*y*z^4 - x^2*y^2*z^4 + x*y^3*z^4, x^3*z^5, x^2*y*z^5 + y^3*z^5, x*y^3*z^5]```

## extend polynomial rings mod 2^n to n > 30, and over ZZ

• People: Anne, Frank, Moritz

Rings mod 2^n are limited to n <= 30, but we'd like to have n<=62 by using longs. This would be relevant for some crypto applications.

## (Done) big exponents

• People: Martin Albrecht, Hans S.

Provide an interface to use Singular monomials with big exponents (64-bit instead of 16-bit)

Sage Trac ticket: Trac #7795

## Plural interface

• People: Burcin, Oleksandr Motsak, Michael Brickenstein, Simon King

Revive #4539 to provide a basic interface to Plural. This will involve writing new parent and element classes for plural at least.

This works using the libsingular interface, without inheriting from the commutative polynomial classes now:

```sage: A.<x,y,z>=FreeAlgebra(QQ,3)
sage: H=A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y})
sage: H.inject_variables()
Defining x, y, z
sage: z*x
x*z + 2*x
sage: z*y
y*z - 2*y
sage: I = H.ideal([y^2, x^2, z^2-H.one_element()],coerce=False)
sage: I._groebner_basis_libsingular()
[z^2 - 1, y*z - y, x*z + x, y^2, 2*x*y - z - 1, x^2]```

This meant adding a lot of instances of this in the interface:

```            if PY_TYPE_CHECK(a, MPolynomialIdeal) or \
PY_TYPE_CHECK(a, NCPolynomialIdeal):
ring2 = a.ring()
elif PY_TYPE_CHECK(a, MPolynomial_libsingular) or \
PY_TYPE_CHECK(a, NCPolynomial_plural):
ring2 = a.parent()
elif PY_TYPE_CHECK(a, MPolynomialRing_libsingular) or \
PY_TYPE_CHECK(a, NCPolynomialRing_plural):
ring2 = a```

Michael volunteered to fix the rest of these. We also need coercion to work:

```sage: z^2-1
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
...
NotImplementedError:
Also, please make sure you have implemented has_coerce_map_from_impl or has_coerce_map_from_c_impl (or better _an_element_c_impl or _an_element_impl if possible) for Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field

sage: z^2-H.one_element()
z^2 - 1```

## Multivariate GCD, factorization, etc. benchmarks

• People: Martin Lee, Burcin, Markus, Michael Brickenstein

Take a look at the new code in GIAC, benchmarks posted here. Compare to improvements in Singular-Factory. See here for more gcd benchmarks and scripts.

Polynomials in Q[x,y,z]:

1. ((1+x+y+z)20+1)*((1+x+y+z)20+2)

2. ((1+x+y+z)30+1)*((1+x+y+z)30+2)

3. (x+y+z2)25-(y-x+3*z-1+x2)25

4. (x+y+z)30-1

5. (2+x-y+z)20-220

6. x200-1

7. x50-250

8. x40-(y+z)40

9. (x+y)10-(y-z)10

10. (1-3*x-4*y+3*z-y*z2-3*y*z3-y2*z-3*y2*z2+3*y2*z3-y3*z-2*y3*z2-3*y3*z3+3*x*z-3*x*z2+2*x*z3+x*y-3*x*y3+3*x2*z-4*x2*z2-x2*z3-x2*y+3*x2*y2-5*x2*y3-x3*z-5*x3*z2-2*x3*z3+2*x3*y+4*x3*y3-x*y2+3*x*y2*z+4*x3*y2+3*y*z-5*z3-4*y2+2*y3+2*x2*y2*z2+3*x*y3*z2+3*x*y3*z+4*x*y*z2+3*x*y3*z3-5*x*y2*z2+3*x*y*z-3*x3*y3*z-5*x2*y3*z3-5*x*y2*z3-5*x2*y*z2+3*x2*y3*z-x3*y2*z2-x3*y2*z-x3*y2*z3-4*x2*y2*z3+2*x2*y*z-4*x2*y*z3+x2*y3*z2-x2*y2*z-5*x3*y*z2-x3*y*z3-x3*y*z-5*x*y*z3-2*x2+3*x3)4-1

11. (360-201*x+389*y+258*z-200*y*z+491*y*z2+493*y2*z+454*y2*z2-401*x*z+49*x*z2-304*x*y-484*x*y2+262*x2*z-339*x2*z2-227*x2*y-330*x2*y2+250*z2-495*y2-218*x*y*z-476*x2*y2*z2+243*x*y2*z+94*x2*y2*z+240*x*y2*z2-149*x*y*z2-321*x2*y*z-189*x2*y*z2+357*x2)4-1

12. x800-1

13. (101-139*x-24*y+104*z-103*y*z-451*y*z2-326*y2*z-493*y2*z2-327*x*z+439*x*z2-108*x*y+155*x*y2+121*x2*z-462*x2*z2+103*x2*y+217*x2*y2+327*z2-122*y2+344*x*y*z-262*x2*y2*z2+396*x*y2*z+8*x2*y2*z-47*x*y2*z2-314*x*y*z2+82*x2*y*z-50*x2*y*z2-424*x2)6-1

14. (14878-22176*x+8386*y+41700*z-38290*y*z+44119*y*z2-37070*y2*z+45024*y2*z2+47986*x*z-28140*x*z2+33417*x*y-31087*x*y2+45572*x2*z-46632*x2*z2-77*x2*y-15943*x2*y2-21957*z2-14839*y2-41351*x*y*z-35985*x2*y2*z2+43811*x*y2*z-35522*x2*y2*z+23454*x*y2*z2-33462*x*y*z2-32836*x2*y*z+9538*x2*y*z2+31480*x2)6-1

15. (-4212647-3198520*x+2950231*y -3315421*z +3701831*y*z +2351230*y*z2 +108373*y2*z +1812831*y2*z2+379586*x*z-3385311*x*z2+2453252*x*y+3838359*x*y2+2688541*x2*z+1838684*x2*z2-4852824*x2*y-4824055*x2*y2+90165*z2+651277*y2+2363714*x*y*z-4782981*x2*y2*z2-4578460*x*y2*z+4757744*x2*y2*z+681595*x*y2*z2+398600*x*y*z2+1864322*x2*y*z+1600103*x2*y*z2+2488109*x2)4-1

16. ((x+y+z)10 - 410)5-35

17. ((x+y+z)5 - 25)8-38

Bechmarks (someone check these, its late...).

GIAC and Singular on AMD opeteron 2800MHZ, Magma on AMD opeteron 2300MHZ (due to licence)

time in s (using timer in singular, which is probably not very excact)

 Polynomial GIAC 9.0.2 Singular 3.1.1.3 Magma 1 1 15 9 2 13 111 164 3 1 4 3 4 0 1 1 5 0 0 0 6 0 0 0 7 0 integer overflow 0 8 0 0 0 9 0 0 0 10 0 0 0 11 0 1 0 12 0 0 0 13 1 1 0 14 1 1 0 15 0 1 0 16 0 1 0 17 1 1 1 18 0 1 1

## Implement multivariate factorization over finite fields

• People: Burcin, William Stein, Martin Albrecht

## Fix bug(s) in Singular needed for updating the spkg

• People: Frank
• Some reduction over the integers goes wrong

## (Done) Error handling in Libsingular

• People: Martin Albrecht, Hans S.
• Goal: If you have a singular library function and it goes wrong, then afterwards you can still use singular library functions.

Patch up at Sage ticket: #9499 (positive review)

## (Done) Catch Singular error messages

People: Martin Albrecht

# other stuff

## @fork, @parallel decorator

• People: Robert Miller, William Stein

Ticket: See trac 9501.

Simon King mentioned that sometimes his code crashes/leaks/etc. So make it so one can do:

```@fork
def f(x,y,z,...):
...```

and then f gets computed in a blocking forked process, and the result is returned via pickling. This is 100% to thwart mem leaks, segfaults, and guaranteed timeout possibility. This could be basically just a light wrapper around @parallel(1). Also, make a global flag to turn this off, so @fork does nothing.

## Profiling Cython code

• People: Robert Miller

An example of using C library function clock() to count clock ticks...

```sage: gc = sage.coding.code_constructions.BinaryGolayCode()
sage: M = gc.extended_code().gen_mat()
sage: from sage.groups.perm_gps.partn_ref.refinement_binary import LinearBinaryCodeStruct
sage: from sage.coding.binary_code import BinaryCodeClassifier, BinaryCode
sage: BC = BinaryCodeClassifier()
sage: B = BinaryCode(M)
sage: BN = LinearBinaryCodeStruct(M)
sage: BN.run()
wd deg tot clock ticks 683242
563425 calls
1.21265829525 per call
cl deg tot clock ticks 281302
144294 calls
1.94950586996 per call
sage: x = BC._aut_gp_and_can_label(B)
wd deg tot clock ticks 659583
746525 calls
0.883537724792 per call
cl deg tot clock ticks 183800
193324 calls
0.950735552751 per call```

days23.5/projects (last edited 2010-07-19 09:54:57 by MoritzMinzlaff)