Module: sage.monoids.free_abelian_monoid_element
Abelian monoid elements
Author: - David Kohel (2005-09)
Recall the example from abelian monoids.
sage: F = FreeAbelianMonoid(5,names = list("abcde"))
sage: (a,b,c,d,e) = F.gens()
sage: a*b^2*e*d
a*b^2*d*e
sage: x = b^2*e*d*a^7
sage: x
a^7*b^2*d*e
sage: x.list()
[7, 2, 0, 1, 1]
It is important to note that lists are mutable and the returned list is not a copy. As a result, reassignment of an element of the list changes the object.
sage: x.list()[0] = 0 sage: x b^2*d*e
Module-level Functions
| x) |
Class: FreeAbelianMonoidElement
| self, F, x) |
Create the element x of the FreeAbelianMonoid F.
sage: F = FreeAbelianMonoid(5, 'abcde') sage: F Free abelian monoid on 5 generators (a, b, c, d, e) sage: F(1) 1 sage: a, b, c, d, e = F.gens() sage: a^2 * b^3 * a^2 * b^4 a^4*b^7 sage: F = FreeAbelianMonoid(5, 'abcde') sage: a, b, c, d, e = F.gens() sage: a in F True sage: a*b in F True
Functions: list
| self) |
Return (a reference to) the underlying list used to represent
this element. If this is a monoid in an abelian monoid on
generators, then this is a list of nonnegative integers of
length
.
sage: F = FreeAbelianMonoid(5, 'abcde') sage: (a, b, c, d, e) = F.gens() sage: a.list() [1, 0, 0, 0, 0]
Special Functions: __init__,
__mul__,
__pow__,
__repr__
| self, n) |
Raises self to the power of n.
Author: - Tom Boothby (2007-08) Replaced O(log n) time, O(n) space algorithm with O(1) time and space "algorithm".
sage: F = FreeAbelianMonoid(5,names = list("abcde"))
sage: (a,b,c,d,e) = F.gens()
sage: x = a*b^2*e*d; x
a*b^2*d*e
sage: x^3
a^3*b^6*d^3*e^3
sage: x^0
1
See About this document... for information on suggesting changes.