Package sage :: Package rings :: Package polynomial :: Module term_order :: Class TermOrder
[hide private]
[frames] | no frames]

Class TermOrder

source code

                      object --+    
                               |    
structure.sage_object.SageObject --+
                                   |
                                  TermOrder


A term order.

See \code{sage.rings.polynomial.term_order} for details on
supported term orderings.



Instance Methods [hide private]
 
__init__(self, name='lex', n=0, blocks=True)
Construct a new term ordering object.
source code
 
__getattr__(self, name)
Return the correct compare_tuples/greater_tuple function.
source code
 
compare_tuples_lp(self, f, g)
Compares two exponent tuples with respect to the lexicographical term order.
source code
 
compare_tuples_rp(self, f, g)
Compares two exponent tuples with respect to the inversed lexicographical term order.
source code
 
compare_tuples_Dp(self, f, g)
Compares two exponent tuples with respect to the degree lexicographical term order.
source code
 
compare_tuples_dp(self, f, g)
Compares two exponent tuples with respect to the degree reversed lexicographical term order.
source code
 
compare_tuples_ls(self, f, g)
Compares two exponent tuples with respect to the negative lexicographical term order.
source code
 
compare_tuples_ds(self, f, g)
Compares two exponent tuples with respect to the negative degree reverse lexicographical term order.
source code
 
compare_tuples_Ds(self, f, g)
Compares two exponent tuples with respect to the negative degree lexicographical term order.
source code
 
compare_tuples_block(self, f, g)
Compares two exponent tuple with respec to the block ordering as specified when constructing this element.
source code
 
greater_tuple_lp(self, f, g)
Returns the greater exponent tuple with respect to the lexicographical term order.
source code
 
greater_tuple_rp(self, f, g)
Returns the greater exponent tuple with respect to the inversed lexicographical term order.
source code
 
greater_tuple_Dp(self, f, g)
Returns the greater exponent tuple with respect to the total degree lexicographical term order.
source code
 
greater_tuple_dp(self, f, g)
Returns the greater exponent tuple with respect to the total degree reversed lexicographical term order.
source code
 
greater_tuple_ds(self, f, g)
Returns the greater exponent tuple with respect to the negative degree reverse lexicographical term order.
source code
 
greater_tuple_Ds(self, f, g)
Returns the greater exponent tuple with respect to the negative degree lexicographical term order.
source code
 
greater_tuple_ls(self, f, g)
Returns the greater exponent tuple with respect to the negative lexicographical term order.
source code
 
greater_tuple_block(self, f, g)
Compares two exponent tuple with respec to the block ordering as specified when constructing this element.
source code
 
name(self)
EXAMPLE:...
source code
 
_repr_(self)
EXAMPLE:...
source code
 
singular_str(self)
Return a SINGULAR representation of self.
source code
 
macaulay2_str(self)
Return a Macaulay2 representation of self.
source code
 
magma_str(self)
Return a MAGMA representation of self.
source code
 
__cmp__(self, other)
Only equality testing makes sense here.
source code
 
__add__(self, other)
Block ordering constructor.
source code
 
__len__(self)
Return the length of this term ordering, i.e.
source code
 
__getitem__(self, i)
Return the i-th block of this term ordering.
source code
 
__iter__(self)
Iterate over the blocks of this term ordering.
source code
 
is_global(self)
Return \code{True} if this term ordering is definitely global.
source code
 
is_local(self)
Return \code{True} if this term ordering is definitely local.
source code

Inherited from structure.sage_object.SageObject: __hash__, __new__, __repr__, _axiom_, _axiom_init_, _gap_, _gap_init_, _gp_, _gp_init_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _kash_init_, _macaulay2_, _macaulay2_init_, _magma_, _magma_init_, _maple_, _maple_init_, _mathematica_, _mathematica_init_, _maxima_, _maxima_init_, _octave_, _octave_init_, _pari_, _pari_init_, _r_init_, _sage_, _singular_, _singular_init_, category, db, dump, dumps, plot, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __reduce__, __reduce_ex__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='lex', n=0, blocks=True)
(Constructor)

source code 

