| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter explains all data types of SINGULAR in alphabetical order. For every type, there is a description of the declaration syntax as well as information about how to build expressions of certain types.
The term expression list in SINGULAR refers to any comma separated list of expressions.
For the general syntax of a declaration see General command syntax.
| 4.1 def | ||
| 4.2 ideal | ||
| 4.3 int | ||
| 4.4 intmat | ||
| 4.5 intvec | ||
| 4.6 link | ||
| 4.7 list | ||
| 4.8 map | ||
| 4.9 matrix | ||
| 4.10 module | ||
| 4.11 number | ||
| 4.12 poly | ||
| 4.13 proc | ||
| 4.14 qring | ||
| 4.15 resolution | ||
| 4.16 ring | ||
| 4.17 string | ||
| 4.18 vector |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Objects may be defined without a specific type: they get their
type from the first assignment to them.
E.g., ideal i=x,y,z; def j=i^2; defines the ideal i^2
with the name j.
Note: Unlike other assignments a ring as an untyped object
is not a copy but another reference to the same (possibly unnamed) ring.
This means that entries in one of these rings appear also in the other ones.
The following defines a ring s which is just another reference (or name)
for the basering r.
ring r=32003,(x,y,z),dp; poly f = x; def s=basering; setring s; nameof(basering); → s listvar(); → // s [0] *ring → // f [0] poly → // r [0] ring → // LIB [0] string standard.lib poly g = y; kill f; listvar(r); → // r [0] ring → // g [0] poly ring t=32003,(u,w),dp; def rt=r+t; rt; → // characteristic : 32003 → // number of vars : 5 → // block 1 : ordering dp → // : names x y z → // block 2 : ordering dp → // : names u w → // block 3 : ordering C
This reference to a ring with def is useful if the basering
is not local to the procedure (so it cannot be accessed by its name) but one
needs a name for it (e.g., for a use with setring or map).
setring r; does not work in this case, because
r may not be local to the procedure.
| 4.1.1 def declarations |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
def name = expression ;
defines an object of the same type as the right-hand side.
none
This is useful if the right-hand side may be of variable type as a consequence of a computation (e.g., ideal or module or matrix). It may also be used in procedures to give the basering a name which is local to the procedure.
def i=2; typeof(i); → int
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Ideals are represented as lists of polynomials which generate the ideal. Like polynomials they can only be defined or accessed with respect to a basering.
Note: size counts only the non-zero generators of an ideal
whereas ncols counts all generators.
| 4.2.1 ideal declarations | ||
| 4.2.2 ideal expressions | ||
| 4.2.3 ideal operations | ||
| 4.2.4 ideal related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ideal name = list_of_poly_and_ideal_expressions ;
ideal name = ideal_expression ;
defines an ideal.
0
ring r=0,(x,y,z),dp; poly s1 = x2; poly s2 = y3; poly s3 = z; ideal i = s1, s2-s1, 0,s2*s3, s3^4; i; → i[1]=x2 → i[2]=y3-x2 → i[3]=0 → i[4]=y3z → i[5]=z4 size(i); → 4 ncols(i); → 5
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An ideal expression is:
+ or *
^ or **)
i*i involves
all products of generators of i while i^2 involves
only the different ones, and is therefore faster.
Example:
ring r=0,(x,y,z),dp; ideal m = maxideal(1); m; → m[1]=x → m[2]=y → m[3]=z poly f = x2; poly g = y3; ideal i = x*y*z , f-g, g*(x-y) + f^4 ,0, 2x-z2y; ideal M = i + maxideal(10); timer =0; i = M*M; timer; → 0 ncols(i); → 505 timer =0; i = M^2; ncols(i); → 505 timer; → 0 i[ncols(i)]; → x20 vector v = [x,y-z,x2,y-x,x2yz2-y]; ideal j = ideal(v);
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition (concatenation of the generators and simplification)
*multiplication (with ideal, poly, vector, module; simplification in case of multiplication with ideal)
^exponentiation (by a non-negative integer)
[ intvec_expression ]are polynomial generators of the ideal, index 1 gives the first generator.
Note: For simplification of an ideal, see also simplify.
Example:
ring r=0,(x,y,z),dp; ideal I = 0,x,0,1; I; → I[1]=0 → I[2]=x → I[3]=0 → I[4]=1 I + 0; // simplification → _[1]=1 ideal J = I,0,x,x-z;; J; → J[1]=0 → J[2]=x → J[3]=0 → J[4]=1 → J[5]=0 → J[6]=x → J[7]=x-z I * J; // multiplication with simplification → _[1]=1 I*x; → _[1]=0 → _[2]=x2 → _[3]=0 → _[4]=x vector V = [x,y,z]; print(V*I); → 0,x2,0,x, → 0,xy,0,y, → 0,xz,0,z ideal m = maxideal(1); m^2; → _[1]=x2 → _[2]=xy → _[3]=xz → _[4]=y2 → _[5]=yz → _[6]=z2 ideal II = I[2..4]; II; → II[1]=x → II[2]=0 → II[3]=1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
char_seriesirreducible characteristic series (see char_series)
coeffsmatrix of coefficients (see coeffs)
contractcontraction by an ideal (see contract)
diffpartial derivative (see diff)
degreemultiplicity, dimension and codimension of the ideal of leading terms (see degree)
dimKrull dimension of basering modulo the ideal of leading terms (see dim)
eliminateelimination of variables (see eliminate)
facstdfactorizing Groebner basis algorithm (see facstd)
factorizeideal of factors of a polynomial (see factorize)
fglmGroebner basis computation from a Groebner basis w.r.t. a different ordering (see fglm)
findunicomputation of univariate polynomials lying in a zero dimensional ideal (see finduni)
groebnerGroebner basis computation (a wrapper around std,stdhilb,stdfglm,...)
(see groebner)
highcornercomputes the smallest monomial not contained in the ideal. The ideal has to be zero-dimensional. (see highcorner)
homoghomogenization with respect to a variable (see homog)
hilbHilbert series of a standard basis (see hilb)
indepSetsets of independent variables of an ideal (see indepSet)
interredinterreduction of an ideal (see interred)
intersectideal intersection (see intersect)
jacobideal of all partial derivatives resp. jacobian matrix (see jacob)
jetTaylor series up to a given order (see jet)
kbasevector space basis of basering modulo ideal of leading terms (see kbase)
koszulKoszul matrix (see koszul)
leadleading terms of a set of generators (see lead)
liftlift-matrix (see lift)
liftstdstandard basis and transformation matrix computation (see liftstd)
lresfree resolution for homogeneous ideals (see lres)
maxidealpower of the maximal ideal at 0 (see maxideal)
minbaseminimal generating set of a homogeneous ideal, resp. module, or an ideal, resp. module, in a local ring (see minbase)
minorset of minors of a matrix (see minor)
modulorepresents (see modulo)
mresminimal free resolution of an ideal resp. module w.r.t. a minimal set of generators of the given ideal resp. module (see mres)
mstdstandard basis and minimal generating set of an ideal (see mstd)
multmultiplicity, resp. degree, of the ideal of leading terms (see mult)
ncolsnumber of columns (see ncols)
preimagepreimage under a ring map (see preimage)
qhweightquasihomogeneous weights of an ideal (see qhweight)
quotientideal quotient (see quotient)
reducenormalform with respect to a standard basis (see reduce)
resfree resolution of an ideal resp. module but not changing the given ideal resp. module (see res)
simplifysimplify a set of polynomials (see simplify)
sizenumber of non-zero generators (see size)
sortvecpermutation for sorting ideals resp. modules (see sortvec)
sresfree resolution of a standard basis (see sres)
stdstandard basis computation (see std)
stdfglmstandard basis computation with fglm technique (see stdfglm)
stdhilbHilbert driven standard basis computation (see stdhilb
substsubstitute a ring variable (see subst)
syzcomputation of the first syzygy module (see syz)
vdimvector space dimension of basering modulo ideal of leading terms (see vdim)
weightoptimal weights (see weight)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Variables of type int represent the machine integers and are, therefore, limited in their range (e.g., the range is between -2147483647 and 2147483647 on 32-bit machines). They are mainly used to count things (dimension, rank, etc.), in loops (see for), and to represent boolean values (FALSE is represented by 0, every other value means TRUE, see boolean expressions).
Integers consist of a sequence of digits, possibly preceded by a sign.
A space is considered as a separator, so it is not allowed between digits.
A sequence of digits outside the allowed range is converted to the type
number if possible.
| 4.3.1 int declarations | ||
| 4.3.2 int expressions | ||
| 4.3.3 int operations | ||
| 4.3.5 boolean expressions | ||
| 4.3.6 boolean operations | ||
| 4.3.4 int related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int name = int_expression ;
defines an integer variable.
0
int i = 42; int j = i + 3; j; → 45 i = i * 3 - j; i; → 81 int k; // assigning the default value 0 to k k; → 0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An int expression is:
+, -, *, div, /,
% (mod), or ^
Note: Variables of type int represent the compiler integers and are, therefore, limited in their range (see Limitations). If this range is too small the expression must be converted to the type number over a ring with characteristic 0.
Example:
12345678901; // too large → ? `12345678901` greater than 2147483647(max. integer representation) → ? error occurred in line 1: `12345678901; // too large` typeof(_); → none ring r=0,x,dp; 12345678901; → 12345678901 typeof(_); → number // Note: 11*13*17*100*200*2000*503*1111*222222 // returns a machine integer: 11*13*17*100*200*2000*503*1111*222222; → // ** int overflow(*), result may be wrong → // ** int overflow(*), result may be wrong → // ** int overflow(*), result may be wrong → // ** int overflow(*), result may be wrong → -1875651584 // using the type cast number for a greater allowed range number(11)*13*17*100*200*2000*503*1111*222222; → 12075748128684240000000 ring rp=32003,x,dp; 12345678901; → 9603 typeof(_); → number intmat m[2][2] = 1,2,3,4; m; → 1,2, → 3,4 m[2,2]; → 4 typeof(_); → int det(m); → -2 m[1,1] + m[2,1] == trace(m); → 0 ! 0; → 1 1 and 2; → 1 intvec v = 1,2,3; def d =transpose(v)*v; // scalarproduct gives an 1x1 intvec typeof(d); → intvec int i = d[1]; // access the first (the only) entry in the intvec ring rr=31,(x,y,z),dp; poly f = 1; i = int(f); // cast to int // Integers may be converted to constant polynomials by an assignment, poly g=37; // define the constant polynomial g equal to the image of // the integer 37 in the actual coefficient field, here it equals 6 g; → 6
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
++changes its operand to its successor, is itself no int expression
--changes its operand to its predecessor, is itself no int expression
+addition
-negation or subtraction
*multiplication
/integer division (omitting the remainder), rounding toward 0
divinteger division (omitting the remainder >= 0)
%integer modulo (the remainder of the division /)
modinteger modulo (the remainder of the division div), always non-negative
^, **exponentiation (exponent must be non-negative)
<, >, <=, >=, ==, <>comparison
Note: An assignment j=i++; or j=i--; is not allowed,
in particular it does not change
the value of j, see Limitations.
Example:
int i=1; int j; i++; i; i--; i; → 2 → 1 // ++ and -- do not return a value as in C, can not assign j = i++; → // ** right side is not a datum, assignment ignored // the value of j is unchanged j; i; → 0 → 2 i+2, 2-i, 5^2; → 4 0 25 5 div 2, 8%3; → 2 2 -5 div 2, -5 / 2, -5 mod 2, -5 % 2; → -3 -2 1 -1 1<2, 2<=2; → 1 1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
charcharacteristic of the coefficient field of a ring (see char)
degdegree of a poly resp. vector (see deg)
detdeterminant (see det)
dimKrull dimension of basering modulo ideal of leading terms, resp. dimension of module of leading terms (see dim)
extgcdBezout representation of gcd (see extgcd)
findposition of a substring in a string (see find)
gcdgreatest common divisor (see gcd)
koszulKoszul matrix (see koszul)
memorymemory usage (see memory)
multmultiplicity of an ideal, resp. module, of leading terms (see mult)
ncolsnumber of columns (see ncols)
nparsnumber of ring parameters (see npars)
nrowsnumber of rows of a matrix, resp. the rank of the free module where the vector or module lives (see nrows)
nvarsnumber of ring variables (see nvars)
orddegree of the leading term of a poly resp. vector (see ord)
parn-th parameter of the basering (see par)
pardegdegree of a number considered as a polynomial in the ring parameters (see pardeg)
primethe next lower prime (see prime)
randoma pseudo random integer between the given limits (see random)
regularityregularity of a resolution (see regularity)
rvartest, if the given expression or string is a ring variable (see rvar)
sizenumber of elements in an object (see size)
tracetrace of an integer matrix (see trace)
varn-th ring variable of the basering (see var)
vdimvector space dimension of basering modulo ideal of leading terms, resp. of freemodule modulo module of leading terms (see vdim)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A boolean expression is really an int expression used in a logical context:
An int expression (<> 0 evaluates to TRUE (represented by 1), 0 represents FALSE).
The following is the list of available comparisons of objects of the same type.
Note: There are no comparisons for ideals and modules, resolution and maps.
i == j i != j // or i <> j i <= j i >= j i > j i < j
m == n m != n // or m <> n m < n m > n m <= n m >= n
For numbers from Z/p or from field extensions not all operations are useful:
- 0 is always the smallest element,
- in Z/p the representatives in the range -(p-1)/2..(p-1)/2 when p>2 resp.
0 and 1 for p=2 are used for comparisons,
- in field extensions the last two operations
(>=,<=) yield always TRUE (1) and
the < and > are equivalent to !=.
f == g f != g // or f <> g f <= g // comparing the leading term w.r.t. the monomial order f < g f >= g f > g
v == w v != w // or v <> w
f == g f != g // or f <> g f <= g // comparing lexicographically f >= g // w.r.t. the order specified by ASCII f > g f < g
and,
or, not)
Note:
All arguments of a logical expression are first evaluated and
then the value of the logical expression is determined. For example, the
logical expression (a || b) is evaluated by first evaluating
a and b, even though the value of b has no
influence on the value of (a || b), if a evaluates to
true.
Note that this evaluation is different from the left-to-right, conditional
evaluation of logical expressions (as found in most programming
languages). For example, in these other languages, the value of (1
|| b) is determined without ever evaluating b.
See Major differences to the C programming language.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
andlogical and, may also be written as &&
orlogical or, may also be written as ||
notlogical not, may also be written as !
The precedence of the boolean operations is:
Example:
(1>2) and 3; → 0 1 > 2 and 3; → 0 ! 0 or 1; → 1 !(0 or 1); → 0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Integer matrices are matrices with integer entries. For the range of
integers see Limitations. Integer matrices do not belong to a
ring, they may be defined without a basering being defined. An intmat
can be multiplied by and added to an int; in this case the int is
converted into an intmat of the right size with the integer on the
diagonal. The integer 1, for example, is converted into the unit
matrix.
| 4.4.1 intmat declarations | ||
| 4.4.2 intmat expressions | ||
| 4.4.3 intmat type cast | ||
| 4.4.4 intmat operations | ||
| 4.4.5 intmat related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
intmat name = intmat_expression ;
intmat name [ rows ] [ cols ] = intmat_expression ;
intmat name [ rows ] [ cols ] = list_of_int_and_intvec_and_intmat_expressions ;
rows and cols must be positive int expressions.
defines an intmat variable.
Given a list of integers, the matrix is filled up with the first row
from the left to the right, then the second row and so on.
If the int_list contains less than rows*cols elements,
the matrix is filled up with zeros; if it contains more
elements, only the first rows*cols elements are used.
0 (1 x 1 matrix)
intmat im[3][5]=1,3,5,7,8,9,10,11,12,13; im; → 1,3,5,7,8, → 9,10,11,12,13, → 0,0,0,0,0 im[3,2]; → 0 intmat m[2][3] = im[1..2,3..5]; // defines a submatrix m; → 5,7,8, → 11,12,13
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An intmat expression is:
+, -, *, div, %)
+, -, *)
Example:
intmat Idm[2][2]; Idm +1; // add the unit intmat → 1,0, → 0,1 intmat m1[3][2] = _,1,-2; // take entries from the last result m1; → 1,0, → 0,1, → 1,-2 intmat m2[2][3]=1,0,2,4,5,1; transpose(m2); → 1,4, → 0,5, → 2,1 intvec v1=1,2,4; intvec v2=5,7,8; m1=v1,v2; // fill m1 with v1 and v2 m1; → 1,2, → 4,5, → 7,8 trace(m1*m2); → 56
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Syntax:intmat ( expression )
intmat ( expression, int_n, int_m )
Type:intmat
Purpose:Converts expression to an intmat, where expression must be of type intvec, or intmat. If int_n and int_m are supplied, then they specify the dimension of the intmat. Otherwise, the size (resp. dimensions) of the intmat are determined by the size (resp. dimensions) of the expression.
Example:intmat(intvec(1)); → 1 intmat(intvec(1), 1, 2); → 1,0 intmat(intvec(1,2,3,4), 2, 2); → 1,2, → 3,4 intmat(_, 2, 3); → 1,2,3, → 4,0,0 intmat(_, 2, 1); → 1, → 2
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition with intmat or int; the int is converted into a diagonal intmat
-negation or subtraction with intmat or int; the int is converted into a diagonal intmat
*multiplication with intmat, intvec, or int; the int is converted into a diagonal intmat
div,/division of entries in the integers (omitting the remainder)
%, modentries modulo int (remainder of the division)
<>, ==comparison
[ intvec_expression, intvec_expression ]is an intmat entry, where the first index indicates the row and the second the column
Example:
intmat m[2][4] = 1,0,2,4,0,1,-1,0,3,2,1,-2; m; → 1,0,2,4, → 0,1,-1,0 m[2,3]; // entry at row 2, col 3 → -1 size(m); // number of entries → 8 intvec v = 1,0,-1,2; m * v; → 7,1 typeof(_); → intvec intmat m1[4][3] = 0,1,2,3,v,1; intmat m2 = m * m1; m2; // 2 x 3 intmat → -2,5,4, → 4,-1,-1 m2*10; // multiply each entry of m with 10; → -20,50,40, → 40,-10,-10 -m2; → 2,-5,-4, → -4,1,1 m2 % 2; → 0,1,0, → 0,1,1 m2 div 2; → -1,2,2, → 2,-1,-1 m2[2,1]; // entry at row 2, col 1 → 4 m1[2..3,2..3]; // submatrix → 1 0 2 1 m2[nrows(m2),ncols(m2)]; // the last entry of intmat m2 → -1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bettiBetti numbers of a free resolution (see betti)
detdeterminant (see det)
ncolsnumber of cols (see ncols)
nrowsnumber of rows (see nrows)
randomcreate a pseudo random intmat (see random)
sizetotal number of entries (see size)
transposetranspose of an intmat (see transpose)
tracetrace of an intmat (see trace)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Variables of type intvec are lists of integers. For the range of integers see Limitations. They may be used for simulating sets of integers (and other sets if the intvec is used as an index set for other objects). Addition and subtraction of an intvec with an int or an intvec is done element-wise.
| 4.5.1 intvec declarations | ||
| 4.5.2 intvec expressions | ||
| 4.5.3 intvec operations | ||
| 4.5.4 intvec related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
intvec name = intvec_expression ;
intvec name = list_of_int_and_intvec_expressions ;
defines an intvec variable.
An intvec consists of an ordered list of integers.
0
intvec iv=1,3,5,7,8; iv; → 1,3,5,7,8 iv[4]; → 7 iv[3..size (iv)]; → 5 7 8
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An intvec expression is:
.. int expression
+, -, *, /, %)
+, -)
*)
Example:
intvec v=-1,2; intvec w=v,v; // concatenation w; → -1,2,-1,2 w = -2..2,v,1; w; → -2,-1,0,1,2,-1,2,1 intmat m[3][2] = 0,1,2,-2,3,1; m*v; → 2,-6,-1 typeof(_); → intvec v = intvec(m); v; → 0,1,2,-2,3,1 ring r; poly f = x2z + 2xy-z; f; → x2z+2xy-z v = leadexp(f); v; → 2,0,1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition with intvec or int (component-wise)
-negation or subtraction with intvec or int (component-wise)
*multiplication with int (component-wise)
/, divdivision by int (component-wise)
%, modmodulo (component-wise)
<>, ==, <=, >=, >, <comparison (done lexicographically)
[ int_expression ]is an element of the intvec; the first element has index one.
Example:
intvec iv = 1,3,5,7,8; iv+1; // add 1 to each entry → 2,4,6,8,9 iv*2; → 2,6,10,14,16 iv; → 1,3,5,7,8 iv-10; → -9,-7,-5,-3,-2 iv=iv,0; iv; → 1,3,5,7,8,0 iv div 2; → 0,1,2,3,4,0 iv+iv; // component-wise addition → 2,6,10,14,16,0 iv[size(iv)-1]; // last-1 entry → 8 intvec iw=2,3,4,0; iv==iw; // lexicographic comparison → 0 iv < iw; → 1 iv != iw; → 1 iv[2]; → 3 iw = 4,1,2; iv[iw]; → 7 1 3
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
hilbreturns Hilbert series as intvec (see hilb)
indepSetsets of independent variables of an ideal (see indepSet)
leadexpthe exponent vector of the leading monomial (see leadexp)
nrowsnumber of rows (see nrows)
qhweightreturns quasihomogeneous weights (see qhweight)
sizelength of the intvec (see size)
sortvecpermutation for sorting ideals/modules (see sortvec)
transposetranspose of an intvec, returns an intmat (see transpose)
weightreturns weights for the weighted ecart method (see weight)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Links are the communication channels of SINGULAR, i.e., something SINGULAR can write to and/or read from. Currently, SINGULAR supports four different link types:
| 4.6.1 link declarations | ||
| 4.6.2 link expressions | ||
| 4.6.3 link related functions | ||
| 4.6.4 ASCII links | ||
| 4.6.5 MP links | ||
| 4.6.6 DBM links |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
link name = string_expression ;
defines a new communication link.
none
link l=":w example.txt"; int i=22; // cf. ASCII links for explanation string s="An int follows:"; write(l,s,i); l; → // type : ASCII → // mode : w → // name : example.txt → // open : yes → // read : not ready → // write: ready close(l); // read(l); → An int follows: → 22 → close(l);
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A link expression is:
A link is described by a string which consists of two parts: a property
string followed by a name string. The property string describes the type
of the link (ASCII, MPfile, MPtcp or DBM)
and the mode of the link (e.g., open for read, write or append). The name
string describes the filename of the link, resp. a network connection
for MPtcp links.
For a detailed format description of the link describing string see:
| 4.6.4 ASCII links | ||
| 4.6.5.1 MPfile links | ||
| 4.6.5.2 MPtcp links | ||
| 4.6.6 DBM links |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
closecloses a link (see close)
dumpgenerates a dump of all variables and their values (see dump)
getdumpreads a dump (see getdump)
openopens a link (see open)
readreads from a link (see read)
statusgets the status of a link (see status)
writewrites to a link (see write)
killcloses and kills a link (see kill)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Via ASCII links data that can be converted to a string can be written
into files for storage or communication with other programs. The data is
written in plain ASCII format. The output format of polynomials is done
w.r.t. the value of the global variable short (see short).
Reading from an ASCII link returns a string — conversion into other data
is up to the user. This can be done, for example,
using the command execute
(see execute).
The ASCII link describing string has to be one of the following:
"ASCII: " + filename
read or
write command.
"ASCII:r " + filename
"ASCII:w " + filename
"ASCII:a " + filename
There are the following default values:
ASCII may be omitted since ASCII links are the
default links.
r, w, or a is specified, the mode of
the link is set by the first read or write command on the
link. If the first command is write, the mode is set to a
(append mode).
read reads from stdin and
write writes to stdout.
Using these default rules, the string ":r temp" describes a link
which is equivalent to the link "ASCII:r temp": an ASCII link to
the file temp which is opened for reading. The string
"temp" describes an ASCII link to the file temp, where the
mode is set by the first read or write command. See also
the example below.
Note that the filename may contain a path. On Microsoft Windows
(resp. MS-DOS) platforms, names of a drive can precede the filename, but
must be started with a // (as in //c/temp/ex. An ASCII
link can be used either for reading or for writing, but not for both at
the same time. A close command must be used before a change of
I/O direction. Types without a conversion to string cannot be
written.
Example:
ring r=32003,(x,y,z),dp;
link l=":w example.txt"; // type is ASCII, mode is overwrite
l;
→ // type : ASCII
→ // mode : w
→ // name : example.txt
→ // open : no
→ // read : not ready
→ // write: not ready
status(l, "open", "yes"); // link is not yet opened
→ 0
ideal i=x2,y2,z2;
write (l,1,";",2,";","ideal i=",i,";");
status(l, "open", "yes"); // now link is open
→ 1
status(l, "mode"); // for writing
→ w
close(l); // link is closed
write("example.txt","int j=5;");// data is appended to file
read("example.txt"); // data is returned as string
→ 1
→ ;
→ 2
→ ;
→ ideal i=
→ x2,y2,z2
→ ;
→ int j=5;
→
execute(read(l)); // read string is executed
→ 1
→ 2
→ // ** redefining i **
close(l); // link is closed
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MP (Multi Protocol) links give the possibility to store and communicate
data in the binary MP format: Read and write access is very fast
compared to ASCII links. MP links can be established using files (link
type is MPfile) or using TCP sockets (link type is
MPtcp). All data (including such data that cannot be converted
to a string) can be written to an MP link. For ring-dependent data, a
ring description is written together with the data. Reading from an MP
link returns an expression (not a string) which was evaluated after the
read operation. If the expression read from an MP link is not from the
same ring as the current ring, then a read changes the current
ring.
Currently, MP links are only available on Unix platforms and data is
written without attributes (which is likely to change in future
versions). For a general description of MP, see
http://symbolicnet.mcs.kent.edu/areas/mp.html.
| 4.6.5.1 MPfile links | ||
| 4.6.5.2 MPtcp links |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MPfile links provide the possibility to store data in a file using the binary MP format. Read and write operations are very fast compared to ASCII links. Therefore, for storing large amounts of data, MPfile links should be used instead of ASCII links. Unlike ASCII links, data read from MPfile links is returned as expressions one at a time, and not as a string containing the entire content of the file. Furthermore, ring-dependent data is stored together with a ring description. Therefore, reading ring-dependent data might change the current ring.
The MPfile link describing string has to be one of the following:
"MPfile: " + filename
read or
write command.
"MPfile:r " + filename
"MPfile:w " + filename
"MPfile:a " + filename
There are the following default values:
r, w, or a is specified, the mode of
the link is set by the first read or write command on the
link. If the first command is write, the mode is set to a
(append mode).
Note that the filename may contain a path. An MPfile link can be used
either for reading or for writing, but not for both at the same time. A
close command must be used before a change of I/O direction.
Example:
ring r;
link l="MPfile:w example.mp"; // type=MPfile, mode=overwrite
l;
→ // type : MPfile
→ // mode : w
→ // name : example.mp
→ // open : no
→ // read : not ready
→ // write: not ready
ideal i=x2,y2,z2;
write (l,1, i, "hello world");// write three expressions
write(l,4); // append one more expression
close(l); // link is closed
// open the file for reading now
read(l); // only first expression is read
→ 1
kill r; // no basering active now
def i = read(l); // second expression
// notice that current ring was set, the name was assigned
// automatically
listvar(ring);
→ // mpsr_r0 [0] *ring
def s = read(l); // third expression
listvar();
→ // s [0] string hello world
→ // mpsr_r0 [0] *ring
→ // i [0] ideal, 3 generator(s)
→ // l [0] link
→ // LIB [0] string standard.lib
close(l); // link is closed
dump("MPfile:w example.mp"); // dump everything to example.mp
kill i, s; // kill i and s
getdump("MPfile: example.mp");// get previous dump
listvar(); // got all variables and values back
→ // mpsr_r0 [0] *ring
→ // i [0] ideal, 3 generator(s)
→ // s [0] string hello world
→ // l [0] link
→ // LIB [0] string standard.lib
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MPtcp links give the possibility to exchange data in the binary MP format between two processes which may run on the same or on different computers. MPtcp links can be opened in four different modes:
listenSINGULAR acts as a server.
connectSINGULAR acts as a client.
launchSINGULAR acts as a client, launching an application as server.
forkSINGULAR acts as a client, forking another SINGULAR as server.
The MPtcp link describing string has to be
"MPtcp:listen --MPport " + portnumber
SINGULAR becomes a server and waits at the port for a connect call.
"MPtcp:connect --MPport " + portnumber
"MPtcp:connect --MPhost " + hostname + " --MPport " +
portnumber
SINGULAR becomes a client and connects to a server waiting at the host and port.
"MPtcp:launch"
"MPtcp:launch --MPrsh " + rsh
"MPtcp:launch --MPrsh " + rsh + " --MPhost " +
hostname
"MPtcp:launch --MPrsh " + rsh + " --MPhost " +
hostname + " --MPapplication " + application
SINGULAR becomes a client and starts (launches) the application
using the specified remote shell command (default is
ssh) on a (possibly) different host (default is localhost
which then acts as a server.
"MPtcp:fork"
SINGULAR becomes a client and forks another SINGULAR on the same host which acts as a server.
There are the following default values:
listen, connect, launch or
fork is specified, the default mode is set to fork.
ssh is used.
launch) the default
application is the value of system("Singular") + "-bq".
(This evaluates to the absolute path of the SINGULAR currently running
with the option "-bq" appended.)
To open an MPtcp link in launch mode, the application to launch must
either be given with an absolute pathname, or must be in a directory
contained in the search path. The launched application acts as a server,
whereas the SINGULAR that actually opened the link acts as a
client. SINGULAR automatically appends the command line arguments
"--MPmode connect --MPhost hostname --MPport portnumber"
to the command line of the server application. Both hostname and
portnumber are substituted by the values from the link
specification. The client "listens" at the given port until the server
application does a connect call. If SINGULAR is used as server
application it has to be started with the command line option -b.
Since launching is done using a remote shell command, the host on which
the application should run must have an entry in the .rhosts
file. Even the local machine must have an entry if applications are to
be launched locally.
If the MPtcp link is opened in fork mode a child of the current SINGULAR is forked. All variables and their values are inherited by the child. The child acts as a server whereas the SINGULAR that actually opened the link acts as a client.
To arrange the evaluation of an expression by a server, the expression
must be quoted using the command quote (see quote), so that
a local evaluation is prevented. Otherwise, the expression is evaluated
first, and the result of the evaluation is written, instead of the
expression which is to be evaluated.
If SINGULAR is in server mode, the value of the variable
mp_ll is the MPtcp link connecting to the client and
SINGULAR is in an infinite read-eval-write loop until the
connection is closed from the client side (by closing its connecting
link). Reading and writing is done to the link mp_ll: After an
expression is read, it is evaluated and the result of the evaluation is
written back. That is, for each expression which was written to the
server, there is exactly one expression written back. This might be an
"empty" expression, if the evaluation on the server side does not return
a value.
MPtcp links should explicitly be opened before being used. MPtcp links
are bidirectional, i.e., can be be used for both, writing and
reading. Reading from an MPtcp link blocks until data was written to
that link. The status command can be used to check whether there
is data to read.
Example:
LIB "general.lib"; // needed for "killall" command
link l="MPtcp:launch";
open(l); l; // l is ready for writing but not for reading
→ // type : MPtcp
→ // mode : launch
→ // name :
→ // open : yes
→ // read : not ready
→ // write: ready
ring r; ideal i=x2+y,xyz+z,x2+y2;
write (l,quote(std(eval(i)))); // std(i) is computed on server
def j = read(l);j; // result of computation on server is read
→ j[1]=z
→ j[2]=y2-y
→ j[3]=x2+y2
write(l, quote(getdump(mp_ll))); // server reads dump
dump(l); // dump is written to server (includes proc's)
read(l); // result of previous write-command is read
killall("not", "link"); killall("proc"); // kills everything, but links
→ // ** killing the basering for level 0
write(l, quote(dump(mp_ll))); // server writes dump
getdump(l); // dump is read from server
read(l); // result of previous write-command is read
close(l); // server is shut down
listvar(all); // same state as we had before "killall()"
→ // mpsr_r0 [0] ring
→ // r [0] *ring
→ // j [0] ideal, 3 generator(s)
→ // i [0] ideal, 3 generator(s)
→ // l [0] link
l = "MPtcp:"; // fork link declaration
open(l); l; // Notice that name is "parent"
→ // type : MPtcp
→ // mode : fork
→ // name : parent
→ // open : yes
→ // read : not ready
→ // write: ready
write(l, quote(status(mp_ll, "name")));
read(l); // and name of forked link is "child"
→ child
write(l,quote(i)); // Child inherited vars and their values
read(l);
→ _[1]=x2+y
→ _[2]=xyz+z
→ _[3]=x2+y2
close(l); // shut down forked child
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
DBM links provide access to data stored in a data base.
Each entry in the data base consists of a (key_string,
value_string) pair. Such a pair can be inserted with the command
write(link, key_string, value_string). By
calling write(link, key_string), the entry with key
key_string is deleted from the data base. The value of an entry is
returned by the command read(link,
key_string). With only one argument, read(link)
returns the next key in the data base. Using this feature a
data base can be scanned in order to access all entries of the data base.
If a data base with name name is opened for writing for the first
time, two files (name.pag and name.dir), which contain the
data base, are automatically created.
The DBM link describing string has to be one of the following:
"DBM: " + name
"DBM:r " + name
"DBM:rw " + name
Note that name must be given without the suffix .pag or
.dir. The name may contain an (absolute) path.
Example:
link l="DBM:rw example"; write(l,"1","abc"); write(l,"3","XYZ"); write(l,"2","ABC"); l; → // type : DBM → // mode : rw → // name : example → // open : yes → // read : ready → // write: ready close(l); // read all keys (till empty string): read(l); → 1 read(l); → 3 read(l); → 2 read(l); → // read data corresponding to key "1" read(l,"1"); → abc // read all data: read(l,read(l)); → abc read(l,read(l)); → XYZ read(l,read(l)); → ABC // close close(l);
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Lists are arrays whose elements can be of any type (including ring and
qring). If one element belongs to a ring the whole list belongs to that
ring. This applies also to the special list #. The expression
list() is the empty list.
Note that a list stores the objects itself and not the names. Hence, if
L is a list, L[1] for example has no name. A name, say
R, can be created for L[1] by def R=L[1];. To store
also the name of an object, say r, it can be added to the list
with nameof(r);. Rings and qrings may be objects of a list.
Note: Unlike other assignments a ring as an element of a list is not a copy but another reference to the same ring.
| 4.7.1 list declarations | ||
| 4.7.2 list expressions | ||
| 4.7.3 list operations | ||
| 4.7.4 list related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
list name = expression_list;
list name = list_expression;
defines a list (of objects of possibly different types).
empty list
list l=1,"str"; l[1]; → 1 l[2]; → str ring r; listvar(r); → // r [0] *ring ideal i = x^2, y^2 + z^3; l[3] = i; l; → [1]: → 1 → [2]: → str → [3]: → _[1]=x2 → _[2]=z3+y2 listvar(r); // the list l belongs now to the ring r → // r [0] *ring → // l [0] list, size: 3 → // i [0] ideal, 2 generator(s)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A list expression is:
list()
+
Example:
list l = "hello",1; l; → [1]: → hello → [2]: → 1 l = list(); l; → empty list ring r =0,x,dp; factorize((x+1)^2); → [1]: → _[1]=1 → _[2]=x+1 → [2]: → 1,2 list(1,2,3); → [1]: → 1 → [2]: → 2 → [3]: → 3
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+concatenation
deletedeletes one element from list, returns new list
insertinserts or appends a new element to list, returns a new list
[ int_expression ]is a list entry; the index 1 gives the first element.
Example:
list l1 = 1,"hello",list(-1,1); list l2 = list(1,2,3); l1 + l2; // one new list → [1]: → 1 → [2]: → hello → [3]: → [1]: → -1 → [2]: → 1 → [4]: → 1 → [5]: → 2 → [6]: → 3 list l3 =_; l1,l2; // two lists → [1]: → 1 → [2]: → hello → [3]: → [1]: → -1 → [2]: → 1 → [1]: → 1 → [2]: → 2 → [3]: → 3 l2[2]; → 2
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bareissreturns a list of a matrix (lower triangular) and of an intvec (permutations of columns, see bareiss)
bettiBetti numbers of a resolution (see betti)
deletedeletes an element from a list (see delete)
facstdfactorizing Groebner basis algorithm (see facstd)
factorizelist of factors of a polynomial (see factorize)
insertinserts or appends a new element to a list (see insert)
lresfree resolution (see lres)
minresminimize a free resolution (see minres)
mresminimal free resolution of an ideal, resp. module w.r.t. a minimal set of generators of the first module (see mres)
nameslist of all user-defined variable names (see names)
resfree resolution of an ideal, resp. module (see res)
sizenumber of entries (see size)
sresfree resolution of an ideal, resp. module, given by a standard base (see sres)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Maps are ring maps from a preimage ring into the basering.
Note:
Maps between rings with different coefficient fields are possible and listed below.
Canonically realized are
Possible are furthermore
Finally, in Singular we allow the mapping from rings with coefficient field Q to rings whose ground fields have finite characteristic:
In these cases the denominator and the numerator of a number are mapped separately by the usual map from Z to Z/p, and the image of the number is built again afterwards by division. It is thus not allowed to map numbers whose denominator is divisible by the characteristic of the target ground field, or objects containing such numbers. We, therefore, strongly recommend using such maps only to map objects with integer coefficients.
| 4.8.1 map declarations | ||
| 4.8.2 map expressions | ||
| 4.8.3 map operations | ||
| 5.1.31 fetch | ||
| 5.1.48 imap | ||
| 5.1.124 subst |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
map name = preimage_ring_name , ideal_expression ;
map name = preimage_ring_name , list_of_poly_and_ideal_expressions ;
map name = map_expression ;
defines a ring map from preimage_ring to basering.
Maps the variables of the preimage ring to the generators of the ideal.
If the ideal contains less elements than variables in the
preimage_ring the remaining variables are mapped to 0, if the ideal contains
more elements these are ignored.
The image ring is always the actual basering.
For the mapping of coefficients from different fields see map.
none
There are standard mappings for maps which are close to the identity
map: fetch and imap.
The name of a map serves as the function which maps objects from the preimage_ring into the basering. These objects must be defined by names (no evaluation in the preimage ring is possible).
ring r1=32003,(x,y,z),dp; ideal i=x,y,z; ring r2=32003,(a,b),dp; map f=r1,a,b,a+b; // maps from r1 to r2, // x -> a // y -> b // z -> a+b f(i); → _[1]=a → _[2]=b → _[3]=a+b // operations like f(i[1]) or f(i*i) are not allowed ideal i=f(i); // objects in different rings may have the same name map g = r2,a2,b2; map phi = g(f); // composition of map f and g // maps from r1 to r2, // x -> a2 // y -> b2 // z -> a2+b2 phi(i); → _[1]=a2 → _[2]=b2 → _[3]=a2+b2
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A map expression is:
(, ))
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
( )composition of maps. If, for example, f and g are maps,
then f(g) is a map expression giving the composition of f
and g.
[ int_expressions ]is a map entry (the image of the corresponding variable)
Example:
ring r=0,(x,y),dp; map f=r,y,x; // the map f permutes the variables f; → f[1]=y → f[2]=x poly p=x+2y3; f(p); → 2x3+y map g=f(f); // the map g defined as f^2 is the identity g; → g[1]=x → g[2]=y g(p) == p; → 1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Objects of type matrix are matrices with polynomial entries. Like polynomials they can only be defined or accessed with respect to a basering. In order to compute with matrices having integer or rational entries define a ring with characteristic 0 and at least one variable.
A matrix can be multiplied by and added to a poly; in this case the poly is converted into a matrix of the right size with the poly on the diagonal.
If A is a matrix then the assignment module M=A; or module
M=module(A); creates a module generated by the columns of A. Note that
the trailing zero columns of A may be deleted by module operations with
M.
| 4.9.1 matrix declarations | ||
| 4.9.2 matrix expressions | ||
| 4.9.3 matrix type cast | ||
| 4.9.4 matrix operations | ||
| 4.9.5 matrix related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
matrix name[rows][cols] = list_of_poly_expressions ;
matrix name = matrix_expression ;
defines a matrix (of polynomials).
The given poly_list fills up the matrix beginning with the first row from the left to the right, then the second row and so on. If the poly_list contains less than rows*cols elements, the matrix is filled up with zeros; if it contains more elements, then only the first rows*cols elements are used. If the right-hand side is a matrix expression the matrix on the left-hand side gets the same size as the right-hand side, otherwise the size is determined by the left-hand side. If the size is omitted a 1x1 matrix is created.
0 (1 x 1 matrix)
int ro = 3; ring r = 32003,(x,y,z),dp; poly f=xyz; poly g=z*f; ideal i=f,g,g^2; matrix m[ro][3] = x3y4, 0, i, f ; // a 3 x 3 matrix m; → m[1,1]=x3y4 → m[1,2]=0 → m[1,3]=xyz → m[2,1]=xyz2 → m[2,2]=x2y2z4 → m[2,3]=xyz → m[3,1]=0 → m[3,2]=0 → m[3,3]=0 print(m); → x3y4,0, xyz, → xyz2,x2y2z4,xyz, → 0, 0, 0 matrix A; // the 1 x 1 zero matrix matrix B[2][2] = m[1..2, 2..3]; //defines a submatrix print(B); → 0, xyz, → x2y2z4,xyz matrix C=m; // defines C as a 3 x 3 matrix equal to m print(C); → x3y4,0, xyz, → xyz2,x2y2z4,xyz, → 0, 0, 0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A matrix expression is:
+, - or *
Example:
ring r=0,(x,y),dp; poly f= x3y2 + 2x2y2 +2; matrix H = jacob(jacob(f)); // the Hessian of f matrix mc = coef(f,y); print(mc); → y2, 1, → x3+2x2,2 module MD = [x+y,1,x],[x+y,0,y]; matrix M = MD; print(M); → x+y,x+y, → 1, 0, → x, y
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Syntax:matrix ( expression )
matrix ( expression, int_n, int_m )
Type:matrix
Purpose:Converts expression to a matrix, where expression must be of type int, intmat, intvec, number, poly, ideal, vector, module, or matrix. If int_n and int_m are supplied, then they specify the dimension of the matrix. Otherwise, the size (resp. dimensions) of the matrix are determined by the size (resp. dimensions) of the expression.
Example:ring r=32003,(x,y,z),dp; matrix(x); → _[1,1]=x matrix(x, 1, 2); → _[1,1]=x → _[1,2]=0 matrix(intmat(intvec(1,2,3,4), 2, 2)); → _[1,1]=1 → _[1,2]=2 → _[2,1]=3 → _[2,2]=4 matrix(_, 2, 3); → _[1,1]=1 → _[1,2]=2 → _[1,3]=0 → _[2,1]=3 → _[2,2]=4 → _[2,3]=0 matrix(_, 2, 1); → _[1,1]=1 → _[2,1]=3
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition with matrix or poly; the poly is converted into a diagonal matrix
-negation or subtraction with matrix or poly; the poly is converted into a diagonal matrix
*multiplication with matrix or poly; the poly is converted into a diagonal matrix
/division by poly
==, <>, !=comparison
[ int_expression, int_expression ]is a matrix entry, where the first index indicates the row and the second the column
Example:
ring r=32003,x,dp; matrix A[3][3] = 1,3,2,5,0,3,2,4,5; // define a matrix print(A); // nice printing of small matrices → 1,3,2, → 5,0,3, → 2,4,5 A[2,3]; // matrix entry → 3 A[2,3] = A[2,3] + 1; // change entry A[2,1..3] = 1,2,3; // change 2nd row print(A); → 1,3,2, → 1,2,3, → 2,4,5 matrix E[3][3]; E = E + 1; // the unit matrix matrix B =x*E - A; print(B); → x-1,-3, -2, → -1, x-2,-3, → -2, -4, x-5 det(B); // the characteristic polynomial of A → x3-8x2-2x-1 A*A*A - 8 * A*A - 2*A == E; // Cayley-Hamilton → 1 vector v =[x,-1,x2]; A*v; // multiplication of matrix and vector → _[1,1]=2x2+x-3 → _[2,1]=3x2+x-2 → _[3,1]=5x2+2x-4 matrix m[2][2]=1,2,3; print(m-transpose(m)); → 0,-1, → 1,0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bareissGauss-Bareiss algorithm (see bareiss)
coefmatrix of coefficients and monomials (see coef)
coeffsmatrix of coefficients (see coeffs)
detdeterminant (see det)
diffpartial derivative (see diff)
jacobJacobi matrix (see jacob)
koszulKoszul matrix (see koszul)
liftlift-matrix (see lift)
liftstdstandard basis and transformation matrix computation (see liftstd)
minorset of minors of a matrix (see minor)
ncolsnumber of columns (see ncols)
nrowsnumber of rows (see nrows)
printnice print format (see print)
sizenumber of matrix entries (see size)
substsubstitute a ring variable (see subst)
tracetrace of a matrix (see trace)
transposetranspose a matrix (see transpose)
wedgewedge product (see wedge)
See also the library matrix_lib, which contains more matrix-related functions.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Modules are submodules of a free module over the basering with basis
gen(1), gen(2), … .
They are represented by lists of vectors which generate the submodule.
Like vectors they
can only be defined or accessed with respect to a basering.
If
is a submodule of
the basering, generated by vectors
may be considered as the generators of relations of
between the canonical generators gen(1),…,gen(n).
Hence any finitely generated
-module can be represented in SINGULAR
by its module of relations. The assignments
module M=v1,...,vk; matrix A=M;
create the presentation matrix of size
for
i.e., the columns of A are the vectors
which generate M (cf. Representation of mathematical objects).
| 4.10.1 module declarations | ||
| 4.10.2 module expressions | ||
| 4.10.3 module operations | ||
| 4.10.4 module related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
module name = list_of_vector_expressions ;
module name = module_expression ;
defines a module.
[0]
ring r=0,(x,y,z),(c,dp); vector s1 = [x2,y3,z]; vector s2 = [xy,1,0]; vector s3 = [0,x2-y2,z]; poly f = xyz; module m = s1, s2-s1,f*(s3-s1); m; → m[1]=[x2,y3,z] → m[2]=[-x2+xy,-y3+1,-z] → m[3]=[-x3yz,-xy4z+x3yz-xy3z] // show m in matrix format (columns generate m) print(m); → x2,-x2+xy,-x3yz, → y3,-y3+1, -xy4z+x3yz-xy3z, → z, -z, 0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A module expression is:
+
*
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition (concatenation of the generators and simplification)
*multiplication with ideal or poly, but not ‘module‘ * ‘module‘
[ int_expression , int_expression ]is a module entry, where the first index indicates the row and the second the column
[ int_expression ]is a vector, where the index indicates the column
Example:
ring r=0,(x,y,z),dp; module m=[x,y],[0,0,z]; print(m*(x+y)); → x2+xy,0, → xy+y2,0, → 0, xz+yz
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
coeffsmatrix of coefficients (see coeffs)
degreemultiplicity, dimension and codimension of the module of leading terms (see degree)
diffpartial derivative (see diff)
dimKrull dimension of free module over the basering modulo the module of leading terms (see dim)
eliminateelimination of variables (see eliminate)
freemodulethe free module of given rank (see freemodule)
groebnerGroebner basis computation (a wrapper around std,stdhilb,stdfglm,...)
(see groebner)
hilbHilbert function of a standard basis (see hilb)
homoghomogenization with respect to a variable (see homog)
interredinterreduction of a module (see interred)
intersectmodule intersection (see intersect)
jetTaylor series up to a given order (see jet)
kbasevector space basis of free module over the basering modulo the module of leading terms (see kbase)
leadinitial module (see lead)
liftlift-matrix (see lift)
liftstdstandard basis and transformation matrix computation (see liftstd)
lresfree resolution (see lres)
minbaseminimal generating set of a homogeneous ideal, resp. module, or an ideal, resp. module, over a local ring
modulorepresents (see modulo)
mresminimal free resolution of an ideal resp. module w.r.t. a minimal set of generators of the given module (see mres)
multmultiplicity, resp. degree, of the module of leading terms (see mult)
ncolsnumber of columns (see ncols)
nrowsnumber of rows (see nrows)
printnice print format (see print)
pruneminimize the embedding into a free module (see prune)
qhweightquasihomogeneous weights of an ideal, resp. module (see qhweight)
quotientmodule quotient (see quotient)
reducenormalform with respect to a standard basis (see reduce)
resfree resolution of an ideal, resp. module, but not changing the given ideal, resp. module (see res)
simplifysimplify a set of vectors (see simplify)
sizenumber of non-zero generators (see size)
sortvecpermutation for sorting ideals/modules (see sortvec)
sresfree resolution of a standard basis (see sres)
stdsubstsubstitute a ring variable (see subst)
syzcomputation of the first syzygy module (see syz)
vdimvector space dimension of free module over the basering modulo module of leading terms (see vdim)
weight"optimal" weights (see weight)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Numbers are elements from the coefficient field (or ground field). They can only be defined or accessed with respect to a basering which determines the coefficient field. See ring declarations for declarations of coefficient fields.
Warning: Beware of the special meaning of the letter e
(immediately following a sequence of digits) if the field is real (or complex).
See number operations, Miscellaneous oddities.
| 4.11.1 number declarations | ||
| 4.11.2 number expressions | ||
| 4.11.3 number operations | ||
| 4.11.4 number related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
number name = number_expression ;
defines a number.
0
Numbers may only be declared w.r.t. the coefficient field of the current basering, i.e., a ring has to be defined prior to any number declaration. See Rings and orderings for a list of the available coefficient fields.
// finite field Z/p, p<= 32003 ring r = 32003,(x,y,z),dp; number n = 4/6; n; → -10667 // finite field GF(p^n), p^n <= 32767 // z is a primitive root of the minimal polynomial ring rg= (7^2,z),x,dp; number n = 4/9+z; n; → z11 // the rational numbers ring r0 = 0,x,dp; number n = 4/6; n; → 2/3 // algebraic extensions of Z/p or Q ring ra=(0,a),x,dp; minpoly=a^2+1; number n=a3+a2+2a-1; n; → (a-2) a^2; → -1 // transcedental extensions of Z/p or Q ring rt=(0,a),x,dp; number n=a3+a2+2a-1; n; → (a3+a2+2a-1) a^2; → (a2) // machine floating point numbers, single precision ring R_0=real,x,dp; number n=4/6; n; → 6.667e-01 n=0.25e+2; n; → 2.500e+01 // floating point numbers, arbitrary prescribed precision ring R_1=(real,50),x,dp; number n=4.0/6; n; → 0.66666666666666666666666666666666666666666666666667 n=0.25e+2; n; → 25 // floating point complex numbers, arbitrary prescribed precision // the third parameter gives the name of the imaginary unit ring R_2=(complex,50,i),x,dp; number n=4.0/6; n; → 0.66666666666666666666666666666666666666666666666667 n=0.25e+2*i+n; n; → (0.66666666666666666666666666666666666666666666666667+i*25)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A number expression is:
real):
.<digits>e<sign><digits>
+, -, *, /, ^, or **.
Example:
// the following expressions are in any ring int expressions 2 / 3; → 0 4/ 8; → 0 2 /2; // the notation of / for div might change in the future → 1 ring r0=0,x,dp; 2/3, 4/8, 2/2 ; // are numbers → 2/3 1/2 1 poly f = 2x2 +1; leadcoef(f); → 2 typeof(_); → number ring rr =real,x,dp; 1.7e-2; 1.7e+2; // are valid (but 1.7e2 not), if the field is `real` → 1.700e-02 → 1.700e+02 ring rp = (31,t),x,dp; 2/3, 4/8, 2/2 ; // are numbers → 11 -15 1 poly g = (3t2 +1)*x2 +1; leadcoef(g); → (3t2+1) typeof(_); → number par(1); → (t) typeof(_); → number
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition
-negation or subtraction
*multiplication
/division
^, **power, exponentiation (by an integer)
<=, >=, ==, <>comparison
modinteger modulo (the remainder of the division div), always non-negative
Note: quotient and exponentiation is only recognized as a
number expression if it is already a number, see Miscellaneous oddities.
For the behavior of comparison operators in rings with
ground field different from real or the rational numbers, see boolean expressions.
Example:
ring r=0,x,dp; number n = 1/2 +1/3; n; → 5/6 n/2; → 5/12 1/2/3; → 1/6 1/2 * 1/3; → 1/6 n = 2; n^-2; → 1/4 // the following oddities appear here 2/(2+3); → 0 number(2)/(2+3); → 2/5 2^-2; // for int's exponent must be non-negative → ? exponent must be non-negative → ? error occurred in line 12: ` 2^-2; // for int's exponent must be no\ n-negative` number(2)^-2; → 1/4 3/4>=2/5; → 1 2/6==1/3; → 1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
cleardenomcancel denominators of numbers in poly and divide it by its content (see cleardenom)
impartimaginary part of a complex number, 0 otherwise (see impart, repart)
numerator, denominatorreturn the numerator/denominator of a rational number (see numerator, denominator)
leadcoefcoefficient of the leading term (see leadcoef)
parn-th parameter of the basering (see par)
pardegdegree of a number in ring parameters (see pardeg)
parstrstring form of ring parameters (see parstr)
repart| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Polynomials are the basic data for all main algorithms in
SINGULAR. They consist of finitely many terms
(coefficient*power product) which are combined by the usual polynomial
operations (see poly expressions). Polynomials can only be defined
or accessed with respect to a basering which determines the coefficient
type, the names of the indeterminates and the monomial ordering.
ring r=32003,(x,y,z),dp; poly f=x3+y5+z2;
| 4.12.1 poly declarations | ||
| 4.12.2 poly expressions | ||
| 4.12.3 poly operations | ||
| 4.12.4 poly related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
poly name = poly_expression ;
defines a polynomial.
0
ring r = 32003,(x,y,z),dp; poly s1 = x3y2+151x5y+186xy6+169y9; poly s2 = 1*x^2*y^2*z^2+3z8; poly s3 = 5/4x4y2+4/5*x*y^5+2x2y2z3+y7+11x10; int a,b,c,t=37,5,4,1; poly f=3*x^a+x*y^(b+c)+t*x^a*y^b*z^c; f; → x37y5z4+3x37+xy9 short = 0; f; → x^37*y^5*z^4+3*x^37+x*y^9
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A poly expression is (optional parts in square brackets):
[coefficient] ring_variable [ exponent] [ring_variable [exponent] …]
monomials which contain an indexed ring variable
must be built from ring_variable and coefficient
with the operations * and ^
+, -, *, /, or ^
Example:
2x, x3, 2x2y3, xyz, 2xy2; // are monomials
2*x, x^3, 2*x^2*y^3, x*y*z, 2*x*y^2; // are poly expressions
2*x(1); // is a valid poly expression, but not 2x(1) (a syntax error)
2*x^3; // is a valid poly expression equal to 2x3 (a valid monomial)
// but not equal to 2x^3 which will be interpreted as (2x)^3
// since 2x is a monomial
ring r=0,(x,y),dp;
poly f = 10x2y3 +2x2y2-2xy+y -x+2;
lead(f);
→ 10x2y3
leadmonom(f);
→ x2y3
simplify(f,1); // normalize leading coefficient
→ x2y3+1/5x2y2-1/5xy-1/10x+1/10y+1/5
poly g = 1/2x2 + 1/3y;
cleardenom(g);
→ 3x2+2y
int i = 102;
poly(i);
→ 102
typeof(_);
→ poly
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition
-negation or subtraction
*multiplication
/division by a polynomial, ignoring the rest
^, **power by an integer
<, <=, >, >=, ==, <>comparison (w.r.t. monomial ordering)
[ intvec_expression ]the monomial at the indicated place w.r.t. the monomial ordering
Example:
ring R=0,(x,y),dp; poly f = x3y2 + 2x2y2 + xy - x + y + 1; f; → x3y2+2x2y2+xy-x+y+1 f + x5 + 2; → x5+x3y2+2x2y2+xy-x+y+3 f * x2; → x5y2+2x4y2+x3y-x3+x2y+x2 (x+y)/x; → 1 f/3x2; → 1/3xy2+2/3y2 x5 > f; → 1 x<=y; → 0 x>y; → 1 ring r=0,(x,y),ds; poly f = fetch(R,f); f; → 1-x+y+xy+2x2y2+x3y2 x5 > f; → 0 f[2..4]; → -x+y+xy size(f); → 6 f[size(f)+1]; f[-1]; // monomials out of range are 0 → 0 → 0 intvec v = 6,1,3; f[v]; // the polynom built from the 1st, 3rd and 6th monomial of f → 1+y+x3y2
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
cleardenomcancel denominators of numbers in poly and divide it by its content (see cleardenom)
coefmatrix of coefficients and monomials (see coef)
coeffsmatrix of coefficients (see coeffs)
degdegree (see deg)
detdeterminant (see det)
diffpartial derivative (see diff)
extgcdBezout representation of gcd (see extgcd)
factorizefactorize polynomial (see factorize)
findunifind univariate polynomials in a zero-dimensional ideal (see finduni)
gcdgreatest common divisor (see gcd)
homoghomogenization (see homog)
jacobideal, resp. matrix, of all partial derivatives (see jacob)
leadleading term (see lead)
leadcoefcoefficient of the leading term (see leadcoef)
leadexpthe exponent vector of the leading monomial (see leadexp)
leadmonomleading monomial (see leadmonom)
jetmonomials with degree smaller k+1 (see jet)
orddegree of the leading monomial (see ord)
qhweightquasihomogeneous weights (see qhweight)
reducenormal form with respect to a standard base (see reduce)
rvartest for ring variable (see rvar)
simplifynormalize a polynomial (see simplify)
sizenumber of monomials (see size)
substsubstitute a ring variable (see subst)
tracetrace of a matrix (see trace)
varthe indicated variable of the ring (see var)
varstrvariable in string form (see varstr)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Procedures are sequences of SINGULAR commands in a special
format. They are used to extend the set of SINGULAR commands with
user defined commands. Once a procedure is defined it can be used as
any other SINGULAR command. Procedures may be defined by either
typing them on the command line or by loading them from a file. For a
detailed description on the concept of procedures in SINGULAR see
Procedures. A file containing procedure definitions which comply with
certain syntax rules is called a library. Such a file is loaded
using the command LIB. For more information on libraries see
Libraries.
| 4.13.1 proc declaration |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[static] proc proc_name [parameter_list]
["help_text"]
{
procedure_body
}
[example
{
sequence_of_commands;
}]
proc proc_name = proc_name ;
proc proc_name = string_expression ;
defines a new function, the proc proc_name, with the additional
information help_text, which is copied to the screen by
help proc_name; and the example section
which is executed by example proc_name;.
The help_text, the parameter_list, and the example section are optional.
The default for a parameter_list is (list #), see Parameter list.
The help and example sections are ignored if the procedure is defined
interactively, i.e., if it was not loaded from a file by a LIB command.
Specifying static in front of the proc-definition is only possible
in a library file and makes this procedure local to the library,
i.e., accessible only for the other procedures in the same library,
but not for the users.
proc milnor_number (poly p)
{
ideal i= std(jacob(p));
int m_nr=vdim(i);
if (m_nr<0)
{
"// not an isolated singularity";
}
return(m_nr); // the value of m_nr is returned
}
ring r1=0,(x,y,z),ds;
poly p=x^2+y^2+z^5;
milnor_number(p);
→ 4
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
SINGULAR offers the opportunity to calculate in quotient rings (factor rings), i.e., rings modulo an ideal. The ideal has to be given as a standard basis. For a detailed description of the concept of rings and quotient rings see Rings and orderings.
| 4.14.1 qring declaration |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
qring name = ideal_expression ;
none
declares a quotient ring as the basering modulo ideal_expression. Sets it as current basering.
ring r=0,(x,y,z),dp; ideal i=xy; qring q=std(i); basering; → // characteristic : 0 → // number of vars : 3 → // block 1 : ordering dp → // : names x y z → // block 2 : ordering C → // quotient ring from ideal → _[1]=xy
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The resolution type is intended as an intermediate representation which internally retains additional information obtained during computation of resolutions. It furthermore enables the use of partial results to compute, for example, Betti numbers or minimal resolutions. Like ideals and modules, a resolution can only be defined w.r.t. a basering.
Note:
to access the elements of a resolution, it has to be assigned to a list,
which also completes computations and may therefore take time,
(resp. an access directly with the brackets [ , ] causes
implicitly a cast to a list).
| 4.15.1 resolution declarations | ||
| 4.15.2 resolution expressions | ||
| 4.15.3 resolution related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
resolution name = resolution_expression ;
defines a resolution.
none
ring R; ideal i=z2,x; resolution re=res(i,0); re; → 1 2 1 → R <-- R <-- R → → 0 1 2 → resolution not minimized yet → betti(re); → 1,1,0, → 0,1,1 list l = re; l; → [1]: → _[1]=x → _[2]=z2 → [2]: → _[1]=-z2*gen(1)+x*gen(2) → [3]: → _[1]=0
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A resolution expression is:
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
bettiBetti numbers of a resolution (see betti)
lresfree resolution (see lres)
minresminimize a free resolution (see minres)
mresminimal free resolution of an ideal, resp. module w.r.t. a minimal set of generators of the given ideal, resp. module (see mres)
resfree resolution of an ideal, resp. module, but not changing the given ideal, resp. module (see res)
sresfree resolution of a standard basis (see sres)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Rings are used to describe properties of polynomials, ideals etc. Almost all computations in SINGULAR require a basering. For a detailed description of the concept of rings see Rings and orderings.
| 4.16.1 ring declarations | ||
| 4.16.2 ring related functions | ||
| 4.16.3 ring operations |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ring name = ( coefficient_field ),
( names_of_ring_variables ),
( ordering );
32003,(x,y,z),(dp,C);
declares a ring and sets it as the actual basering.
The coefficient_field is given by one of the following:
real
real and an int_expression.
complex, an optional int_expression
and a name.
For the definition of the ’coefficient_field’, see Rings and orderings.
’names_of_ring_variables’ must be a list of names or indexed names.
’ordering’ is a list of block orderings where each block ordering is either
lp, dp, Dp, ls, ds, or Ds
optionally followed by a size parameter in parentheses.
wp, Wp, ws, Ws, or a followed by a
weight vector given as an intvec_expression in parentheses.
M followed by an intmat_expression in parentheses.
c or C.
For the definition of the orderings, see Term orderings, Monomial orderings.
If one of coefficient_field, names_of_ring_variables, and ordering consists of only one entry, the parentheses around this entry may be omitted.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
charstrdescription of the coefficient field of a ring (see charstr)
keepringmove ring to next upper level (see keepring)
nparsnumber of ring parameters (see npars)
nvarsnumber of ring variables (see nvars)
ordstrmonomial ordering of a ring (see ordstr)
parstrnames of all ring parameters or the name of the n-th ring parameter (see parstr)
qringquotient ring (see qring)
setringset a new basering (see setring)
varstrnames of all ring variables or the name of the n-th ring variable (see varstr)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+construct a new ring from and .
Concerning the ground fields and take the following guide lines into consideration:
charstr of type (p^n,a).
Example:
ring R1=0,(x,y),dp; ring R2=32003,(a,b),dp; def R=R1+R2; R; → // characteristic : 32003 → // number of vars : 4 → // block 1 : ordering dp → // : names x y → // block 2 : ordering dp → // : names a b → // block 3 : ordering C
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Variables of type string are used for output (almost every type
can be "converted" to string) and for creating new
commands at runtime see execute. They are also return values of
certain interpreter related functions (see Functions). String
constants consist of a sequence of ANY characters (including newline!)
between a starting " and a closing ". There is also a
string constant newline, which is the newline character. The
+ sign "adds" strings, "" is the empty string (hence
strings form a semigroup). Strings may be used to comment the output of
a computation or to give it a nice format. Strings may also be used for
intermediate conversion of one type into another.
string s="Hi"; string s1="a string with new line at the end"+newline; string s2="another string with new line at the end "; s;s1;s2; → Hi → a string with new line at the end → → another string with new line at the end → ring r; ideal i=std(ideal(x,y^3)); "dimension of i =",dim(i),", multiplicity of i =",mult(i); → dimension of i = 1 , multiplicity of i = 3 "dimension of i = "+string(dim(i))+", multiplicity of i = "+string(mult(i)); → dimension of i = 1, multiplicity of i = 3 "a"+"b","c"; → ab c
A comma between two strings makes an expression list out of them
(such a list is printed with a separating blank in between),
while a + concatenates strings.
| 4.17.1 string declarations | ||
| 4.17.2 string expressions | ||
| 4.17.3 string type cast | ||
| 4.17.4 string operations | ||
| 4.17.5 string related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
string name = string_expression ;
string name = list_of_string_expressions ;
defines a string variable.
"" (the empty string)
string s1="Now I know"; string s2="how to encode a \" in a string..."; string s=s1+" "+s2; // concatenation of 3 strings s; → Now I know how to encode a " in a string... s1,s2; // 2 strings, separated by a blank in the output: → Now I know how to encode a " in a string...
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A string expression is:
")
+.
Example:
// string_expression[start, length] : a substring // (possibly filled up with blanks) // the substring of s starting at position 2 // with a length of 4 string s="123456"; s[2,4]; → 2345 "abcd"[2,2]; → bc // string_expression[position] : a character from a string s[3]; → 3 // string_expression[position..position] : // a substring starting at the first position up to the second // given position s[2..4]; → 2 3 4 // a function returning a string typeof(s); → string
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Syntax:string ( expression [, expression_2, ... expression_n])
Type:string
Purpose:Converts each expression to a string, where expression can be of any type. The concatenated string of all concersions is returned.
The elements of intvec, intmat, ideal, module, matrix, and list, are
separated by a comma. No newlines are inserted.
Not defined elements of a list are omitted.
For link, the name of the link is used.
For map, the ideal defining the mapping is converted.
Note:When applied to a list, elements of type intvec, intmat, ideal, module, matrix, and list become indistinguishable.
Example: string("1+1=", 2);
→ 1+1=2
string(intvec(1,2,3,4));
→ 1,2,3,4
string(intmat(intvec(1,2,3,4), 2, 2));
→ 1,2,3,4
ring r;
string(r);
→ (32003),(x,y,z),(dp(3),C)
string(ideal(x,y));
→ x,y
qring R = std(ideal(x,y));
string(R);
→ (32003),(x,y,z),(dp(3),C)
map phi = r, ideal(x,z);
string(phi);
→ x,z
list l;
string(l);
→
l[3] = 1;
string(l); // notice that l[1],l[2] are omitted
→ 1
l[2] = l;
l;
→ [2]:
→ [3]:
→ 1
→ [3]:
→ 1
string(l); // notice that lists of list is flattened
→ 1,1
l[1] = intvec(1,2,3);
l;
→ [1]:
→ 1,2,3
→ [2]:
→ [3]:
→ 1
→ [3]:
→ 1
string(l); // notice that intvec elements are not distinguishable
→ 1,2,3,1,1
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+concatenation
<=, >=, ==, <>comparison (lexicographical with respect to the ASCII encoding)
[ int_expression ]is a character of the string; the index 1 gives the first character.
[ int_expression, int_expression ]is a substring, where the first argument is the start index and the second is the length of the substring, filled up with blanks if the length exceeds the total size of the string
[ intvec_expression ]is a expression list of characters from the string
Example:
string s="abcde"; s[2]; → b s[3,2]; → cd ">>"+s[1,10]+"<<"; → >>abcde << s[2]="BC"; s; → aBcde intvec v=1,3,5; s=s[v]; s; → ace s="123456"; s=s[3..5]; s; → 345
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
charstrdescription of the coefficient field of a ring (see charstr)
executeexecuting string as command (see execute)
findposition of a substring in a string (see find)
nameslist of strings of all user-defined variable names (see names)
nameofname of an object (see nameof)
optionlists all defined options (see option)
ordstrmonomial ordering of a ring (see ordstr)
parstrnames of all ring parameters or the name of the n-th ring parameter (see parstr)
readread a file (see read)
sizelength of a string (see size)
sprintfstring formatting (see sprintf)
typeoftype of an object (see typeof)
varstrnames of all ring variables or the name of the n-th ring variable (see varstr)
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Vectors are elements of a free module over the basering with basis
gen(1), gen(2), … .
Each vector belongs to a free module of rank equal to the biggest index
of a generator with non-zero coefficient. Since generators with zero
coefficients need not be written any vector may be considered
also as an element of a free module of higher rank.
Like polynomials they
can only be defined or accessed with respect to the basering.
(E.g., if f and g are polynomials then
f*gen(1)+g*gen(3)+gen(4) may also be written as [f,0,g,1]
or as [f,0,g,1,0].) Note that the elements of a vector have to be
surrounded by square brackets ([ , ])
(cf. Representation of mathematical objects).
| 4.18.1 vector declarations | ||
| 4.18.2 vector expressions | ||
| 4.18.3 vector operations | ||
| 4.18.4 vector related functions |
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
vector name = vector_expression ;
defines a vector of polynomials (an element of a free module).
[0]
ring r=0,(x,y,z),(c,dp); poly s1 = x2; poly s2 = y3; poly s3 = z; vector v = [s1, s2-s1, s3-s1]+ s1*gen(5); // v is a vector in the free module of rank 5 v; → [x2,y3-x2,-x2+z,0,x2]
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A vector expression is:
p → p*gen(1))
+ or
-
*
[ , ]
Example:
// ordering gives priority to components: ring rr=0,(x,y,z),(c,dp); vector v=[x2+y3,2,0,x*y]+gen(6)*x6; v; → [y3+x2,2,0,xy,0,x6] vector w=[z3-x,3y]; v-w; → [y3-z3+x2+x,-3y+2,0,xy,0,x6] v*(z+x); → [xy3+y3z+x3+x2z,2x+2z,0,x2y+xyz,0,x7+x6z]
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
+addition
-negation or subtraction
/division by a monomial, not divisible terms yield 0
<, <=, >, >=, ==, <>comparison of leading terms w.r.t. monomial ordering
[ int_expressions ]is a vector entry; the index 1 gives the first entry.
Example:
ring R=0,(x,y),(c,dp); [x,y]-[1,x]; → [x-1,-x+y] [1,2,x,4][3]; → x
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
cleardenomquotient of a vector by its content (see cleardenom)
coeffsmatrix of coefficients (see coeffs)
degdegree (see deg)
diffpartial derivative (see diff)
geni-th generator (see gen)
homoghomogenization (see homog)
jetk-jet: monomials with degree smaller k+1 (see jet)
leadleading term (see lead)
leadcoefleading coefficient (see leadcoef)
leadexpthe exponent vector of the leading monomial (see leadexp)
leadmonomleading monomial (see leadmonom)
nrowsnumber of rows (see nrows)
orddegree of the leading monomial (see ord)
reducenormal form with respect to a standard base (see reduce)
simplifynormalize a vector (see simplify)
sizenumber of monomials (see size)
substsubstitute a ring variable (see subst)
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on a sunny day using texi2any.