Top
Back: D.2.2.13 product
Forward: D.2.2.15 sum
FastBack: D. SINGULAR libraries
FastForward: E. Release Notes
Up: D.2.2 general_lib
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

D.2.2.14 sort

Procedure from library general.lib (see general_lib).

Usage:

sort(id[v,o,n]); id = ideal/module/intvec/list(of intvec’s or int’s)
sort may be called with 1, 2 or 3 arguments in the following way:
sort(id[v,n]); v=intvec of positive integers, n=integer,
sort(id[o,n]); o=string (any allowed ordstr of a ring), n=integer

Return:

a list l of two elements:

 
        l[1]: object of same type as input but sorted in the following way:
           - if id=ideal/module: generators of id are sorted w.r.t. intvec v
             (id[v[1]] becomes 1-st, id[v[2]]  2-nd element, etc.). If no v is
             present, id is sorted w.r.t. ordering o (if o is given) or w.r.t.
             actual monomial ordering (if no o is given):
             NOTE: generators with SMALLER(!) leading term come FIRST
             (e.g. sort(id); sorts backwards to actual monomial ordering)
           - if id=list of intvec’s or int’s: consider a list element, say
             id[1]=3,2,5, as exponent vector of the monomial x^3*y^2*z^5;
             the corresponding monomials are ordered w.r.t. intvec v (s.a.).
             If no v is present, the monomials are sorted w.r.t. ordering o
             (if o is given) or w.r.t. lexicographical ordering (if no o is
             given). The corresponding ordered list of exponent vectors is
             returned.
             (e.g. sort(id); sorts lexicographically, smaller int’s come first)
             WARNING: Since negative exponents create the 0 polynomial in
             Singular, id should not contain negative integers: the result
             might not be as expected
           - if id=intvec: id is treated as list of integers
           - if n!=0 the ordering is inverse, i.e. w.r.t. v(size(v)..1)
             default: n=0
         l[2]: intvec, describing the permutation of the input (hence l[2]=v
             if v is given (with positive integers))
Note:

If v is given id may be any simply indexed object (e.g. any list or string); if v[i]<0 and i<=size(id) v[i] is set internally to i; entries of v must be pairwise distinct to get a permutation if id. Zero generators of ideal/module are deleted

Example:

 
LIB "general.lib";
ring r0 = 0,(x,y,z,t),lp;
ideal i = x3,z3,xyz;
sort(i);            //sorts using lex ordering, smaller polys come first
→ [1]:
→    _[1]=z3
→    _[2]=xyz
→    _[3]=x3
→ [2]:
→    2,3,1
sort(i,3..1);
→ [1]:
→    _[1]=xyz
→    _[2]=z3
→    _[3]=x3
→ [2]:
→    3,2,1
sort(i,"ls")[1];     //sort w.r.t. negative lex ordering
→ _[1]=x3
→ _[2]=xyz
→ _[3]=z3
intvec v =1,10..5,2..4;v;
→ 1,10,9,8,7,6,5,2,3,4
sort(v)[1];          // sort v lexicographically
→ 1,2,3,4,5,6,7,8,9,10
sort(v,"Dp",1)[1];   // sort v w.r.t (total sum, reverse lex)
→ 10,9,8,7,6,5,4,3,2,1

Top Back: D.2.2.13 product Forward: D.2.2.15 sum FastBack: D. SINGULAR libraries FastForward: E. Release Notes Up: D.2.2 general_lib Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.