Opened 11 years ago

Last modified 10 years ago

#11431 closed defect

Conversion from Singular to Sage — at Initial Version

Reported by: SimonKing Owned by: was
Priority: major Milestone: sage-4.7.2
Component: interfaces Keywords:
Cc: malb Merged in:
Authors: Simon King Reviewers:
Report Upstream: None of the above - read trac for reasoning. Work issues:
Branch: Commit:
Dependencies: #11316 Stopgaps:

Status badges

Description

On sage-devel, Francisco Botana complained about some shortcomings of the conversion from Singular (pexpect interface) to Sage.

I think the conversions provided by this patch are quite thorough.

First of all, the patch provides a conversion of base rings, even with minpoly, with complicated block, matrix and weighted orders (note that one needs #11316) and even quotient rings:

sage: singular.eval('ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp)')
'ring r1 = (9,x),(a,b,c,d,e,f),(M((1,2,3,0)),wp(2,3),lp);'
sage: R = singular('r1').sage_basering()
sage: R
Multivariate Polynomial Ring in a, b, c, d, e, f over Finite Field in x of size 3^2
sage: R.term_order()
Block term order with blocks:
(Matrix term order with matrix
[1 2]
[3 0],
 Weighted degree reverse lexicographic term order with weights (2, 3),
 Lexicographic term order of length 2)

sage: singular.eval('ring r3 = (3,z),(a,b,c),dp')
'ring r3 = (3,z),(a,b,c),dp;'
sage: singular.eval('minpoly = 1+z+z2+z3+z4')
'minpoly = 1+z+z2+z3+z4;'
sage: singular('r3').sage_basering()
Multivariate Polynomial Ring in a, b, c over Univariate Quotient Polynomial Ring in z over Finite Field of size 3 with modulus z^4 + z^3 + z^2 + z + 1

sage: singular.eval('ring r5 = (9,a), (x,y,z),lp') 
'ring r5 = (9,a), (x,y,z),lp;'
sage: Q = singular('std(ideal(x^2,x+y^2+z^3))', type='qring')
sage: Q.sage_basering()
Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field in a of size 3^2 by the ideal (y^4 - y^2*z^3 + z^6, x + y^2 + z^3)

By consequence, it is now straight forward to convert polynomials or ideals to sage:

sage: singular.eval('ring R = integer, (x,y,z),lp') 
'// ** You are using coefficient rings which are not fields...'
sage: I = singular.ideal(['x^2','y*z','z+x']) 
sage: I.sage()  # indirect doctest
Ideal (x^2, y*z, x + z) of Multivariate Polynomial Ring in x, y, z over Integer Ring

# Note that conversion of a Singular string to a Sage string was missing
sage: singular('ringlist(basering)').sage()
[['integer'], ['x', 'y', 'z'], [['lp', (1, 1, 1)], ['C', (0)]], Ideal (0) of Multivariate Polynomial Ring in x, y, z over Integer Ring]

sage: singular.eval('ring r10 = (9,a), (x,y,z),lp')
'ring r10 = (9,a), (x,y,z),lp;'
sage: Q = singular('std(ideal(x^2,x+y^2+z^3))', type='qring')
sage: Q.sage()
Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field in a of size 3^2 by the ideal (y^4 - y^2*z^3 + z^6, x + y^2 + z^3)
sage: singular('x^2+y').sage()
x^2 + y
sage: singular('x^2+y').sage().parent()
Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field in a of size 3^2 by the ideal (y^4 - y^2*z^3 + z^6, x + y^2 + z^3)

Change History (0)

Note: See TracTickets for help on using tickets.