Construct a new term ordering object.

INPUT:
    name -- name of the term ordering (default: lex)
    n -- number of variables in the polynomial ring (default: 0)
    blocks -- controls whether a list of blocks is maintained
              (internal use only, default:True)

See the \code{sage.rings.polynomial.term_order} module for
help which names and orderings are available.

EXAMPLES:

    sage: t = TermOrder('lex')
    sage: t
    Lexicographic term order
    sage: loads(dumps(t)) == t
    True

We can construct block orderings directly as

    sage: TermOrder('degrevlex(3),neglex(2)')
    degrevlex(3),neglex(2) term order

or by adding together the blocks:

    sage: t1 = TermOrder('degrevlex',3)
    sage: t2 = TermOrder('neglex',2)
    sage: t1 + t2
    degrevlex(3),neglex(2) term order
    sage: t2 + t1
    neglex(2),degrevlex(3) term order

NOTE: The optional $n$ parameter is not necessary if only
non-block orderings like $deglex$ are constructed. However, it
is useful if block orderings are to be constructed from this
\code{TermOrder} object later.

Overrides: object.__init__

__getattr__(self, name)
(Qualification operator)

source code 

Return the correct compare_tuples/greater_tuple function.

EXAMPLE:
    sage: TermOrder('lex').compare_tuples
    <bound method TermOrder.compare_tuples_lp of Lexicographic term order>

    sage: TermOrder('deglex').compare_tuples
    <bound method TermOrder.compare_tuples_Dp of Degree lexicographic term order>

compare_tuples_lp(self, f, g)

source code 

Compares two exponent tuples with respect to the
lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(QQ,2,order='lex')
    sage: x > y^2 # indirect doctest
    True
    sage: x > 1
    True

compare_tuples_rp(self, f, g)

source code 

Compares two exponent tuples with respect to the inversed
lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(ZZ,2,order='invlex')
    sage: x > y^2 # indirect doctest
    False
    sage: x > 1
    True

compare_tuples_Dp(self, f, g)

source code 

Compares two exponent tuples with respect to the
degree lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(GF(127),2,order='deglex')
    sage: x > y^2 # indirect doctest
    False
    sage: x > 1
    True

compare_tuples_dp(self, f, g)

source code 

Compares two exponent tuples with respect to the degree
reversed lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(GF(127),2,order='degrevlex')
    sage: x > y^2 # indirect doctest
    False
    sage: x > 1
    True

compare_tuples_ls(self, f, g)

source code 

Compares two exponent tuples with respect to the
negative lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(GF(2^8,'a'),2,order='neglex')
    sage: x > y^2 # indirect doctest
    False
    sage: x > 1
    False

compare_tuples_ds(self, f, g)

source code 

Compares two exponent tuples with respect to the
negative degree reverse lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(IntegerModRing(10), 2,order='negdegrevlex')
    sage: x > y^2 # indirect doctest
    True
    sage: x > 1
    False

compare_tuples_Ds(self, f, g)

source code 

Compares two exponent tuples with respect to the
negative degree lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y> = PolynomialRing(GF(2), 2,order='negdeglex')
    sage: x > y^2 # indirect doctest
    True
    sage: x > 1
    False

compare_tuples_block(self, f, g)

source code 

Compares two exponent tuple with respec to the block ordering
as specified when constructing this element.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<a,b,c,d,e,f>=PolynomialRing(ZZ,6, order='degrevlex(3),degrevlex(3)')
    sage: a > c^4 # indirect doctest
    False
    sage: a > e^4
    True

greater_tuple_lp(self, f, g)

source code 

Returns the greater exponent tuple with respect to the
lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLES:
    sage: P.<x,y,z> = PolynomialRing(ZZ,3,order='lex')
    sage: f = x + y^2; f.lm() # indirect doctest
    x

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_rp(self, f, g)

source code 

Returns the greater exponent tuple with respect to the
inversed lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(ZZ,3,order='invlex')
    sage: f = x + y; f.lm() # indirect doctest
    y
    sage: f = y + x^2; f.lm()
    y

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_Dp(self, f, g)

source code 

