sage: t = '"%s"'%10^15000 # 15 thousand character string (note that normal Singular input must be at most 10000) sage: a = singular.eval(t) sage: a = singular(t)
TESTS: We test an automatic coercion:
sage: a = 3*singular('2'); a 6 sage: type(a) <class 'sage.interfaces.singular.SingularElement'> sage: a = singular('2')*3; a 6 sage: type(a) <class 'sage.interfaces.singular.SingularElement'>
Module-level Functions
x) |
) |
) |
) |
) |
Class: Singular
A Groebner basis example.
sage: R = singular.ring(0, '(x0,x1,x2)', 'lp') sage: I = singular.ideal([ 'x0*x1*x2 -x0^2*x2', 'x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2', 'x0*x1-x0*x2-x1*x2']) sage: I.groebner() x1^2*x2^2, x0*x2^3-x1^2*x2^2+x1*x2^3, x0*x1-x0*x2-x1*x2, x0^2*x2-x0*x1*x2
Author: David Joyner and William Stein
self, [maxread=1000], [script_subdirectory=None], [logfile=None], [server=None], [server_tmpdir=None]) |
Functions: clear,
console,
cputime,
current_ring,
current_ring_name,
eval,
get,
ideal,
LIB,
lib,
list,
load,
matrix,
option,
ring,
set,
set_ring,
setring,
string,
trait_names,
version
self, var) |
Clear the variable named var.
self) |
Returns the current ring of the runnging Singular session.
sage: r = PolynomialRing(GF(127),3,'xyz', order='invlex') sage: r._singular_() // characteristic : 127 // number of vars : 3 // block 1 : ordering rp // : names x y z // block 2 : ordering C sage: singular.current_ring() // characteristic : 127 // number of vars : 3 // block 1 : ordering rp // : names x y z // block 2 : ordering C
self) |
Returns the Singular name of the currently active ring in Singular.
Output: currently active ring's name
sage: r = PolynomialRing(GF(127),3,'xyz') sage: r._singular_().name() == singular.current_ring_name() True
self, x, [allow_semicolon=True], [strip=True]) |
Send the code x to the Singular interpreter and return the output as a string.
Input:
sage: singular.eval('2 > 1') '1' sage: singular.eval('2 + 2') '4'
if the verbosity level is
comments are also printed
and not only returned.
sage: r = singular.ring(0,'(x,y,z)','dp') sage: i = singular.ideal(['x^2','y^2','z^2']) sage: s = i.std() sage: singular.eval('hilb(%s)'%(s.name())) '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n// 3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n// degree (affine) = 8'
sage: set_verbose(1) sage: o = singular.eval('hilb(%s)'%(s.name())) // 1 t^0 // -3 t^2 // 3 t^4 // -1 t^6 // 1 t^0 // 3 t^1 // 3 t^2 // 1 t^3 // dimension (affine) = 0 // degree (affine) = 8
This is mainly useful if this method is called implicitly. Because then intermediate results, debugging outputs and printed statements are printed
sage: o = s.hilb() // 1 t^0 // -3 t^2 // 3 t^4 // -1 t^6 // 1 t^0 // 3 t^1 // 3 t^2 // 1 t^3 // dimension (affine) = 0 // degree (affine) = 8 // ** right side is not a datum, assignment ignored
rather than ignored
sage: set_verbose(0) sage: o = s.hilb()
self, var) |
Get string representation of variable named var.
self) |
Return the ideal generated by gens.
Input:
A Groebner basis example done in a different way.
sage: _ = singular.eval("ring R=0,(x0,x1,x2),lp") sage: i1 = singular.ideal([ 'x0*x1*x2 -x0^2*x2', 'x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2', 'x0*x1-x0*x2-x1*x2']) sage: i1 -x0^2*x2+x0*x1*x2, x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2, x0*x1-x0*x2-x1*x2
sage: i2 = singular.ideal('groebner(%s);'%i1.name()) sage: i2 x1^2*x2^2, x0*x2^3-x1^2*x2^2+x1*x2^3, x0*x1-x0*x2-x1*x2, x0^2*x2-x0*x1*x2
self, lib, [reload=False]) |
Load the Singular library named lib.
Note that if the library was already loaded during this session it is not reloaded unless the optional reload argument is True (the default is False).
self, lib, [reload=False]) |
Load the Singular library named lib.
Note that if the library was already loaded during this session it is not reloaded unless the optional reload argument is True (the default is False).
self, lib, [reload=False]) |
Load the Singular library named lib.
Note that if the library was already loaded during this session it is not reloaded unless the optional reload argument is True (the default is False).
self, nrows, ncols, [entries=None]) |
sage: singular.lib("matrix") sage: R = singular.ring(0, '(x,y,z)', 'dp') sage: A = singular.matrix(3,2,'1,2,3,4,5,6') sage: A 1,2, 3,4, 5,6 sage: A.gauss_col() 2,-1, 1,0, 0,1
Author: - Martin Albrecht (malb@informatik.uni-bremen.de), 2006-01-14
self, [cmd=None], [val=None]) |
Access to Singular's options as follows:
Syntax: option() Return Type: string Purpose: lists all defined options.
Syntax: option( 'option_name' ) Return Type: none Purpose: sets an option. Note: To disable an option, use the prefix no.
Syntax: option( 'get' ) Return Type: intvec Purpose: dumps the state of all options to an intvec.
Syntax: option( 'set', intvec_expression ) Type: none Purpose: restores the state of all options from an intvec (produced by option(get)).
self, [char=0], [vars=(x)], [order=lp], [check=True]) |
Create a Singular ring and makes it the current ring.
Input:
Note:
This function is not identical to calling the
Singular ring
function. In particular, it also
attempts to ``kill'' the variable names, so they can actually
be used without getting errors, and it sets printing of
elements for this range to short (i.e., with *'s and carets).
We first declare
with degree reverse lexicographic ordering.
sage: R = singular.ring(0, '(x,y,z)', 'dp') sage: R // characteristic : 0 // number of vars : 3 // block 1 : ordering dp // : names x y z // block 2 : ordering C
sage: R1 = singular.ring(32003, '(x,y,z)', 'dp') sage: R2 = singular.ring(32003, '(a,b,c,d)', 'lp')
This is a ring in variables named x(1) through x(10) over the finite
field of order
:
sage: R3 = singular.ring(7, '(x(1..10))', 'ds')
This is a polynomial ring over the transcendental extension
of
:
sage: R4 = singular.ring('(0,a)', '(mu,nu)', 'lp')
This is a ring over the field of single-precision floats:
sage: R5 = singular.ring('real', '(a,b)', 'lp')
This is over 50-digit floats:
sage: R6 = singular.ring('(real,50)', '(a,b)', 'lp') sage: R7 = singular.ring('(complex,50,i)', '(a,b)', 'lp')
To use a ring that you've defined, use the set_ring() method on the ring. This sets the ring to be the ``current ring''. For example,
sage: R = singular.ring(7, '(a,b)', 'ds') sage: S = singular.ring('real', '(a,b)', 'lp') sage: singular.new('10*a') 1.000e+01*a sage: R.set_ring() sage: singular.new('10*a') 3*a
self, type, name, value) |
Set the variable with given name to the given value.
self) |
Return a list of all Singular commands.
Special Functions: __call__,
__init__,
__reduce__,
_create,
_equality_symbol,
_false_symbol,
_keyboard_interrupt,
_quit_string,
_read_in_file_command,
_start,
_true_symbol
self, x, [type=def]) |
Create a singular object X with given type determined by the string x. This returns var, where var is built using the Singular statement type var = ... x ... Note that the actual name of var could be anything, and can be recovered using X.name().
The object X returned can be used like any Sage object, and wraps an object in self. The standard arithmetic operators work. Morever if foo is a function then X.foo(y,z,...) calls foo(X, y, z, ...) and returns the corresponding object.
sage: R = singular.ring(0, '(x0,x1,x2)', 'lp') sage: I = singular.ideal([ 'x0*x1*x2 -x0^2*x2', 'x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2', 'x0*x1-x0*x2-x1*x2']) sage: I -x0^2*x2+x0*x1*x2, x0^2*x1*x2-x0*x1^2*x2-x0*x1*x2^2, x0*x1-x0*x2-x1*x2 sage: type(I) <class 'sage.interfaces.singular.SingularElement'> sage: I.parent() Singular
Class: SingularElement
self, parent, type, value, [is_name=False]) |
Functions: attrib,
sage_flattened_str_list,
sage_matrix,
sage_poly,
sage_polystring,
sage_structured_str_list,
set_ring,
trait_names,
type
self, name, [value=None]) |
Get and set attributs for self.
Input:
VALUES: isSB - the standard basis property is set by all commands computing a standard basis like groebner, std, stdhilb etc.; used by lift, dim, degree, mult, hilb, vdim, kbase isHomog - the weight vector for homogeneous or quasihomogeneous ideals/modules isCI - complete intersection property isCM - Cohen-Macaulay property rank - set the rank of a module (see nrows) withSB - value of type ideal, resp. module, is std withHilb - value of type intvec is hilb(_,1) (see hilb) withRes - value of type list is a free resolution withDim - value of type int is the dimension (see dim) withMult - value of type int is the multiplicity (see mult)
sage: P.<x,y,z> = PolynomialRing(QQ) sage: I = Ideal([z^2, y*z, y^2, x*z, x*y, x^2]) sage: Ibar = I._singular_() sage: Ibar.attrib('isSB') 0 sage: singular.eval('vdim(%s)'%Ibar.name()) # sage7 name is random // ** sage7 is no standard basis 4 sage: Ibar.attrib('isSB',1) sage: singular.eval('vdim(%s)'%Ibar.name()) '4'
self, R, [sparse=True]) |
Returns SAGE matrix for self
self, R, [kcache=None]) |
Returns a SAGE polynomial in the ring r matching the provided poly which is a singular polynomial.
Input:
sage: R = PolynomialRing(GF(2^8,'a'),2,'xy') sage: f=R('a^20*x^2*y+a^10+x') sage: f._singular_().sage_poly(R)==f True sage: R = PolynomialRing(GF(2^8,'a'),1,'x') sage: f=R('a^20*x^3+x^2+a^10') sage: f._singular_().sage_poly(R)==f True
sage: P.<x,y> = PolynomialRing(QQ, 2) sage: f = x*y**3 - 1/9 * x + 1; f x*y^3 - 1/9*x + 1 sage: singular(f) x*y^3-1/9*x+1 sage: P(singular(f)) x*y^3 - 1/9*x + 1
Author: Martin Albrecht (2006-05-18)
oteFor very simple polynomials eval(SingularElement.sage_polystring()) is faster than SingularElement.sage_poly(R), maybe we should detect the crossover point (in dependence of the string length) and choose an appropriate conversion strategy
self) |
If this Singular element is a polynomial, return a string representation of this polynomial that is suitable for evaluation in Python. Thus * is used for multiplication and ** for exponentiation. This function is primarily used internally.
The short=0 option must be set for the parent ring or
this function will not work as expected. This option is
set by default for rings created using singular.ring
or set using ring_name.set_ring()
.
sage: R = singular.ring(0,'(x,y)') sage: f = singular('x^3 + 3*y^11 + 5') sage: f x^3+3*y^11+5 sage: f.sage_polystring() 'x**3+3*y**11+5'
self) |
If self is a Singular list of lists of Singular elements, returns corresponding SAGE list of lists of strings.
sage: R=singular.ring(0,'(x,y)','dp') sage: RL=R.ringlist() sage: RL [1]: 0 [2]: [1]: x [2]: y [3]: [1]: [1]: dp [2]: 1,1 [2]: [1]: C [2]: 0 [4]: _[1]=0 sage: RL.sage_structured_str_list() ['0', ['x', 'y'], [['dp', '1, 1 '], ['C', '0 ']], '0']
self) |
Returns the internal type of this element.
sage: R = PolynomialRing(GF(2^8,'a'),2,'x') sage: R._singular_().type() 'ring' sage: fs = singular('x0^2','poly') sage: fs.type() 'poly'
Special Functions: __copy__,
__init__,
__iter__,
__len__,
__reduce__,
__setitem__,
_sage_,
_singular_
self) |
Returns a copy of self.
sage: R=singular.ring(0,'(x,y)','dp') sage: M=singular.matrix(3,3,'0,0,-x, 0,y,0, x*y,0,0') sage: N=copy(M) sage: N[1,1]=singular('x+y') sage: N x+y,0,-x, 0, y,0, x*y,0,0 sage: M 0, 0,-x, 0, y,0, x*y,0,0 sage: L=R.ringlist() sage: L[4]=singular.ideal('x**2-5') sage: Q=L.ring() sage: otherR=singular.ring(5,'(x)','dp') sage: cpQ=copy(Q) sage: cpQ.set_ring() sage: cpQ // characteristic : 0 // number of vars : 2 // block 1 : ordering dp // : names x y // block 2 : ordering C // quotient ring from ideal _[1]=x^2-5 sage: R.fetch(M) 0, 0,-x, 0, y,0, x*y,0,0
self, n, value) |
Set the n-th element of self to x.
Input:
sage: R = singular.ring(0, '(x,y,z)', 'dp') sage: A = singular.matrix(2,2) sage: A 0,0, 0,0 sage: A[1,1] = 5 sage: A 5,0, 0,0 sage: A[1,2] = '5*x + y + z3' sage: A 5,z^3+5*x+y, 0,0
self, [R=None]) |
Coerces self to SAGE.
Class: SingularFunction
Special Functions: _sage_doc_
Class: SingularFunctionElement
Special Functions: _sage_doc_
See About this document... for information on suggesting changes.