Returns the greater exponent tuple with respect to the total
degree lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(ZZ, 3, order='deglex')
    sage: f = x + y; f.lm() # indirect doctest
    x
    sage: f = x + y^2*z; f.lm()
    y^2*z

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_dp(self, f, g)

source code 

Returns the greater exponent tuple with respect to the total
degree reversed lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLES:
    sage: P.<x,y,z> = PolynomialRing(ZZ, 3, order='degrevlex')
    sage: f = x + y; f.lm() # indirect doctest
    x
    sage: f = x + y^2*z; f.lm()
    y^2*z

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_ds(self, f, g)

source code 

Returns the greater exponent tuple with respect to the
negative degree reverse lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(ZZ,3,order='negdegrevlex')
    sage: f = x + y; f.lm() # indirect doctest
    y
    sage: f = x + x^2; f.lm()
    x
    sage: f = x^2*y*z^2 + x*y^3*z; f.lm()
    x^2*y*z^2

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_Ds(self, f, g)

source code 

Returns the greater exponent tuple with respect to the
negative degree lexicographical term order.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<x,y,z> = PolynomialRing(ZZ,3,order='negdeglex')
    sage: f = x + y; f.lm() # indirect doctest
    y
    sage: f = x + x^2; f.lm()
    x
    sage: f = x^2*y*z^2 + x*y^3*z; f.lm()
    x*y^3*z

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

greater_tuple_ls(self, f, g)

source code 

Returns the greater exponent tuple with respect to the
negative lexicographical term order.

This method is called by the lm/lc/lt methods of
\code{MPolynomial_polydict}.

INPUT:
    f -- exponent tuple
    g -- exponent tuple


EXAMPLE:
    sage: P.<a,b,c,d,e,f>=PolynomialRing(ZZ,6, order='degrevlex(3),degrevlex(3)')
    sage: f = a + c^4; f.lm() # indirect doctest
    c^4
    sage: g = a + e^4; g.lm()
    a

greater_tuple_block(self, f, g)

source code 

Compares two exponent tuple with respec to the block ordering
as specified when constructing this element.

This method is called by the lm/lc/lt methods of \code{MPolynomial_polydict}.

INPUT:
    f -- exponent tuple
    g -- exponent tuple

EXAMPLE:
    sage: P.<a,b,c,d,e,f>=PolynomialRing(ZZ,6, order='degrevlex(3),degrevlex(3)')
    sage: f = a + c^4; f.lm() # indirect doctest
    c^4
    sage: g = a + e^4; g.lm()
    a

name(self)

source code 

EXAMPLE:
    sage: TermOrder('lex').name()
    'lex'

_repr_(self)

source code 

EXAMPLE:
    sage: TermOrder('lex') # indirect doctest
    Lexicographic term order

singular_str(self)

source code 

Return a SINGULAR representation of self.

Used to convert polynomial rings to their SINGULAR
representation.

EXAMPLE:
    sage: P = PolynomialRing(GF(127),10,names='x',order='lex(3),deglex(5),lex(2)')
    sage: T = P.term_order()
    sage: T.singular_str()
    '(lp(3),Dp(5),lp(2))'
    sage: P._singular_()
    //   characteristic : 127
    //   number of vars : 10
    //        block   1 : ordering lp
    //                  : names    x0 x1 x2
    //        block   2 : ordering Dp
    //                  : names    x3 x4 x5 x6 x7
    //        block   3 : ordering lp
    //                  : names    x8 x9
    //        block   4 : ordering C

macaulay2_str(self)

source code 

Return a Macaulay2 representation of self.

Used to convert polynomial rings to their Macaulay2
representation.

EXAMPLE:
    sage: P = PolynomialRing(GF(127),8,names='x',order='degrevlex(3),lex(5)')
    sage: T = P.term_order()
    sage: T.macaulay2_str()
    '(GRevLex => 3,Lex => 5)'
    sage: P._macaulay2_() # optional -- requires macaulay2
    ZZ/127 [x0, x1, x2, x3, x4, x5, x6, x7, MonomialOrder => {GRevLex => 3, Lex => 5}, MonomialSize => 16]

magma_str(self)

source code 

Return a MAGMA representation of self.

Used to convert polynomial rings to their MAGMA
representation.

EXAMPLE:
    sage: P = PolynomialRing(GF(127),10,names='x',order='degrevlex')
    sage: P._magma_() # optional, requires MAGMA
    Polynomial ring of rank 10 over GF(127)
    Graded Reverse Lexicographical Order
    Variables: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9

    sage: T = P.term_order()
    sage: T.magma_str()
    '"grevlex"'

__cmp__(self, other)
(Comparison operator)

source code 

Only equality testing makes sense here.

EXAMPLE:
    sage: TermOrder('lex') == TermOrder('lex',3)
    True

    sage: TermOrder('degrevlex') == TermOrder('lex')
    False

    sage: T1 = TermOrder('lex',2)+TermOrder('lex',3)
    sage: T2 = TermOrder('lex',3)+TermOrder('lex',2)
    sage: T1 == T2
    False

    sage: T1 = TermOrder('lex',2)+TermOrder('neglex',3)
    sage: T2 = TermOrder('lex',2)+TermOrder('neglex',3)
    sage: T1 == T2
    True

__add__(self, other)
(Addition operator)

source code 

Block ordering constructor.

INPUT:
    other -- a term order

OUTPUT:
    a block ordering

EXAMPLE:
    sage: from sage.rings.polynomial.term_order import TermOrder
    sage: TermOrder('deglex',2) + TermOrder('degrevlex(3),neglex(3)')
    deglex(2),degrevlex(3),neglex(3) term order

__len__(self)
(Length operator)

source code 

Return the length of this term ordering, i.e. the number of
variables it covers. This may be zero for undefinitely many
variables.

EXAMPLE:
    sage: T = TermOrder('lex')
    sage: len(T)
    0
    sage: T = TermOrder('lex', 2) + TermOrder('degrevlex', 3)
    sage: len(T)
    5

__getitem__(self, i)
(Indexing operator)

source code 

Return the i-th block of this term ordering.

INPUT:
    i -- index

EXAMPLE:
    sage: T = TermOrder('lex')
    sage: T[0]
    Lexicographic term order

    sage: T = TermOrder('lex', 2) + TermOrder('degrevlex', 3)
    sage: T[1]
    Degree reverse lexicographic term order

Note that \code{len(self)} does not count blocks but variables.

    sage: T = TermOrder('lex', 2) + TermOrder('degrevlex', 3)
    sage: T[len(T)-1]
    Traceback (most recent call last):
    ...
    IndexError: tuple index out of range

__iter__(self)

source code 

Iterate over the blocks of this term ordering.

EXAMPLE:
    sage: T = TermOrder('lex')
    sage: list(T) # indirect doctest
    [Lexicographic term order]

    sage: T = TermOrder('lex', 2) + TermOrder('degrevlex', 3)
    sage: list(T)
    [Lexicographic term order, Degree reverse lexicographic term order]

Note that \code{len(self)} and \code{len(list(self))} are not
the same. The former counts the number of variables in
\code{self} while the latter counts the number of blocks.

is_global(self)

source code 

Return \code{True} if this term ordering is definitely
global. Return \code{False} otherwise, which includes unknown
term orderings.

EXAMPLE:
    sage: T = TermOrder('lex')
    sage: T.is_global()
    True
    sage: T = TermOrder('degrevlex', 3) + TermOrder('degrevlex', 3)
    sage: T.is_global()
    True
    sage: T = TermOrder('degrevlex', 3) + TermOrder('negdegrevlex', 3)
    sage: T.is_global()
    False

is_local(self)

source code 

Return \code{True} if this term ordering is definitely
local. Return \code{False} otherwise, which includes unknown
term orderings.

EXAMPLE:
    sage: T = TermOrder('lex')
    sage: T.is_local()
    False
    sage: T = TermOrder('negdeglex', 3) + TermOrder('negdegrevlex', 3)
    sage: T.is_local()
    True
    sage: T = TermOrder('degrevlex', 3) + TermOrder('negdegrevlex', 3)
    sage: T.is_local()
    False