Modules With Basis¶
AUTHORS:
Nicolas M. Thiery (2008-2014): initial revision, axiomatization
Jason Bandlow and Florent Hivert (2010): Triangular Morphisms
Christian Stump (2010): Issue #9648 module_morphism’s to a wider class of codomains
- class sage.categories.modules_with_basis.ModulesWithBasis(base_category)[source]¶
Bases:
CategoryWithAxiom_over_base_ring
The category of modules with a distinguished basis.
The elements are represented by expanding them in the distinguished basis. The morphisms are not required to respect the distinguished basis.
EXAMPLES:
sage: ModulesWithBasis(ZZ) Category of modules with basis over Integer Ring sage: ModulesWithBasis(ZZ).super_categories() [Category of modules over Integer Ring]
>>> from sage.all import * >>> ModulesWithBasis(ZZ) Category of modules with basis over Integer Ring >>> ModulesWithBasis(ZZ).super_categories() [Category of modules over Integer Ring]
ModulesWithBasis(ZZ) ModulesWithBasis(ZZ).super_categories()
If the base ring is actually a field, this constructs instead the category of vector spaces with basis:
sage: ModulesWithBasis(QQ) Category of vector spaces with basis over Rational Field sage: ModulesWithBasis(QQ).super_categories() [Category of modules with basis over Rational Field, Category of vector spaces over Rational Field]
>>> from sage.all import * >>> ModulesWithBasis(QQ) Category of vector spaces with basis over Rational Field >>> ModulesWithBasis(QQ).super_categories() [Category of modules with basis over Rational Field, Category of vector spaces over Rational Field]
ModulesWithBasis(QQ) ModulesWithBasis(QQ).super_categories()
Let \(X\) and \(Y\) be two modules with basis. We can build \(Hom(X,Y)\):
sage: X = CombinatorialFreeModule(QQ, [1,2]); X.rename('X') # needs sage.modules sage: Y = CombinatorialFreeModule(QQ, [3,4]); Y.rename('Y') # needs sage.modules sage: H = Hom(X, Y); H # needs sage.modules Set of Morphisms from X to Y in Category of finite dimensional vector spaces with basis over Rational Field
>>> from sage.all import * >>> X = CombinatorialFreeModule(QQ, [Integer(1),Integer(2)]); X.rename('X') # needs sage.modules >>> Y = CombinatorialFreeModule(QQ, [Integer(3),Integer(4)]); Y.rename('Y') # needs sage.modules >>> H = Hom(X, Y); H # needs sage.modules Set of Morphisms from X to Y in Category of finite dimensional vector spaces with basis over Rational Field
X = CombinatorialFreeModule(QQ, [1,2]); X.rename('X') # needs sage.modules Y = CombinatorialFreeModule(QQ, [3,4]); Y.rename('Y') # needs sage.modules H = Hom(X, Y); H # needs sage.modules
The simplest morphism is the zero map:
sage: H.zero() # todo: move this test into module once we have an example # needs sage.modules Generic morphism: From: X To: Y
>>> from sage.all import * >>> H.zero() # todo: move this test into module once we have an example # needs sage.modules Generic morphism: From: X To: Y
H.zero() # todo: move this test into module once we have an example # needs sage.modules
which we can apply to elements of \(X\):
sage: x = X.monomial(1) + 3 * X.monomial(2) # needs sage.modules sage: H.zero()(x) # needs sage.modules 0
>>> from sage.all import * >>> x = X.monomial(Integer(1)) + Integer(3) * X.monomial(Integer(2)) # needs sage.modules >>> H.zero()(x) # needs sage.modules 0
x = X.monomial(1) + 3 * X.monomial(2) # needs sage.modules H.zero()(x) # needs sage.modules
EXAMPLES:
We now construct a more interesting morphism by extending a function by linearity:
sage: phi = H(on_basis=lambda i: Y.monomial(i + 2)); phi # needs sage.modules Generic morphism: From: X To: Y sage: phi(x) # needs sage.modules B[3] + 3*B[4]
>>> from sage.all import * >>> phi = H(on_basis=lambda i: Y.monomial(i + Integer(2))); phi # needs sage.modules Generic morphism: From: X To: Y >>> phi(x) # needs sage.modules B[3] + 3*B[4]
phi = H(on_basis=lambda i: Y.monomial(i + 2)); phi # needs sage.modules phi(x) # needs sage.modules
We can retrieve the function acting on indices of the basis:
sage: f = phi.on_basis() # needs sage.modules sage: f(1), f(2) # needs sage.modules (B[3], B[4])
>>> from sage.all import * >>> f = phi.on_basis() # needs sage.modules >>> f(Integer(1)), f(Integer(2)) # needs sage.modules (B[3], B[4])
f = phi.on_basis() # needs sage.modules f(1), f(2) # needs sage.modules
\(Hom(X,Y)\) has a natural module structure (except for the zero, the operations are not yet implemented though). However since the dimension is not necessarily finite, it is not a module with basis; but see
FiniteDimensionalModulesWithBasis
andGradedModulesWithBasis
:sage: H in ModulesWithBasis(QQ), H in Modules(QQ) # needs sage.modules (False, True)
>>> from sage.all import * >>> H in ModulesWithBasis(QQ), H in Modules(QQ) # needs sage.modules (False, True)
H in ModulesWithBasis(QQ), H in Modules(QQ) # needs sage.modules
Some more playing around with categories and higher order homsets:
sage: H.category() # needs sage.modules Category of homsets of finite dimensional modules with basis over Rational Field sage: Hom(H, H).category() # needs sage.modules Category of endsets of homsets of finite dimensional modules with basis over Rational Field
>>> from sage.all import * >>> H.category() # needs sage.modules Category of homsets of finite dimensional modules with basis over Rational Field >>> Hom(H, H).category() # needs sage.modules Category of endsets of homsets of finite dimensional modules with basis over Rational Field
H.category() # needs sage.modules Hom(H, H).category() # needs sage.modules
Todo
End(X)
is an algebra.Note
This category currently requires an implementation of an element method
support
. Once Issue #18066 is merged, an implementation of anitems
method will be required.- class CartesianProducts(category, *args)[source]¶
Bases:
CartesianProductsCategory
The category of modules with basis constructed by Cartesian products of modules with basis.
- extra_super_categories()[source]¶
EXAMPLES:
sage: ModulesWithBasis(QQ).CartesianProducts().extra_super_categories() [Category of vector spaces with basis over Rational Field] sage: ModulesWithBasis(QQ).CartesianProducts().super_categories() [Category of Cartesian products of modules with basis over Rational Field, Category of vector spaces with basis over Rational Field, Category of Cartesian products of vector spaces over Rational Field]
>>> from sage.all import * >>> ModulesWithBasis(QQ).CartesianProducts().extra_super_categories() [Category of vector spaces with basis over Rational Field] >>> ModulesWithBasis(QQ).CartesianProducts().super_categories() [Category of Cartesian products of modules with basis over Rational Field, Category of vector spaces with basis over Rational Field, Category of Cartesian products of vector spaces over Rational Field]
ModulesWithBasis(QQ).CartesianProducts().extra_super_categories() ModulesWithBasis(QQ).CartesianProducts().super_categories()
- class DualObjects(category, *args)[source]¶
Bases:
DualObjectsCategory
- extra_super_categories()[source]¶
EXAMPLES:
sage: ModulesWithBasis(ZZ).DualObjects().extra_super_categories() [Category of modules over Integer Ring] sage: ModulesWithBasis(QQ).DualObjects().super_categories() [Category of duals of vector spaces over Rational Field, Category of duals of modules with basis over Rational Field]
>>> from sage.all import * >>> ModulesWithBasis(ZZ).DualObjects().extra_super_categories() [Category of modules over Integer Ring] >>> ModulesWithBasis(QQ).DualObjects().super_categories() [Category of duals of vector spaces over Rational Field, Category of duals of modules with basis over Rational Field]
ModulesWithBasis(ZZ).DualObjects().extra_super_categories() ModulesWithBasis(QQ).DualObjects().super_categories()
- class ElementMethods[source]¶
Bases:
object
- coefficient(m)[source]¶
Return the coefficient of
m
inself
and raise an error ifm
is not in the basis indexing set.INPUT:
m
– a basis index of the parent ofself
OUTPUT:
The
B[m]
-coordinate ofself
with respect to the basisB
. Here,B
denotes the given basis of the parent ofself
.EXAMPLES:
sage: # needs sage.combinat sage.modules sage: s = CombinatorialFreeModule(QQ, Partitions()) sage: z = s([4]) - 2*s([2,1]) + s([1,1,1]) + s([1]) sage: z.coefficient([4]) 1 sage: z.coefficient([2,1]) -2 sage: z.coefficient(Partition([2,1])) -2 sage: z.coefficient([1,2]) Traceback (most recent call last): ... AssertionError: [1, 2] should be an element of Partitions sage: z.coefficient(Composition([2,1])) Traceback (most recent call last): ... AssertionError: [2, 1] should be an element of Partitions
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> s = CombinatorialFreeModule(QQ, Partitions()) >>> z = s([Integer(4)]) - Integer(2)*s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) >>> z.coefficient([Integer(4)]) 1 >>> z.coefficient([Integer(2),Integer(1)]) -2 >>> z.coefficient(Partition([Integer(2),Integer(1)])) -2 >>> z.coefficient([Integer(1),Integer(2)]) Traceback (most recent call last): ... AssertionError: [1, 2] should be an element of Partitions >>> z.coefficient(Composition([Integer(2),Integer(1)])) Traceback (most recent call last): ... AssertionError: [2, 1] should be an element of Partitions
# needs sage.combinat sage.modules s = CombinatorialFreeModule(QQ, Partitions()) z = s([4]) - 2*s([2,1]) + s([1,1,1]) + s([1]) z.coefficient([4]) z.coefficient([2,1]) z.coefficient(Partition([2,1])) z.coefficient([1,2]) z.coefficient(Composition([2,1]))
Test that
coefficient
also works for those parents that do not have anelement_class
:sage: # needs sage.modules sage.rings.padics sage: H = pAdicWeightSpace(3) sage: F = CombinatorialFreeModule(QQ, H) sage: hasattr(H, "element_class") False sage: h = H.an_element() sage: (2*F.monomial(h)).coefficient(h) 2
>>> from sage.all import * >>> # needs sage.modules sage.rings.padics >>> H = pAdicWeightSpace(Integer(3)) >>> F = CombinatorialFreeModule(QQ, H) >>> hasattr(H, "element_class") False >>> h = H.an_element() >>> (Integer(2)*F.monomial(h)).coefficient(h) 2
# needs sage.modules sage.rings.padics H = pAdicWeightSpace(3) F = CombinatorialFreeModule(QQ, H) hasattr(H, "element_class") h = H.an_element() (2*F.monomial(h)).coefficient(h)
- coefficients(sort=True)[source]¶
Return a list of the (nonzero) coefficients appearing on the basis elements in
self
(in an arbitrary order).INPUT:
sort
– boolean (default:True
); to sort the coefficients based upon the default ordering of the indexing set
See also
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] - 3*B['c'] sage: f.coefficients() [1, -3] sage: f = B['c'] - 3*B['a'] sage: f.coefficients() [-3, 1]
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] - Integer(3)*B['c'] >>> f.coefficients() [1, -3] >>> f = B['c'] - Integer(3)*B['a'] >>> f.coefficients() [-3, 1]
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] - 3*B['c'] f.coefficients() f = B['c'] - 3*B['a'] f.coefficients()
sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules sage: z.coefficients() # needs sage.combinat sage.modules [1, 1, 1, 1]
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> z.coefficients() # needs sage.combinat sage.modules [1, 1, 1, 1]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules z.coefficients() # needs sage.combinat sage.modules
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> z.coefficients() # needs sage.combinat sage.modules [1, 1, 1, 1]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules z.coefficients() # needs sage.combinat sage.modules
- is_zero()[source]¶
Return
True
if and only ifself == 0
.EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] - 3*B['c'] sage: f.is_zero() False sage: F.zero().is_zero() True
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] - Integer(3)*B['c'] >>> f.is_zero() False >>> F.zero().is_zero() True
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] - 3*B['c'] f.is_zero() F.zero().is_zero()
sage: # needs sage.combinat sage.modules sage: s = SymmetricFunctions(QQ).schur() sage: s([2,1]).is_zero() False sage: s(0).is_zero() True sage: (s([2,1]) - s([2,1])).is_zero() True
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> s = SymmetricFunctions(QQ).schur() >>> s([Integer(2),Integer(1)]).is_zero() False >>> s(Integer(0)).is_zero() True >>> (s([Integer(2),Integer(1)]) - s([Integer(2),Integer(1)])).is_zero() True
# needs sage.combinat sage.modules s = SymmetricFunctions(QQ).schur() s([2,1]).is_zero() s(0).is_zero() (s([2,1]) - s([2,1])).is_zero()
>>> from sage.all import * >>> # needs sage.combinat sage.modules >>> s = SymmetricFunctions(QQ).schur() >>> s([Integer(2),Integer(1)]).is_zero() False >>> s(Integer(0)).is_zero() True >>> (s([Integer(2),Integer(1)]) - s([Integer(2),Integer(1)])).is_zero() True
# needs sage.combinat sage.modules s = SymmetricFunctions(QQ).schur() s([2,1]).is_zero() s(0).is_zero() (s([2,1]) - s([2,1])).is_zero()
- leading_coefficient(*args, **kwds)[source]¶
Return the leading coefficient of
self
.This is the coefficient of the term whose corresponding basis element is maximal. Note that this may not be the term which actually appears first when
self
is printed.If the default term ordering is not what is desired, a comparison key,
key(x,y)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.leading_coefficient() 1 sage: def key(x): return -x sage: x.leading_coefficient(key=key) 3 sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.leading_coefficient() # needs sage.combinat sage.modules -5
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.leading_coefficient() 1 >>> def key(x): return -x >>> x.leading_coefficient(key=key) 3 >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.leading_coefficient() # needs sage.combinat sage.modules -5
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.leading_coefficient() def key(x): return -x x.leading_coefficient(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.leading_coefficient() # needs sage.combinat sage.modules
- leading_item(*args, **kwds)[source]¶
Return the pair
(k, c)
where\[c \cdot (\mbox{the basis element indexed by } k)\]is the leading term of
self
.Here ‘leading term’ means that the corresponding basis element is maximal. Note that this may not be the term which actually appears first when
self
is printed.If the default term ordering is not what is desired, a comparison function,
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) sage: x.leading_item() (3, 4) sage: def key(x): return -x sage: x.leading_item(key=key) (1, 3) sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.leading_item() # needs sage.combinat sage.modules ([3], -5)
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + Integer(4)*X.monomial(Integer(3)) >>> x.leading_item() (3, 4) >>> def key(x): return -x >>> x.leading_item(key=key) (1, 3) >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.leading_item() # needs sage.combinat sage.modules ([3], -5)
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) x.leading_item() def key(x): return -x x.leading_item(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.leading_item() # needs sage.combinat sage.modules
- leading_monomial(*args, **kwds)[source]¶
Return the leading monomial of
self
.This is the monomial whose corresponding basis element is maximal. Note that this may not be the term which actually appears first when
self
is printed.If the default term ordering is not what is desired, a comparison key,
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.leading_monomial() B[3] sage: def key(x): return -x sage: x.leading_monomial(key=key) B[1] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.leading_monomial() # needs sage.combinat sage.modules s[3]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.leading_monomial() B[3] >>> def key(x): return -x >>> x.leading_monomial(key=key) B[1] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.leading_monomial() # needs sage.combinat sage.modules s[3]
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.leading_monomial() def key(x): return -x x.leading_monomial(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.leading_monomial() # needs sage.combinat sage.modules
- leading_support(*args, **kwds)[source]¶
Return the maximal element of the support of
self
.Note that this may not be the term which actually appears first when
self
is printed.If the default ordering of the basis elements is not what is desired, a comparison key,
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]) sage: X.rename('X'); x = X.basis() sage: x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) sage: x.leading_support() 3 sage: def key(x): return -x sage: x.leading_support(key=key) 1 sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.leading_support() # needs sage.combinat sage.modules [3]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]) >>> X.rename('X'); x = X.basis() >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + Integer(4)*X.monomial(Integer(3)) >>> x.leading_support() 3 >>> def key(x): return -x >>> x.leading_support(key=key) 1 >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.leading_support() # needs sage.combinat sage.modules [3]
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]) X.rename('X'); x = X.basis() x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) x.leading_support() def key(x): return -x x.leading_support(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.leading_support() # needs sage.combinat sage.modules
- leading_term(*args, **kwds)[source]¶
Return the leading term of
self
.This is the term whose corresponding basis element is maximal. Note that this may not be the term which actually appears first when
self
is printed.If the default term ordering is not what is desired, a comparison key,
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.leading_term() B[3] sage: def key(x): return -x sage: x.leading_term(key=key) 3*B[1] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.leading_term() # needs sage.combinat sage.modules -5*s[3]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.leading_term() B[3] >>> def key(x): return -x >>> x.leading_term(key=key) 3*B[1] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.leading_term() # needs sage.combinat sage.modules -5*s[3]
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.leading_term() def key(x): return -x x.leading_term(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.leading_term() # needs sage.combinat sage.modules
- length()[source]¶
Return the number of basis elements whose coefficients in
self
are nonzero.EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] - 3*B['c'] sage: f.length() 2
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] - Integer(3)*B['c'] >>> f.length() 2
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] - 3*B['c'] f.length()
sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules sage: z.length() # needs sage.combinat sage.modules 4
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> z.length() # needs sage.combinat sage.modules 4
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules z.length() # needs sage.combinat sage.modules
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> z.length() # needs sage.combinat sage.modules 4
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules z.length() # needs sage.combinat sage.modules
- map_coefficients(f, new_base_ring=None)[source]¶
Return the element obtained by applying
f
to the nonzero coefficients ofself
.If
f
is asage.categories.map.Map
, then the resulting polynomial will be defined over the codomain off
. Otherwise, the resulting polynomial will be over the same ring asself
. Setnew_base_ring
to override this behaviour.An error is raised if the coefficients cannot be converted to the new base ring.
INPUT:
f
– a callable that will be applied to the coefficients ofself
new_base_ring
– (optional) if given, the resulting element will be defined over this ring
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] - 3*B['c'] sage: f.map_coefficients(lambda x: x + 5) 6*B['a'] + 2*B['c']
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] - Integer(3)*B['c'] >>> f.map_coefficients(lambda x: x + Integer(5)) 6*B['a'] + 2*B['c']
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] - 3*B['c'] f.map_coefficients(lambda x: x + 5)
Killed coefficients are handled properly:
sage: f.map_coefficients(lambda x: 0) # needs sage.modules 0 sage: list(f.map_coefficients(lambda x: 0)) # needs sage.modules []
>>> from sage.all import * >>> f.map_coefficients(lambda x: Integer(0)) # needs sage.modules 0 >>> list(f.map_coefficients(lambda x: Integer(0))) # needs sage.modules []
f.map_coefficients(lambda x: 0) # needs sage.modules list(f.map_coefficients(lambda x: 0)) # needs sage.modules
sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: a = s([2,1]) + 2*s([3,2]) # needs sage.combinat sage.modules sage: a.map_coefficients(lambda x: x * 2) # needs sage.combinat sage.modules 2*s[2, 1] + 4*s[3, 2]
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> a = s([Integer(2),Integer(1)]) + Integer(2)*s([Integer(3),Integer(2)]) # needs sage.combinat sage.modules >>> a.map_coefficients(lambda x: x * Integer(2)) # needs sage.combinat sage.modules 2*s[2, 1] + 4*s[3, 2]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules a = s([2,1]) + 2*s([3,2]) # needs sage.combinat sage.modules a.map_coefficients(lambda x: x * 2) # needs sage.combinat sage.modules
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> a = s([Integer(2),Integer(1)]) + Integer(2)*s([Integer(3),Integer(2)]) # needs sage.combinat sage.modules >>> a.map_coefficients(lambda x: x * Integer(2)) # needs sage.combinat sage.modules 2*s[2, 1] + 4*s[3, 2]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules a = s([2,1]) + 2*s([3,2]) # needs sage.combinat sage.modules a.map_coefficients(lambda x: x * 2) # needs sage.combinat sage.modules
We can map into a different base ring:
sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: a = 1/2*(B['a'] + 3*B['c']); a 1/2*B['a'] + 3/2*B['c'] sage: b = a.map_coefficients(lambda c: 2*c, ZZ); b B['a'] + 3*B['c'] sage: b.parent() Free module generated by {'a', 'b', 'c'} over Integer Ring sage: b.map_coefficients(lambda c: 1/2*c, ZZ) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer
>>> from sage.all import * >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> a = Integer(1)/Integer(2)*(B['a'] + Integer(3)*B['c']); a 1/2*B['a'] + 3/2*B['c'] >>> b = a.map_coefficients(lambda c: Integer(2)*c, ZZ); b B['a'] + 3*B['c'] >>> b.parent() Free module generated by {'a', 'b', 'c'} over Integer Ring >>> b.map_coefficients(lambda c: Integer(1)/Integer(2)*c, ZZ) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer
F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() a = 1/2*(B['a'] + 3*B['c']); a b = a.map_coefficients(lambda c: 2*c, ZZ); b b.parent() b.map_coefficients(lambda c: 1/2*c, ZZ)
Coefficients are converted to the new base ring after applying the map:
sage: B['a'].map_coefficients(lambda c: 2*c, GF(2)) 0 sage: B['a'].map_coefficients(lambda c: GF(2)(c), QQ) B['a']
>>> from sage.all import * >>> B['a'].map_coefficients(lambda c: Integer(2)*c, GF(Integer(2))) 0 >>> B['a'].map_coefficients(lambda c: GF(Integer(2))(c), QQ) B['a']
B['a'].map_coefficients(lambda c: 2*c, GF(2)) B['a'].map_coefficients(lambda c: GF(2)(c), QQ)
- map_item(f)[source]¶
Mapping a function on items.
INPUT:
f
– a function mapping pairs(index, coeff)
to other such pairs
Return a new element of
self.parent()
obtained by applying the function \(f\) to all items(index, coeff)
ofself
.EXAMPLES:
sage: B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules sage: x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] sage: x.map_item(lambda i, c: (-i, 2*c)) # needs sage.modules 6*B[-1] + 4*B[0] + 4*B[1]
>>> from sage.all import * >>> B = CombinatorialFreeModule(ZZ, [-Integer(1), Integer(0), Integer(1)]) # needs sage.modules >>> x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] >>> x.map_item(lambda i, c: (-i, Integer(2)*c)) # needs sage.modules 6*B[-1] + 4*B[0] + 4*B[1]
B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules x = B.an_element(); x # needs sage.modules x.map_item(lambda i, c: (-i, 2*c)) # needs sage.modules
f
needs not be injective:sage: x.map_item(lambda i, c: (1, 2*c)) # needs sage.modules 14*B[1] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = lambda m, c: (m.conjugate(), 2 * c) sage: a = s([2,1]) + s([1,1,1]) # needs sage.combinat sage.modules sage: a.map_item(f) # needs sage.combinat sage.modules 2*s[2, 1] + 2*s[3]
>>> from sage.all import * >>> x.map_item(lambda i, c: (Integer(1), Integer(2)*c)) # needs sage.modules 14*B[1] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = lambda m, c: (m.conjugate(), Integer(2) * c) >>> a = s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) # needs sage.combinat sage.modules >>> a.map_item(f) # needs sage.combinat sage.modules 2*s[2, 1] + 2*s[3]
x.map_item(lambda i, c: (1, 2*c)) # needs sage.modules s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = lambda m, c: (m.conjugate(), 2 * c) a = s([2,1]) + s([1,1,1]) # needs sage.combinat sage.modules a.map_item(f) # needs sage.combinat sage.modules
- map_support(f)[source]¶
Mapping a function on the support.
INPUT:
f
– an endofunction on the indices of the free module
Return a new element of
self.parent()
obtained by applying the functionf
to all of the objects indexing the basis elements.EXAMPLES:
sage: B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules sage: x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] sage: x.map_support(lambda i: -i) # needs sage.modules 3*B[-1] + 2*B[0] + 2*B[1]
>>> from sage.all import * >>> B = CombinatorialFreeModule(ZZ, [-Integer(1), Integer(0), Integer(1)]) # needs sage.modules >>> x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] >>> x.map_support(lambda i: -i) # needs sage.modules 3*B[-1] + 2*B[0] + 2*B[1]
B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules x = B.an_element(); x # needs sage.modules x.map_support(lambda i: -i) # needs sage.modules
f
needs not be injective:sage: x.map_support(lambda i: 1) # needs sage.modules 7*B[1] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: a = s([2,1]) + 2*s([3,2]) # needs sage.combinat sage.modules sage: a.map_support(lambda x: x.conjugate()) # needs sage.combinat sage.modules s[2, 1] + 2*s[2, 2, 1]
>>> from sage.all import * >>> x.map_support(lambda i: Integer(1)) # needs sage.modules 7*B[1] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> a = s([Integer(2),Integer(1)]) + Integer(2)*s([Integer(3),Integer(2)]) # needs sage.combinat sage.modules >>> a.map_support(lambda x: x.conjugate()) # needs sage.combinat sage.modules s[2, 1] + 2*s[2, 2, 1]
x.map_support(lambda i: 1) # needs sage.modules s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules a = s([2,1]) + 2*s([3,2]) # needs sage.combinat sage.modules a.map_support(lambda x: x.conjugate()) # needs sage.combinat sage.modules
- map_support_skip_none(f)[source]¶
Mapping a function on the support.
INPUT:
f
– an endofunction on the indices of the free module
Returns a new element of
self.parent()
obtained by applying the function \(f\) to all of the objects indexing the basis elements.EXAMPLES:
sage: B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules sage: x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] sage: x.map_support_skip_none(lambda i: -i if i else None) # needs sage.modules 3*B[-1] + 2*B[1]
>>> from sage.all import * >>> B = CombinatorialFreeModule(ZZ, [-Integer(1), Integer(0), Integer(1)]) # needs sage.modules >>> x = B.an_element(); x # needs sage.modules 2*B[-1] + 2*B[0] + 3*B[1] >>> x.map_support_skip_none(lambda i: -i if i else None) # needs sage.modules 3*B[-1] + 2*B[1]
B = CombinatorialFreeModule(ZZ, [-1, 0, 1]) # needs sage.modules x = B.an_element(); x # needs sage.modules x.map_support_skip_none(lambda i: -i if i else None) # needs sage.modules
f
needs not be injective:sage: x.map_support_skip_none(lambda i: 1 if i else None) # needs sage.modules 5*B[1]
>>> from sage.all import * >>> x.map_support_skip_none(lambda i: Integer(1) if i else None) # needs sage.modules 5*B[1]
x.map_support_skip_none(lambda i: 1 if i else None) # needs sage.modules
- monomial_coefficients(copy=True)[source]¶
Return a dictionary whose keys are indices of basis elements in the support of
self
and whose values are the corresponding coefficients.INPUT:
copy
– boolean (default:True
); ifself
is internally represented by a dictionaryd
, then make a copy ofd
; ifFalse
, then this can cause undesired behavior by mutatingd
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] + 3*B['c'] sage: d = f.monomial_coefficients() sage: d['a'] 1 sage: d['c'] 3
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] + Integer(3)*B['c'] >>> d = f.monomial_coefficients() >>> d['a'] 1 >>> d['c'] 3
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] + 3*B['c'] d = f.monomial_coefficients() d['a'] d['c']
- monomials()[source]¶
Return a list of the monomials of
self
(in an arbitrary order).The monomials of an element \(a\) are defined to be the basis elements whose corresponding coefficients of \(a\) are nonzero.
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] + 2*B['c'] sage: f.monomials() [B['a'], B['c']] sage: (F.zero()).monomials() # needs sage.modules []
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] + Integer(2)*B['c'] >>> f.monomials() [B['a'], B['c']] >>> (F.zero()).monomials() # needs sage.modules []
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] + 2*B['c'] f.monomials() (F.zero()).monomials() # needs sage.modules
- support()[source]¶
Return an iterable of the objects indexing the basis of
self.parent()
whose corresponding coefficients ofself
are nonzero.This method returns these objects in an arbitrary order.
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] - 3*B['c'] sage: sorted(f.support()) ['a', 'c']
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] - Integer(3)*B['c'] >>> sorted(f.support()) ['a', 'c']
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] - 3*B['c'] sorted(f.support())
sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules sage: sorted(z.support()) # needs sage.combinat sage.modules [[1], [1, 1, 1], [2, 1], [4]]
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> sorted(z.support()) # needs sage.combinat sage.modules [[1], [1, 1, 1], [2, 1], [4]]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules sorted(z.support()) # needs sage.combinat sage.modules
>>> from sage.all import * >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> z = s([Integer(4)]) + s([Integer(2),Integer(1)]) + s([Integer(1),Integer(1),Integer(1)]) + s([Integer(1)]) # needs sage.combinat sage.modules >>> sorted(z.support()) # needs sage.combinat sage.modules [[1], [1, 1, 1], [2, 1], [4]]
s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) # needs sage.combinat sage.modules sorted(z.support()) # needs sage.combinat sage.modules
- support_of_term()[source]¶
Return the support of
self
, whereself
is a monomial (possibly with coefficient).EXAMPLES:
sage: X = CombinatorialFreeModule(QQ, [1,2,3,4]); X.rename('X') # needs sage.modules sage: X.monomial(2).support_of_term() # needs sage.modules 2 sage: X.term(3, 2).support_of_term() # needs sage.modules 3
>>> from sage.all import * >>> X = CombinatorialFreeModule(QQ, [Integer(1),Integer(2),Integer(3),Integer(4)]); X.rename('X') # needs sage.modules >>> X.monomial(Integer(2)).support_of_term() # needs sage.modules 2 >>> X.term(Integer(3), Integer(2)).support_of_term() # needs sage.modules 3
X = CombinatorialFreeModule(QQ, [1,2,3,4]); X.rename('X') # needs sage.modules X.monomial(2).support_of_term() # needs sage.modules X.term(3, 2).support_of_term() # needs sage.modules
An exception is raised if
self
has more than one term:sage: (X.monomial(2) + X.monomial(3)).support_of_term() # needs sage.modules Traceback (most recent call last): ... ValueError: B[2] + B[3] is not a single term
>>> from sage.all import * >>> (X.monomial(Integer(2)) + X.monomial(Integer(3))).support_of_term() # needs sage.modules Traceback (most recent call last): ... ValueError: B[2] + B[3] is not a single term
(X.monomial(2) + X.monomial(3)).support_of_term() # needs sage.modules
- tensor(*elements)[source]¶
Return the tensor product of its arguments, as an element of the tensor product of the parents of those elements.
EXAMPLES:
sage: C = AlgebrasWithBasis(QQ) sage: A = C.example() # needs sage.combinat sage.modules sage: a, b, c = A.algebra_generators() # needs sage.combinat sage.modules sage: a.tensor(b, c) # needs sage.combinat sage.modules B[word: a] # B[word: b] # B[word: c]
>>> from sage.all import * >>> C = AlgebrasWithBasis(QQ) >>> A = C.example() # needs sage.combinat sage.modules >>> a, b, c = A.algebra_generators() # needs sage.combinat sage.modules >>> a.tensor(b, c) # needs sage.combinat sage.modules B[word: a] # B[word: b] # B[word: c]
C = AlgebrasWithBasis(QQ) A = C.example() # needs sage.combinat sage.modules a, b, c = A.algebra_generators() # needs sage.combinat sage.modules a.tensor(b, c) # needs sage.combinat sage.modules
FIXME: is this a policy that we want to enforce on all parents?
- terms()[source]¶
Return a list of the (nonzero) terms of
self
(in an arbitrary order).See also
EXAMPLES:
sage: # needs sage.modules sage: F = CombinatorialFreeModule(QQ, ['a','b','c']) sage: B = F.basis() sage: f = B['a'] + 2*B['c'] sage: f.terms() [B['a'], 2*B['c']]
>>> from sage.all import * >>> # needs sage.modules >>> F = CombinatorialFreeModule(QQ, ['a','b','c']) >>> B = F.basis() >>> f = B['a'] + Integer(2)*B['c'] >>> f.terms() [B['a'], 2*B['c']]
# needs sage.modules F = CombinatorialFreeModule(QQ, ['a','b','c']) B = F.basis() f = B['a'] + 2*B['c'] f.terms()
- trailing_coefficient(*args, **kwds)[source]¶
Return the trailing coefficient of
self
.This is the coefficient of the monomial whose corresponding basis element is minimal. Note that this may not be the term which actually appears last when
self
is printed.If the default term ordering is not what is desired, a comparison key
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.trailing_coefficient() 3 sage: def key(x): return -x sage: x.trailing_coefficient(key=key) 1 sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.trailing_coefficient() # needs sage.combinat sage.modules 2
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.trailing_coefficient() 3 >>> def key(x): return -x >>> x.trailing_coefficient(key=key) 1 >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.trailing_coefficient() # needs sage.combinat sage.modules 2
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.trailing_coefficient() def key(x): return -x x.trailing_coefficient(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.trailing_coefficient() # needs sage.combinat sage.modules
- trailing_item(*args, **kwds)[source]¶
Return the pair
(c, k)
wherec*self.parent().monomial(k)
is the trailing term ofself
.This is the monomial whose corresponding basis element is minimal. Note that this may not be the term which actually appears last when
self
is printed.If the default term ordering is not what is desired, a comparison key
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.trailing_item() (1, 3) sage: def key(x): return -x sage: x.trailing_item(key=key) (3, 1) sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.trailing_item() # needs sage.combinat sage.modules ([1], 2)
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.trailing_item() (1, 3) >>> def key(x): return -x >>> x.trailing_item(key=key) (3, 1) >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.trailing_item() # needs sage.combinat sage.modules ([1], 2)
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.trailing_item() def key(x): return -x x.trailing_item(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.trailing_item() # needs sage.combinat sage.modules
- trailing_monomial(*args, **kwds)[source]¶
Return the trailing monomial of
self
.This is the monomial whose corresponding basis element is minimal. Note that this may not be the term which actually appears last when
self
is printed.If the default term ordering is not what is desired, a comparison key
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.trailing_monomial() B[1] sage: def key(x): return -x sage: x.trailing_monomial(key=key) B[3] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.trailing_monomial() # needs sage.combinat sage.modules s[1]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.trailing_monomial() B[1] >>> def key(x): return -x >>> x.trailing_monomial(key=key) B[3] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.trailing_monomial() # needs sage.combinat sage.modules s[1]
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.trailing_monomial() def key(x): return -x x.trailing_monomial(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.trailing_monomial() # needs sage.combinat sage.modules
- trailing_support(*args, **kwds)[source]¶
Return the minimal element of the support of
self
. Note that this may not be the term which actually appears last whenself
is printed.If the default ordering of the basis elements is not what is desired, a comparison key,
key(x)
, can be provided.EXAMPLES:
sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') # needs sage.modules sage: x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) # needs sage.modules sage: x.trailing_support() # needs sage.modules 1 sage: def key(x): return -x sage: x.trailing_support(key=key) # needs sage.modules 3 sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.trailing_support() # needs sage.combinat sage.modules [1]
>>> from sage.all import * >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') # needs sage.modules >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + Integer(4)*X.monomial(Integer(3)) # needs sage.modules >>> x.trailing_support() # needs sage.modules 1 >>> def key(x): return -x >>> x.trailing_support(key=key) # needs sage.modules 3 >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.trailing_support() # needs sage.combinat sage.modules [1]
X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') # needs sage.modules x = 3*X.monomial(1) + 2*X.monomial(2) + 4*X.monomial(3) # needs sage.modules x.trailing_support() # needs sage.modules def key(x): return -x x.trailing_support(key=key) # needs sage.modules s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.trailing_support() # needs sage.combinat sage.modules
- trailing_term(*args, **kwds)[source]¶
Return the trailing term of
self
.This is the term whose corresponding basis element is minimal. Note that this may not be the term which actually appears last when
self
is printed.If the default term ordering is not what is desired, a comparison key
key(x)
, can be provided.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) sage: x.trailing_term() 3*B[1] sage: def key(x): return -x sage: x.trailing_term(key=key) B[3] sage: s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules sage: f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules sage: f.trailing_term() # needs sage.combinat sage.modules 2*s[1]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> x = Integer(3)*X.monomial(Integer(1)) + Integer(2)*X.monomial(Integer(2)) + X.monomial(Integer(3)) >>> x.trailing_term() 3*B[1] >>> def key(x): return -x >>> x.trailing_term(key=key) B[3] >>> s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules >>> f = Integer(2)*s[Integer(1)] + Integer(3)*s[Integer(2),Integer(1)] - Integer(5)*s[Integer(3)] # needs sage.combinat sage.modules >>> f.trailing_term() # needs sage.combinat sage.modules 2*s[1]
# needs sage.modules X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename('X') x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3) x.trailing_term() def key(x): return -x x.trailing_term(key=key) s = SymmetricFunctions(QQ).schur() # needs sage.combinat sage.modules f = 2*s[1] + 3*s[2,1] - 5*s[3] # needs sage.combinat sage.modules f.trailing_term() # needs sage.combinat sage.modules
- Filtered[source]¶
alias of
FilteredModulesWithBasis
- FiniteDimensional[source]¶
alias of
FiniteDimensionalModulesWithBasis
- Graded[source]¶
alias of
GradedModulesWithBasis
- class Homsets(category, *args)[source]¶
Bases:
HomsetsCategory
- class MorphismMethods[source]¶
Bases:
object
- on_basis()[source]¶
Return the action of this morphism on basis elements.
OUTPUT:
a function from the indices of the basis of the domain to the codomain
EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename('X') sage: Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename('Y') sage: H = Hom(X, Y) sage: x = X.basis() sage: f = H(lambda x: Y.zero()).on_basis() sage: f(2) 0 sage: f = lambda i: Y.monomial(i) + 2*Y.monomial(i+1) sage: g = H(on_basis=f).on_basis() sage: g(2) B[2] + 2*B[3] sage: g == f True
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1),Integer(2),Integer(3)]); X.rename('X') >>> Y = CombinatorialFreeModule(QQ, [Integer(1),Integer(2),Integer(3),Integer(4)]); Y.rename('Y') >>> H = Hom(X, Y) >>> x = X.basis() >>> f = H(lambda x: Y.zero()).on_basis() >>> f(Integer(2)) 0 >>> f = lambda i: Y.monomial(i) + Integer(2)*Y.monomial(i+Integer(1)) >>> g = H(on_basis=f).on_basis() >>> g(Integer(2)) B[2] + 2*B[3] >>> g == f True
# needs sage.modules X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename('X') Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename('Y') H = Hom(X, Y) x = X.basis() f = H(lambda x: Y.zero()).on_basis() f(2) f = lambda i: Y.monomial(i) + 2*Y.monomial(i+1) g = H(on_basis=f).on_basis() g(2) g == f
- class ParentMethods[source]¶
Bases:
object
- basis()[source]¶
Return the basis of
self
.EXAMPLES:
sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules sage: F.basis() # needs sage.modules Finite family {'a': B['a'], 'b': B['b'], 'c': B['c']}
>>> from sage.all import * >>> F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules >>> F.basis() # needs sage.modules Finite family {'a': B['a'], 'b': B['b'], 'c': B['c']}
F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules F.basis() # needs sage.modules
sage: QS3 = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups sage.modules sage: list(QS3.basis()) # needs sage.combinat sage.groups sage.modules [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
>>> from sage.all import * >>> QS3 = SymmetricGroupAlgebra(QQ, Integer(3)) # needs sage.combinat sage.groups sage.modules >>> list(QS3.basis()) # needs sage.combinat sage.groups sage.modules [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
QS3 = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups sage.modules list(QS3.basis()) # needs sage.combinat sage.groups sage.modules
>>> from sage.all import * >>> QS3 = SymmetricGroupAlgebra(QQ, Integer(3)) # needs sage.combinat sage.groups sage.modules >>> list(QS3.basis()) # needs sage.combinat sage.groups sage.modules [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
QS3 = SymmetricGroupAlgebra(QQ, 3) # needs sage.combinat sage.groups sage.modules list(QS3.basis()) # needs sage.combinat sage.groups sage.modules
- cardinality()[source]¶
Return the cardinality of
self
.EXAMPLES:
sage: # needs sage.groups sage.modules sage: S = SymmetricGroupAlgebra(QQ, 4) sage: S.cardinality() +Infinity sage: S = SymmetricGroupAlgebra(GF(2), 4) sage: S.cardinality() 16777216 sage: S.cardinality().factor() 2^24 sage: # needs sage.modules sage: E.<x,y> = ExteriorAlgebra(QQ) sage: E.cardinality() +Infinity sage: E.<x,y> = ExteriorAlgebra(GF(3)) sage: E.cardinality() 81 sage: s = SymmetricFunctions(GF(2)).s() # needs sage.combinat sage.modules sage: s.cardinality() # needs sage.combinat sage.modules +Infinity sage: M = CombinatorialFreeModule(QQ, []) sage: M.dimension() 0 sage: M.cardinality() 1
>>> from sage.all import * >>> # needs sage.groups sage.modules >>> S = SymmetricGroupAlgebra(QQ, Integer(4)) >>> S.cardinality() +Infinity >>> S = SymmetricGroupAlgebra(GF(Integer(2)), Integer(4)) >>> S.cardinality() 16777216 >>> S.cardinality().factor() 2^24 >>> # needs sage.modules >>> E = ExteriorAlgebra(QQ, names=('x', 'y',)); (x, y,) = E._first_ngens(2) >>> E.cardinality() +Infinity >>> E = ExteriorAlgebra(GF(Integer(3)), names=('x', 'y',)); (x, y,) = E._first_ngens(2) >>> E.cardinality() 81 >>> s = SymmetricFunctions(GF(Integer(2))).s() # needs sage.combinat sage.modules >>> s.cardinality() # needs sage.combinat sage.modules +Infinity >>> M = CombinatorialFreeModule(QQ, []) >>> M.dimension() 0 >>> M.cardinality() 1
# needs sage.groups sage.modules S = SymmetricGroupAlgebra(QQ, 4) S.cardinality() S = SymmetricGroupAlgebra(GF(2), 4) S.cardinality() S.cardinality().factor() # needs sage.modules E.<x,y> = ExteriorAlgebra(QQ) E.cardinality() E.<x,y> = ExteriorAlgebra(GF(3)) E.cardinality() s = SymmetricFunctions(GF(2)).s() # needs sage.combinat sage.modules s.cardinality() # needs sage.combinat sage.modules M = CombinatorialFreeModule(QQ, []) M.dimension() M.cardinality()
- dimension()[source]¶
Return the dimension of
self
.EXAMPLES:
sage: A.<x,y> = algebras.DifferentialWeyl(QQ) # needs sage.modules sage: A.dimension() # needs sage.modules +Infinity
>>> from sage.all import * >>> A = algebras.DifferentialWeyl(QQ, names=('x', 'y',)); (x, y,) = A._first_ngens(2)# needs sage.modules >>> A.dimension() # needs sage.modules +Infinity
A.<x,y> = algebras.DifferentialWeyl(QQ) # needs sage.modules A.dimension() # needs sage.modules
- echelon_form(elements, row_reduced=False, order=None)[source]¶
Return a basis in echelon form of the subspace spanned by a finite set of elements.
INPUT:
elements
– list or finite iterable of elements ofself
row_reduced
– boolean (default:False
); whether to compute the basis for the row reduced echelon formorder
– (optional) either something that can be converted into a tuple or a key function
OUTPUT:
A list of elements of
self
whose expressions as vectors form a matrix in echelon form. Ifbase_ring
is specified, then the calculation is achieved in this base ring.EXAMPLES:
sage: R.<x,y> = QQ[] sage: C = CombinatorialFreeModule(R, ZZ, prefix='z') # needs sage.modules sage: z = C.basis() # needs sage.modules sage: C.echelon_form([z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]]) # needs sage.libs.singular sage.modules [z[0] - z[2], z[1] - z[2]]
>>> from sage.all import * >>> R = QQ['x, y']; (x, y,) = R._first_ngens(2) >>> C = CombinatorialFreeModule(R, ZZ, prefix='z') # needs sage.modules >>> z = C.basis() # needs sage.modules >>> C.echelon_form([z[Integer(0)] - z[Integer(1)], Integer(2)*z[Integer(1)] - Integer(2)*z[Integer(2)], z[Integer(0)] - z[Integer(2)]]) # needs sage.libs.singular sage.modules [z[0] - z[2], z[1] - z[2]]
R.<x,y> = QQ[] C = CombinatorialFreeModule(R, ZZ, prefix='z') # needs sage.modules z = C.basis() # needs sage.modules C.echelon_form([z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]]) # needs sage.libs.singular sage.modules
- intersection(other)[source]¶
Return the intersection of
self
withother
.EXAMPLES:
sage: X = CombinatorialFreeModule(QQ, range(4)); x = X.basis() sage: U = X.submodule([x[0]-x[1], x[1]-x[2], x[2]-x[3]]) sage: F = CombinatorialFreeModule(QQ, ['a','b','c','d']) sage: G = F.submodule([F.basis()['a']]) sage: X.intersection(X) is X True sage: X.intersection(U) is U True sage: X.intersection(F) Traceback (most recent call last): ... TypeError: other must be a submodule sage: X.intersection(G) Traceback (most recent call last): ... ArithmeticError: this module must be the ambient
>>> from sage.all import * >>> X = CombinatorialFreeModule(QQ, range(Integer(4))); x = X.basis() >>> U = X.submodule([x[Integer(0)]-x[Integer(1)], x[Integer(1)]-x[Integer(2)], x[Integer(2)]-x[Integer(3)]]) >>> F = CombinatorialFreeModule(QQ, ['a','b','c','d']) >>> G = F.submodule([F.basis()['a']]) >>> X.intersection(X) is X True >>> X.intersection(U) is U True >>> X.intersection(F) Traceback (most recent call last): ... TypeError: other must be a submodule >>> X.intersection(G) Traceback (most recent call last): ... ArithmeticError: this module must be the ambient
X = CombinatorialFreeModule(QQ, range(4)); x = X.basis() U = X.submodule([x[0]-x[1], x[1]-x[2], x[2]-x[3]]) F = CombinatorialFreeModule(QQ, ['a','b','c','d']) G = F.submodule([F.basis()['a']]) X.intersection(X) is X X.intersection(U) is U X.intersection(F) X.intersection(G)
- is_finite()[source]¶
Return whether
self
is finite.This is true if and only if
self.basis().keys()
andself.base_ring()
are both finite.EXAMPLES:
sage: GroupAlgebra(SymmetricGroup(2), IntegerModRing(10)).is_finite() # needs sage.combinat sage.groups sage.modules True sage: GroupAlgebra(SymmetricGroup(2)).is_finite() # needs sage.combinat sage.groups sage.modules False sage: GroupAlgebra(AbelianGroup(1), IntegerModRing(10)).is_finite() # needs sage.groups sage.modules False
>>> from sage.all import * >>> GroupAlgebra(SymmetricGroup(Integer(2)), IntegerModRing(Integer(10))).is_finite() # needs sage.combinat sage.groups sage.modules True >>> GroupAlgebra(SymmetricGroup(Integer(2))).is_finite() # needs sage.combinat sage.groups sage.modules False >>> GroupAlgebra(AbelianGroup(Integer(1)), IntegerModRing(Integer(10))).is_finite() # needs sage.groups sage.modules False
GroupAlgebra(SymmetricGroup(2), IntegerModRing(10)).is_finite() # needs sage.combinat sage.groups sage.modules GroupAlgebra(SymmetricGroup(2)).is_finite() # needs sage.combinat sage.groups sage.modules GroupAlgebra(AbelianGroup(1), IntegerModRing(10)).is_finite() # needs sage.groups sage.modules
- module_morphism(on_basis=None, matrix=None, function=None, diagonal=None, triangular=None, unitriangular=False, **keywords)[source]¶
Construct a module morphism from
self
tocodomain
.Let
self
be a module \(X\) with a basis indexed by \(I\). This constructs a morphism \(f: X \to Y\) by linearity from a map \(I \to Y\) which is to be its restriction to the basis \((x_i)_{i \in I}\) of \(X\). Some variants are possible too.INPUT:
self
– a parent \(X\) inModulesWithBasis(R)
with basis \(x=(x_i)_{i\in I}\)
Exactly one of the four following options must be specified in order to define the morphism:
on_basis
– a function \(f\) from \(I\) to \(Y\)diagonal
– a function \(d\) from \(I\) to \(R\)function
– a function \(f\) from \(X\) to \(Y\)matrix
– a matrix of size \(\dim Y \times \dim X\) (if the keywordside
is set to'left'
) or \(\dim Y \times \dim X\) (if this keyword is'right'
)
Further options include:
codomain
– the codomain \(Y\) of the morphism (default:f.codomain()
if it’s defined; otherwise it must be specified)category
– a category orNone
(default:None
)zero
– the zero of the codomain (default:codomain.zero()
); can be used (with care) to define affine maps. Only meaningful withon_basis
.position
– nonnegative integer specifying which positional argument is used as the input of the function \(f\) (default: 0); this is currently only used withon_basis
.triangular
– (default:None
)'upper'
or'lower'
orNone
:'upper'
– if theleading_support()
of the image of the basis vector \(x_i\) is \(i\), or'lower'
– if thetrailing_support()
of the image of the basis vector \(x_i\) is \(i\).
unitriangular
– boolean (default:False
); only meaningful for a triangular morphism. As a shorthand, one may useunitriangular="lower"
fortriangular='lower', unitriangular=True
.side
–'left'
or'right'
(default:'left'
); only meaningful for a morphism built from a matrix
EXAMPLES:
With the
on_basis
option, this returns a function \(g\) obtained by extending \(f\) by linearity on theposition
-th positional argument. For example, forposition == 1
and a ternary function \(f\), one has:\[g\left( a,\ \sum_i \lambda_i x_i,\ c \right) = \sum_i \lambda_i f(a, i, c).\]sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename('X') sage: Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename('Y') sage: def f(i): ....: return Y.monomial(i) + 2*Y.monomial(i+1) sage: phi = X.module_morphism(f, codomain=Y) sage: x = X.basis(); y = Y.basis() sage: phi(x[1] + x[3]) B[1] + 2*B[2] + B[3] + 2*B[4] sage: phi Generic morphism: From: X To: Y
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(1),Integer(2),Integer(3)]); X.rename('X') >>> Y = CombinatorialFreeModule(QQ, [Integer(1),Integer(2),Integer(3),Integer(4)]); Y.rename('Y') >>> def f(i): ... return Y.monomial(i) + Integer(2)*Y.monomial(i+Integer(1)) >>> phi = X.module_morphism(f, codomain=Y) >>> x = X.basis(); y = Y.basis() >>> phi(x[Integer(1)] + x[Integer(3)]) B[1] + 2*B[2] + B[3] + 2*B[4] >>> phi Generic morphism: From: X To: Y
# needs sage.modules X = CombinatorialFreeModule(QQ, [1,2,3]); X.rename('X') Y = CombinatorialFreeModule(QQ, [1,2,3,4]); Y.rename('Y') def f(i): return Y.monomial(i) + 2*Y.monomial(i+1) phi = X.module_morphism(f, codomain=Y) x = X.basis(); y = Y.basis() phi(x[1] + x[3]) phi
By default, the category is the first of
Modules(R).WithBasis().FiniteDimensional()
,Modules(R).WithBasis()
,Modules(R)
, andCommutativeAdditiveMonoids()
that contains both the domain and the codomain:sage: phi.category_for() # needs sage.modules Category of finite dimensional vector spaces with basis over Rational Field
>>> from sage.all import * >>> phi.category_for() # needs sage.modules Category of finite dimensional vector spaces with basis over Rational Field
phi.category_for() # needs sage.modules
With the
zero
argument, one can define affine morphisms:sage: def f(i): ....: return Y.monomial(i) + 2*Y.monomial(i+1) sage: phi = X.module_morphism(f, codomain=Y, zero=10*y[1]) # needs sage.modules sage: phi(x[1] + x[3]) # needs sage.modules 11*B[1] + 2*B[2] + B[3] + 2*B[4]
>>> from sage.all import * >>> def f(i): ... return Y.monomial(i) + Integer(2)*Y.monomial(i+Integer(1)) >>> phi = X.module_morphism(f, codomain=Y, zero=Integer(10)*y[Integer(1)]) # needs sage.modules >>> phi(x[Integer(1)] + x[Integer(3)]) # needs sage.modules 11*B[1] + 2*B[2] + B[3] + 2*B[4]
def f(i): return Y.monomial(i) + 2*Y.monomial(i+1) phi = X.module_morphism(f, codomain=Y, zero=10*y[1]) # needs sage.modules phi(x[1] + x[3]) # needs sage.modules
In this special case, the default category is
Sets()
:sage: phi.category_for() # needs sage.modules Category of sets
>>> from sage.all import * >>> phi.category_for() # needs sage.modules Category of sets
phi.category_for() # needs sage.modules
One can construct morphisms with the base ring as codomain:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(ZZ, [1, -1]) sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=ZZ) sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) -1 sage: phi.category_for() Category of commutative additive semigroups sage: phi.category_for() # not implemented Category of modules over Integer Ring
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(ZZ, [Integer(1), -Integer(1)]) >>> phi = X.module_morphism(on_basis=lambda i: i, codomain=ZZ) >>> phi(Integer(2) * X.monomial(Integer(1)) + Integer(3) * X.monomial(-Integer(1))) -1 >>> phi.category_for() Category of commutative additive semigroups >>> phi.category_for() # not implemented Category of modules over Integer Ring
# needs sage.modules X = CombinatorialFreeModule(ZZ, [1, -1]) phi = X.module_morphism(on_basis=lambda i: i, codomain=ZZ) phi(2 * X.monomial(1) + 3 * X.monomial(-1)) phi.category_for() phi.category_for() # not implemented
Or more generally any ring admitting a coercion map from the base ring:
sage: # needs sage.modules sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=RR) sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) -1.00000000000000 sage: phi.category_for() Category of commutative additive semigroups sage: phi.category_for() # not implemented Category of modules over Integer Ring sage: phi = X.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # needs sage.modules sage: phi(2 * X.monomial(1) + 3 * X.monomial(-1)) # needs sage.modules 3 sage: phi = Y.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Ring of integers modulo 4) should be a module over the base ring of the domain(=Y)
>>> from sage.all import * >>> # needs sage.modules >>> phi = X.module_morphism(on_basis=lambda i: i, codomain=RR) >>> phi(Integer(2) * X.monomial(Integer(1)) + Integer(3) * X.monomial(-Integer(1))) -1.00000000000000 >>> phi.category_for() Category of commutative additive semigroups >>> phi.category_for() # not implemented Category of modules over Integer Ring >>> phi = X.module_morphism(on_basis=lambda i: i, codomain=Zmod(Integer(4))) # needs sage.modules >>> phi(Integer(2) * X.monomial(Integer(1)) + Integer(3) * X.monomial(-Integer(1))) # needs sage.modules 3 >>> phi = Y.module_morphism(on_basis=lambda i: i, codomain=Zmod(Integer(4))) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Ring of integers modulo 4) should be a module over the base ring of the domain(=Y)
# needs sage.modules phi = X.module_morphism(on_basis=lambda i: i, codomain=RR) phi(2 * X.monomial(1) + 3 * X.monomial(-1)) phi.category_for() phi.category_for() # not implemented phi = X.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # needs sage.modules phi(2 * X.monomial(1) + 3 * X.monomial(-1)) # needs sage.modules phi = Y.module_morphism(on_basis=lambda i: i, codomain=Zmod(4)) # needs sage.modules
On can also define module morphisms between free modules over different base rings; here we implement the natural map from \(X = \RR^2\) to \(Y = \CC\):
sage: # needs sage.modules sage: X = CombinatorialFreeModule(RR, ['x', 'y']) sage: Y = CombinatorialFreeModule(CC, ['z']) sage: x = X.monomial('x') sage: y = X.monomial('y') sage: z = Y.monomial('z') sage: def on_basis(a): ....: if a == 'x': ....: return CC(1) * z ....: elif a == 'y': ....: return CC(I) * z sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) sage: v = 3 * x + 2 * y; v 3.00000000000000*B['x'] + 2.00000000000000*B['y'] sage: phi(v) # needs sage.symbolic (3.00000000000000+2.00000000000000*I)*B['z'] sage: phi.category_for() Category of commutative additive semigroups sage: phi.category_for() # not implemented Category of vector spaces over Real Field with 53 bits of precision sage: # needs sage.modules sage: Y = CombinatorialFreeModule(CC['q'], ['z']) sage: z = Y.monomial('z') sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) sage: phi(v) # needs sage.symbolic (3.00000000000000+2.00000000000000*I)*B['z']
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(RR, ['x', 'y']) >>> Y = CombinatorialFreeModule(CC, ['z']) >>> x = X.monomial('x') >>> y = X.monomial('y') >>> z = Y.monomial('z') >>> def on_basis(a): ... if a == 'x': ... return CC(Integer(1)) * z ... elif a == 'y': ... return CC(I) * z >>> phi = X.module_morphism(on_basis=on_basis, codomain=Y) >>> v = Integer(3) * x + Integer(2) * y; v 3.00000000000000*B['x'] + 2.00000000000000*B['y'] >>> phi(v) # needs sage.symbolic (3.00000000000000+2.00000000000000*I)*B['z'] >>> phi.category_for() Category of commutative additive semigroups >>> phi.category_for() # not implemented Category of vector spaces over Real Field with 53 bits of precision >>> # needs sage.modules >>> Y = CombinatorialFreeModule(CC['q'], ['z']) >>> z = Y.monomial('z') >>> phi = X.module_morphism(on_basis=on_basis, codomain=Y) >>> phi(v) # needs sage.symbolic (3.00000000000000+2.00000000000000*I)*B['z']
# needs sage.modules X = CombinatorialFreeModule(RR, ['x', 'y']) Y = CombinatorialFreeModule(CC, ['z']) x = X.monomial('x') y = X.monomial('y') z = Y.monomial('z') def on_basis(a): if a == 'x': return CC(1) * z elif a == 'y': return CC(I) * z phi = X.module_morphism(on_basis=on_basis, codomain=Y) v = 3 * x + 2 * y; v phi(v) # needs sage.symbolic phi.category_for() phi.category_for() # not implemented # needs sage.modules Y = CombinatorialFreeModule(CC['q'], ['z']) z = Y.monomial('z') phi = X.module_morphism(on_basis=on_basis, codomain=Y) phi(v) # needs sage.symbolic
Of course, there should be a coercion between the respective base rings of the domain and the codomain for this to be meaningful:
sage: Y = CombinatorialFreeModule(QQ, ['z']) # needs sage.modules sage: phi = X.module_morphism(on_basis=on_basis, codomain=Y) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Free module generated by {'z'} over Rational Field) should be a module over the base ring of the domain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision) sage: Y = CombinatorialFreeModule(RR['q'], ['z']) # needs sage.modules sage: phi = Y.module_morphism(on_basis=on_basis, codomain=X) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision) should be a module over the base ring of the domain(=Free module generated by {'z'} over Univariate Polynomial Ring in q over Real Field with 53 bits of precision)
>>> from sage.all import * >>> Y = CombinatorialFreeModule(QQ, ['z']) # needs sage.modules >>> phi = X.module_morphism(on_basis=on_basis, codomain=Y) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Free module generated by {'z'} over Rational Field) should be a module over the base ring of the domain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision) >>> Y = CombinatorialFreeModule(RR['q'], ['z']) # needs sage.modules >>> phi = Y.module_morphism(on_basis=on_basis, codomain=X) # needs sage.modules Traceback (most recent call last): ... ValueError: codomain(=Free module generated by {'x', 'y'} over Real Field with 53 bits of precision) should be a module over the base ring of the domain(=Free module generated by {'z'} over Univariate Polynomial Ring in q over Real Field with 53 bits of precision)
Y = CombinatorialFreeModule(QQ, ['z']) # needs sage.modules phi = X.module_morphism(on_basis=on_basis, codomain=Y) # needs sage.modules Y = CombinatorialFreeModule(RR['q'], ['z']) # needs sage.modules phi = Y.module_morphism(on_basis=on_basis, codomain=X) # needs sage.modules
With the
diagonal=d
argument, this constructs the module morphism \(g\) such that\[`g(x_i) = d(i) y_i`.\]This assumes that the respective bases \(x\) and \(y\) of \(X\) and \(Y\) have the same index set \(I\):
sage: # needs sage.modules sage: X = CombinatorialFreeModule(ZZ, [1, 2, 3]); X.rename('X') sage: from sage.arith.misc import factorial sage: phi = X.module_morphism(diagonal=factorial, codomain=X) sage: x = X.basis() sage: phi(x[1]), phi(x[2]), phi(x[3]) (B[1], 2*B[2], 6*B[3])
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(ZZ, [Integer(1), Integer(2), Integer(3)]); X.rename('X') >>> from sage.arith.misc import factorial >>> phi = X.module_morphism(diagonal=factorial, codomain=X) >>> x = X.basis() >>> phi(x[Integer(1)]), phi(x[Integer(2)]), phi(x[Integer(3)]) (B[1], 2*B[2], 6*B[3])
# needs sage.modules X = CombinatorialFreeModule(ZZ, [1, 2, 3]); X.rename('X') from sage.arith.misc import factorial phi = X.module_morphism(diagonal=factorial, codomain=X) x = X.basis() phi(x[1]), phi(x[2]), phi(x[3])
See also:
sage.modules.with_basis.morphism.DiagonalModuleMorphism
.With the
matrix=m
argument, this constructs the module morphism whose matrix in the distinguished basis of \(X\) and \(Y\) is \(m\):sage: # needs sage.modules sage: X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename('X') sage: x = X.basis() sage: Y = CombinatorialFreeModule(ZZ, [3,4]); Y.rename('Y') sage: y = Y.basis() sage: m = matrix([[0,1,2], [3,5,0]]) sage: phi = X.module_morphism(matrix=m, codomain=Y) sage: phi(x[1]) 3*B[4] sage: phi(x[2]) B[3] + 5*B[4]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(ZZ, [Integer(1),Integer(2),Integer(3)]); X.rename('X') >>> x = X.basis() >>> Y = CombinatorialFreeModule(ZZ, [Integer(3),Integer(4)]); Y.rename('Y') >>> y = Y.basis() >>> m = matrix([[Integer(0),Integer(1),Integer(2)], [Integer(3),Integer(5),Integer(0)]]) >>> phi = X.module_morphism(matrix=m, codomain=Y) >>> phi(x[Integer(1)]) 3*B[4] >>> phi(x[Integer(2)]) B[3] + 5*B[4]
# needs sage.modules X = CombinatorialFreeModule(ZZ, [1,2,3]); X.rename('X') x = X.basis() Y = CombinatorialFreeModule(ZZ, [3,4]); Y.rename('Y') y = Y.basis() m = matrix([[0,1,2], [3,5,0]]) phi = X.module_morphism(matrix=m, codomain=Y) phi(x[1]) phi(x[2])
See also:
sage.modules.with_basis.morphism.ModuleMorphismFromMatrix
.With
triangular="upper"
, the constructed module morphism is assumed to be upper triangular; that is its matrix in the distinguished basis of \(X\) and \(Y\) would be upper triangular with invertible elements on its diagonal. This is used to compute preimages and to invert the morphism:sage: # needs sage.modules sage: I = list(range(1, 200)) sage: X = CombinatorialFreeModule(QQ, I); X.rename('X'); x = X.basis() sage: Y = CombinatorialFreeModule(QQ, I); Y.rename('Y'); y = Y.basis() sage: f = Y.sum_of_monomials * divisors sage: phi = X.module_morphism(f, triangular='upper', codomain=Y) sage: phi(x[2]) B[1] + B[2] sage: phi(x[6]) B[1] + B[2] + B[3] + B[6] sage: phi(x[30]) B[1] + B[2] + B[3] + B[5] + B[6] + B[10] + B[15] + B[30] sage: phi.preimage(y[2]) -B[1] + B[2] sage: phi.preimage(y[6]) B[1] - B[2] - B[3] + B[6] sage: phi.preimage(y[30]) -B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30] sage: (phi^-1)(y[30]) -B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30]
>>> from sage.all import * >>> # needs sage.modules >>> I = list(range(Integer(1), Integer(200))) >>> X = CombinatorialFreeModule(QQ, I); X.rename('X'); x = X.basis() >>> Y = CombinatorialFreeModule(QQ, I); Y.rename('Y'); y = Y.basis() >>> f = Y.sum_of_monomials * divisors >>> phi = X.module_morphism(f, triangular='upper', codomain=Y) >>> phi(x[Integer(2)]) B[1] + B[2] >>> phi(x[Integer(6)]) B[1] + B[2] + B[3] + B[6] >>> phi(x[Integer(30)]) B[1] + B[2] + B[3] + B[5] + B[6] + B[10] + B[15] + B[30] >>> phi.preimage(y[Integer(2)]) -B[1] + B[2] >>> phi.preimage(y[Integer(6)]) B[1] - B[2] - B[3] + B[6] >>> phi.preimage(y[Integer(30)]) -B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30] >>> (phi**-Integer(1))(y[Integer(30)]) -B[1] + B[2] + B[3] + B[5] - B[6] - B[10] - B[15] + B[30]
# needs sage.modules I = list(range(1, 200)) X = CombinatorialFreeModule(QQ, I); X.rename('X'); x = X.basis() Y = CombinatorialFreeModule(QQ, I); Y.rename('Y'); y = Y.basis() f = Y.sum_of_monomials * divisors phi = X.module_morphism(f, triangular='upper', codomain=Y) phi(x[2]) phi(x[6]) phi(x[30]) phi.preimage(y[2]) phi.preimage(y[6]) phi.preimage(y[30]) (phi^-1)(y[30])
Since Issue #8678, one can also define a triangular morphism from a function:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, [0,1,2,3,4]); x = X.basis() sage: from sage.modules.with_basis.morphism import TriangularModuleMorphismFromFunction sage: def f(x): return x + X.term(0, sum(x.coefficients())) sage: phi = X.module_morphism(function=f, codomain=X, ....: triangular='upper') sage: phi(x[2] + 3*x[4]) 4*B[0] + B[2] + 3*B[4] sage: phi.preimage(_) B[2] + 3*B[4]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, [Integer(0),Integer(1),Integer(2),Integer(3),Integer(4)]); x = X.basis() >>> from sage.modules.with_basis.morphism import TriangularModuleMorphismFromFunction >>> def f(x): return x + X.term(Integer(0), sum(x.coefficients())) >>> phi = X.module_morphism(function=f, codomain=X, ... triangular='upper') >>> phi(x[Integer(2)] + Integer(3)*x[Integer(4)]) 4*B[0] + B[2] + 3*B[4] >>> phi.preimage(_) B[2] + 3*B[4]
# needs sage.modules X = CombinatorialFreeModule(QQ, [0,1,2,3,4]); x = X.basis() from sage.modules.with_basis.morphism import TriangularModuleMorphismFromFunction def f(x): return x + X.term(0, sum(x.coefficients())) phi = X.module_morphism(function=f, codomain=X, triangular='upper') phi(x[2] + 3*x[4]) phi.preimage(_)
For details and further optional arguments, see
sage.modules.with_basis.morphism.TriangularModuleMorphism
.Warning
As a temporary measure, until multivariate morphisms are implemented, the constructed morphism is in
Hom(codomain, domain, category)
. This is only correct for unary functions.Todo
Should codomain be
self
by default in the diagonal, triangular, and matrix cases?Support for diagonal morphisms between modules not sharing the same index set
- monomial(i)[source]¶
Return the basis element indexed by
i
.INPUT:
i
– an element of the index set
EXAMPLES:
sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules sage: F.monomial('a') # needs sage.modules B['a']
>>> from sage.all import * >>> F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules >>> F.monomial('a') # needs sage.modules B['a']
F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules F.monomial('a') # needs sage.modules
F.monomial
is in fact (almost) a map:sage: F.monomial # needs sage.modules Term map from {'a', 'b', 'c'} to Free module generated by {'a', 'b', 'c'} over Rational Field
>>> from sage.all import * >>> F.monomial # needs sage.modules Term map from {'a', 'b', 'c'} to Free module generated by {'a', 'b', 'c'} over Rational Field
F.monomial # needs sage.modules
- monomial_or_zero_if_none(i)[source]¶
EXAMPLES:
sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules sage: F.monomial_or_zero_if_none('a') # needs sage.modules B['a'] sage: F.monomial_or_zero_if_none(None) # needs sage.modules 0
>>> from sage.all import * >>> F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules >>> F.monomial_or_zero_if_none('a') # needs sage.modules B['a'] >>> F.monomial_or_zero_if_none(None) # needs sage.modules 0
F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules F.monomial_or_zero_if_none('a') # needs sage.modules F.monomial_or_zero_if_none(None) # needs sage.modules
- quotient_module(submodule, check=True, already_echelonized=False, category=None)[source]¶
Construct the quotient module
self
/submodule
.INPUT:
submodule
– a submodule with basis ofself
, or something that can be turned into one viaself.submodule(submodule)
check
,already_echelonized
– passed down toModulesWithBasis.ParentMethods.submodule()
Warning
At this point, this only supports quotients by free submodules admitting a basis in unitriangular echelon form. In this case, the quotient is also a free module, with a basis consisting of the retract of a subset of the basis of
self
.EXAMPLES:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, range(3), prefix='x') sage: x = X.basis() sage: Y = X.quotient_module([x[0] - x[1], x[1] - x[2]], ....: already_echelonized=True) sage: Y.print_options(prefix='y'); Y Free module generated by {2} over Rational Field sage: y = Y.basis() sage: y[2] y[2] sage: y[2].lift() x[2] sage: Y.retract(x[0] + 2*x[1]) 3*y[2] sage: # needs sage.modules sage: R.<a,b> = QQ[] sage: C = CombinatorialFreeModule(R, range(3), prefix='x') sage: x = C.basis() sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] sage: Y = C.quotient_module(gens)
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, range(Integer(3)), prefix='x') >>> x = X.basis() >>> Y = X.quotient_module([x[Integer(0)] - x[Integer(1)], x[Integer(1)] - x[Integer(2)]], ... already_echelonized=True) >>> Y.print_options(prefix='y'); Y Free module generated by {2} over Rational Field >>> y = Y.basis() >>> y[Integer(2)] y[2] >>> y[Integer(2)].lift() x[2] >>> Y.retract(x[Integer(0)] + Integer(2)*x[Integer(1)]) 3*y[2] >>> # needs sage.modules >>> R = QQ['a, b']; (a, b,) = R._first_ngens(2) >>> C = CombinatorialFreeModule(R, range(Integer(3)), prefix='x') >>> x = C.basis() >>> gens = [x[Integer(0)] - x[Integer(1)], Integer(2)*x[Integer(1)] - Integer(2)*x[Integer(2)], x[Integer(0)] - x[Integer(2)]] >>> Y = C.quotient_module(gens)
# needs sage.modules X = CombinatorialFreeModule(QQ, range(3), prefix='x') x = X.basis() Y = X.quotient_module([x[0] - x[1], x[1] - x[2]], already_echelonized=True) Y.print_options(prefix='y'); Y y = Y.basis() y[2] y[2].lift() Y.retract(x[0] + 2*x[1]) # needs sage.modules R.<a,b> = QQ[] C = CombinatorialFreeModule(R, range(3), prefix='x') x = C.basis() gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] Y = C.quotient_module(gens)
See also
Modules.WithBasis.ParentMethods.submodule()
- random_element(n=2)[source]¶
Return a ‘random’ element of
self
.INPUT:
n
– integer (default: 2); number of summands
ALGORITHM:
Return a sum of \(n\) terms, each of which is formed by multiplying a random element of the base ring by a random element of the group.
EXAMPLES:
sage: x = DihedralGroup(6).algebra(QQ).random_element() # needs sage.groups sage.modules sage: x.parent() is DihedralGroup(6).algebra(QQ) # needs sage.groups sage.modules True
>>> from sage.all import * >>> x = DihedralGroup(Integer(6)).algebra(QQ).random_element() # needs sage.groups sage.modules >>> x.parent() is DihedralGroup(Integer(6)).algebra(QQ) # needs sage.groups sage.modules True
x = DihedralGroup(6).algebra(QQ).random_element() # needs sage.groups sage.modules x.parent() is DihedralGroup(6).algebra(QQ) # needs sage.groups sage.modules
Note, this result can depend on the PRNG state in libgap in a way that depends on which packages are loaded, so we must re-seed GAP to ensure a consistent result for this example:
sage: libgap.set_seed(0) # needs sage.libs.gap 0 sage: m = SU(2, 13).algebra(QQ).random_element(1) # needs sage.groups sage.libs.pari sage.modules sage: m.parent() is SU(2, 13).algebra(QQ) # needs sage.groups sage.libs.pari sage.modules True sage: p = CombinatorialFreeModule(ZZ, Partitions(4)).random_element() # needs sage.combinat sage.modules sage: p.parent() is CombinatorialFreeModule(ZZ, Partitions(4)) # needs sage.combinat sage.modules True
>>> from sage.all import * >>> libgap.set_seed(Integer(0)) # needs sage.libs.gap 0 >>> m = SU(Integer(2), Integer(13)).algebra(QQ).random_element(Integer(1)) # needs sage.groups sage.libs.pari sage.modules >>> m.parent() is SU(Integer(2), Integer(13)).algebra(QQ) # needs sage.groups sage.libs.pari sage.modules True >>> p = CombinatorialFreeModule(ZZ, Partitions(Integer(4))).random_element() # needs sage.combinat sage.modules >>> p.parent() is CombinatorialFreeModule(ZZ, Partitions(Integer(4))) # needs sage.combinat sage.modules True
libgap.set_seed(0) # needs sage.libs.gap m = SU(2, 13).algebra(QQ).random_element(1) # needs sage.groups sage.libs.pari sage.modules m.parent() is SU(2, 13).algebra(QQ) # needs sage.groups sage.libs.pari sage.modules p = CombinatorialFreeModule(ZZ, Partitions(4)).random_element() # needs sage.combinat sage.modules p.parent() is CombinatorialFreeModule(ZZ, Partitions(4)) # needs sage.combinat sage.modules
- submodule(gens, check=True, already_echelonized=False, unitriangular=False, support_order=None, category=None, submodule_class=None, *args, **opts)[source]¶
The submodule spanned by a finite set of elements.
INPUT:
gens
– list or family of elements ofself
check
– boolean (default:True
); whether to verify that the elements ofgens
are inself
already_echelonized
– boolean (default:False
); whetherthe elements of
gens
are already in (not necessarily reduced) echelon form
unitriangular
– boolean (default:False
); whether the lift morphism is unitriangularsupport_order
– (optional) either something that can be converted into a tuple or a key functioncategory
– (optional) the category of the submodulesubmodule_class
– (optional) the class of the submodule to return
If
already_echelonized
isFalse
, then the generators are put in reduced echelon form usingechelonize()
, and reindexed by \(0,1,...\).Warning
At this point, this method only works for finite dimensional submodules and if matrices can be echelonized over the base ring.
If in addition
unitriangular
isTrue
, then the generators are made such that the coefficients of the pivots are 1, so that lifting map is unitriangular.The basis of the submodule uses the same index set as the generators, and the lifting map sends \(y_i\) to \(gens[i]\).
See also
ModulesWithBasis.FiniteDimensional.ParentMethods.quotient_module()
EXAMPLES:
We construct a submodule of the free \(\QQ\)-module generated by \(x_0, x_1, x_2\). The submodule is spanned by \(y_0 = x_0 - x_1\) and \(y_1 - x_1 - x_2\), and its basis elements are indexed by \(0\) and \(1\):
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, range(3), prefix='x') sage: x = X.basis() sage: gens = [x[0] - x[1], x[1] - x[2]]; gens [x[0] - x[1], x[1] - x[2]] sage: Y = X.submodule(gens, already_echelonized=True) sage: Y.print_options(prefix='y'); Y Free module generated by {0, 1} over Rational Field sage: y = Y.basis() sage: y[1] y[1] sage: y[1].lift() x[1] - x[2] sage: Y.retract(x[0] - x[2]) y[0] + y[1] sage: Y.retract(x[0]) Traceback (most recent call last): ... ValueError: x[0] is not in the image
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, range(Integer(3)), prefix='x') >>> x = X.basis() >>> gens = [x[Integer(0)] - x[Integer(1)], x[Integer(1)] - x[Integer(2)]]; gens [x[0] - x[1], x[1] - x[2]] >>> Y = X.submodule(gens, already_echelonized=True) >>> Y.print_options(prefix='y'); Y Free module generated by {0, 1} over Rational Field >>> y = Y.basis() >>> y[Integer(1)] y[1] >>> y[Integer(1)].lift() x[1] - x[2] >>> Y.retract(x[Integer(0)] - x[Integer(2)]) y[0] + y[1] >>> Y.retract(x[Integer(0)]) Traceback (most recent call last): ... ValueError: x[0] is not in the image
# needs sage.modules X = CombinatorialFreeModule(QQ, range(3), prefix='x') x = X.basis() gens = [x[0] - x[1], x[1] - x[2]]; gens Y = X.submodule(gens, already_echelonized=True) Y.print_options(prefix='y'); Y y = Y.basis() y[1] y[1].lift() Y.retract(x[0] - x[2]) Y.retract(x[0])
By using a family to specify a basis of the submodule, we obtain a submodule whose index set coincides with the index set of the family:
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, range(3), prefix='x') sage: x = X.basis() sage: gens = Family({1: x[0] - x[1], 3: x[1] - x[2]}); gens Finite family {1: x[0] - x[1], 3: x[1] - x[2]} sage: Y = X.submodule(gens, already_echelonized=True) sage: Y.print_options(prefix='y'); Y Free module generated by {1, 3} over Rational Field sage: y = Y.basis() sage: y[1] y[1] sage: y[1].lift() x[0] - x[1] sage: y[3].lift() x[1] - x[2] sage: Y.retract(x[0] - x[2]) y[1] + y[3] sage: Y.retract(x[0]) Traceback (most recent call last): ... ValueError: x[0] is not in the image
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, range(Integer(3)), prefix='x') >>> x = X.basis() >>> gens = Family({Integer(1): x[Integer(0)] - x[Integer(1)], Integer(3): x[Integer(1)] - x[Integer(2)]}); gens Finite family {1: x[0] - x[1], 3: x[1] - x[2]} >>> Y = X.submodule(gens, already_echelonized=True) >>> Y.print_options(prefix='y'); Y Free module generated by {1, 3} over Rational Field >>> y = Y.basis() >>> y[Integer(1)] y[1] >>> y[Integer(1)].lift() x[0] - x[1] >>> y[Integer(3)].lift() x[1] - x[2] >>> Y.retract(x[Integer(0)] - x[Integer(2)]) y[1] + y[3] >>> Y.retract(x[Integer(0)]) Traceback (most recent call last): ... ValueError: x[0] is not in the image
# needs sage.modules X = CombinatorialFreeModule(QQ, range(3), prefix='x') x = X.basis() gens = Family({1: x[0] - x[1], 3: x[1] - x[2]}); gens Y = X.submodule(gens, already_echelonized=True) Y.print_options(prefix='y'); Y y = Y.basis() y[1] y[1].lift() y[3].lift() Y.retract(x[0] - x[2]) Y.retract(x[0])
It is not necessary that the generators of the submodule form a basis (an explicit basis will be computed):
sage: # needs sage.modules sage: X = CombinatorialFreeModule(QQ, range(3), prefix='x') sage: x = X.basis() sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]; gens [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] sage: Y = X.submodule(gens, already_echelonized=False) sage: Y.print_options(prefix='y') sage: Y Free module generated by {0, 1} over Rational Field sage: [b.lift() for b in Y.basis()] [x[0] - x[2], x[1] - x[2]]
>>> from sage.all import * >>> # needs sage.modules >>> X = CombinatorialFreeModule(QQ, range(Integer(3)), prefix='x') >>> x = X.basis() >>> gens = [x[Integer(0)] - x[Integer(1)], Integer(2)*x[Integer(1)] - Integer(2)*x[Integer(2)], x[Integer(0)] - x[Integer(2)]]; gens [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] >>> Y = X.submodule(gens, already_echelonized=False) >>> Y.print_options(prefix='y') >>> Y Free module generated by {0, 1} over Rational Field >>> [b.lift() for b in Y.basis()] [x[0] - x[2], x[1] - x[2]]
# needs sage.modules X = CombinatorialFreeModule(QQ, range(3), prefix='x') x = X.basis() gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]]; gens Y = X.submodule(gens, already_echelonized=False) Y.print_options(prefix='y') Y [b.lift() for b in Y.basis()]
We now implement by hand the center of the algebra of the symmetric group \(S_3\):
sage: # needs sage.combinat sage.groups sage.modules sage: S3 = SymmetricGroup(3) sage: S3A = S3.algebra(QQ) sage: basis = S3A.annihilator_basis(S3A.algebra_generators(), ....: S3A.bracket) sage: basis ((), (1,2,3) + (1,3,2), (2,3) + (1,2) + (1,3)) sage: center = S3A.submodule(basis, ....: category=AlgebrasWithBasis(QQ).Subobjects(), ....: already_echelonized=True) sage: center Free module generated by {0, 1, 2} over Rational Field sage: center in Algebras True sage: center.print_options(prefix='c') sage: c = center.basis() sage: c[1].lift() (1,2,3) + (1,3,2) sage: c[0]^2 c[0] sage: e = 1/6 * (c[0]+c[1]+c[2]) sage: e.is_idempotent() True
>>> from sage.all import * >>> # needs sage.combinat sage.groups sage.modules >>> S3 = SymmetricGroup(Integer(3)) >>> S3A = S3.algebra(QQ) >>> basis = S3A.annihilator_basis(S3A.algebra_generators(), ... S3A.bracket) >>> basis ((), (1,2,3) + (1,3,2), (2,3) + (1,2) + (1,3)) >>> center = S3A.submodule(basis, ... category=AlgebrasWithBasis(QQ).Subobjects(), ... already_echelonized=True) >>> center Free module generated by {0, 1, 2} over Rational Field >>> center in Algebras True >>> center.print_options(prefix='c') >>> c = center.basis() >>> c[Integer(1)].lift() (1,2,3) + (1,3,2) >>> c[Integer(0)]**Integer(2) c[0] >>> e = Integer(1)/Integer(6) * (c[Integer(0)]+c[Integer(1)]+c[Integer(2)]) >>> e.is_idempotent() True
# needs sage.combinat sage.groups sage.modules S3 = SymmetricGroup(3) S3A = S3.algebra(QQ) basis = S3A.annihilator_basis(S3A.algebra_generators(), S3A.bracket) basis center = S3A.submodule(basis, category=AlgebrasWithBasis(QQ).Subobjects(), already_echelonized=True) center center in Algebras center.print_options(prefix='c') c = center.basis() c[1].lift() c[0]^2 e = 1/6 * (c[0]+c[1]+c[2]) e.is_idempotent()
Of course, this center is best constructed using:
sage: center = S3A.center() # needs sage.combinat sage.groups sage.modules
>>> from sage.all import * >>> center = S3A.center() # needs sage.combinat sage.groups sage.modules
center = S3A.center() # needs sage.combinat sage.groups sage.modules
We can also automatically construct a basis such that the lift morphism is (lower) unitriangular:
sage: # needs sage.modules sage: R.<a,b> = QQ[] sage: C = CombinatorialFreeModule(R, range(3), prefix='x') sage: x = C.basis() sage: gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] sage: Y = C.submodule(gens, unitriangular=True) sage: Y.lift.matrix() [ 1 0] [ 0 1] [-1 -1]
>>> from sage.all import * >>> # needs sage.modules >>> R = QQ['a, b']; (a, b,) = R._first_ngens(2) >>> C = CombinatorialFreeModule(R, range(Integer(3)), prefix='x') >>> x = C.basis() >>> gens = [x[Integer(0)] - x[Integer(1)], Integer(2)*x[Integer(1)] - Integer(2)*x[Integer(2)], x[Integer(0)] - x[Integer(2)]] >>> Y = C.submodule(gens, unitriangular=True) >>> Y.lift.matrix() [ 1 0] [ 0 1] [-1 -1]
# needs sage.modules R.<a,b> = QQ[] C = CombinatorialFreeModule(R, range(3), prefix='x') x = C.basis() gens = [x[0] - x[1], 2*x[1] - 2*x[2], x[0] - x[2]] Y = C.submodule(gens, unitriangular=True) Y.lift.matrix()
We now construct a (finite-dimensional) submodule of an infinite dimensional free module:
sage: # needs sage.modules sage: C = CombinatorialFreeModule(QQ, ZZ, prefix='z') sage: z = C.basis() sage: gens = [z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]] sage: Y = C.submodule(gens) sage: [Y.lift(b) for b in Y.basis()] [z[0] - z[2], z[1] - z[2]]
>>> from sage.all import * >>> # needs sage.modules >>> C = CombinatorialFreeModule(QQ, ZZ, prefix='z') >>> z = C.basis() >>> gens = [z[Integer(0)] - z[Integer(1)], Integer(2)*z[Integer(1)] - Integer(2)*z[Integer(2)], z[Integer(0)] - z[Integer(2)]] >>> Y = C.submodule(gens) >>> [Y.lift(b) for b in Y.basis()] [z[0] - z[2], z[1] - z[2]]
# needs sage.modules C = CombinatorialFreeModule(QQ, ZZ, prefix='z') z = C.basis() gens = [z[0] - z[1], 2*z[1] - 2*z[2], z[0] - z[2]] Y = C.submodule(gens) [Y.lift(b) for b in Y.basis()]
- sum_of_monomials()[source]¶
Return the sum of the basis elements with indices in
indices
.INPUT:
indices
– list (or iterable) of indices of basis elements
EXAMPLES:
sage: F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules sage: F.sum_of_monomials(['a', 'b']) # needs sage.modules B['a'] + B['b'] sage: F.sum_of_monomials(['a', 'b', 'a']) # needs sage.modules 2*B['a'] + B['b']
>>> from sage.all import * >>> F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules >>> F.sum_of_monomials(['a', 'b']) # needs sage.modules B['a'] + B['b'] >>> F.sum_of_monomials(['a', 'b', 'a']) # needs sage.modules 2*B['a'] + B['b']
F = CombinatorialFreeModule(QQ, ['a', 'b', 'c']) # needs sage.modules F.sum_of_monomials(['a', 'b']) # needs sage.modules F.sum_of_monomials(['a', 'b', 'a']) # needs sage.modules
F.sum_of_monomials
is in fact (almost) a map:sage: F.sum_of_monomials # needs sage.modules A map to Free module generated by {'a', 'b', 'c'} over Rational Field
>>> from sage.all import * >>> F.sum_of_monomials # needs sage.modules A map to Free module generated by {'a', 'b', 'c'} over Rational Field
F.sum_of_monomials # needs sage.modules
- sum_of_terms(terms)[source]¶
Construct a sum of terms of
self
.INPUT:
terms
– list (or iterable) of pairs(index, coeff)
OUTPUT:
Sum of
coeff * B[index]
over all(index, coeff)
interms
, whereB
is the basis ofself
.EXAMPLES:
sage: m = matrix([[0,1], [1,1]]) # needs sage.modules sage: J.<a,b,c> = JordanAlgebra(m) # needs sage.combinat sage.modules sage: J.sum_of_terms([(0, 2), (2, -3)]) # needs sage.combinat sage.modules 2 + (0, -3)
>>> from sage.all import * >>> m = matrix([[Integer(0),Integer(1)], [Integer(1),Integer(1)]]) # needs sage.modules >>> J = JordanAlgebra(m, names=('a', 'b', 'c',)); (a, b, c,) = J._first_ngens(3)# needs sage.combinat sage.modules >>> J.sum_of_terms([(Integer(0), Integer(2)), (Integer(2), -Integer(3))]) # needs sage.combinat sage.modules 2 + (0, -3)
m = matrix([[0,1], [1,1]]) # needs sage.modules J.<a,b,c> = JordanAlgebra(m) # needs sage.combinat sage.modules J.sum_of_terms([(0, 2), (2, -3)]) # needs sage.combinat sage.modules
- tensor(*parents, **kwargs)[source]¶
Return the tensor product of the parents.
EXAMPLES:
sage: C = AlgebrasWithBasis(QQ) sage: A = C.example(); A.rename('A') # needs sage.combinat sage.modules sage: A.tensor(A, A) # needs sage.combinat sage.modules A # A # A sage: A.rename(None) # needs sage.combinat sage.modules
>>> from sage.all import * >>> C = AlgebrasWithBasis(QQ) >>> A = C.example(); A.rename('A') # needs sage.combinat sage.modules >>> A.tensor(A, A) # needs sage.combinat sage.modules A # A # A >>> A.rename(None) # needs sage.combinat sage.modules
C = AlgebrasWithBasis(QQ) A = C.example(); A.rename('A') # needs sage.combinat sage.modules A.tensor(A, A) # needs sage.combinat sage.modules A.rename(None) # needs sage.combinat sage.modules
- term(index, coeff=None)[source]¶
Construct a term in
self
.INPUT:
index
– the index of a basis elementcoeff
– an element of the coefficient ring (default: one)
OUTPUT:
coeff * B[index]
, whereB
is the basis ofself
EXAMPLES:
sage: m = matrix([[0,1], [1,1]]) # needs sage.modules sage: J.<a,b,c> = JordanAlgebra(m) # needs sage.combinat sage.modules sage: J.term(1, -2) # needs sage.combinat sage.modules 0 + (-2, 0)
>>> from sage.all import * >>> m = matrix([[Integer(0),Integer(1)], [Integer(1),Integer(1)]]) # needs sage.modules >>> J = JordanAlgebra(m, names=('a', 'b', 'c',)); (a, b, c,) = J._first_ngens(3)# needs sage.combinat sage.modules >>> J.term(Integer(1), -Integer(2)) # needs sage.combinat sage.modules 0 + (-2, 0)
m = matrix([[0,1], [1,1]]) # needs sage.modules J.<a,b,c> = JordanAlgebra(m) # needs sage.combinat sage.modules J.term(1, -2) # needs sage.combinat sage.modules
Design: should this do coercion on the coefficient ring?
- Super[source]¶
alias of
SuperModulesWithBasis
- class TensorProducts(category, *args)[source]¶
Bases:
TensorProductsCategory
The category of modules with basis constructed by tensor product of modules with basis.
- class ElementMethods[source]¶
Bases:
object
Implement operations on elements of tensor products of modules with basis.
- apply_multilinear_morphism(f, codomain=None)[source]¶
Return the result of applying the morphism induced by
f
toself
.INPUT:
f
– a multilinear morphism from the component modules of the parent tensor product to any modulecodomain
– the codomain off
(optional)
By the universal property of the tensor product,
f
induces a linear morphism from \(self.parent()\) to the target module. Returns the result of applying that morphism toself
.The codomain is used for optimizations purposes only. If it’s not provided, it’s recovered by calling
f
on the zero input.EXAMPLES:
We start with simple (admittedly not so interesting) examples, with two modules \(A\) and \(B\):
sage: # needs sage.modules sage: A = CombinatorialFreeModule(ZZ, [1,2], prefix='A') sage: A.rename('A') sage: B = CombinatorialFreeModule(ZZ, [3,4], prefix='B') sage: B.rename('B')
>>> from sage.all import * >>> # needs sage.modules >>> A = CombinatorialFreeModule(ZZ, [Integer(1),Integer(2)], prefix='A') >>> A.rename('A') >>> B = CombinatorialFreeModule(ZZ, [Integer(3),Integer(4)], prefix='B') >>> B.rename('B')
# needs sage.modules A = CombinatorialFreeModule(ZZ, [1,2], prefix='A') A.rename('A') B = CombinatorialFreeModule(ZZ, [3,4], prefix='B') B.rename('B')
and \(f\) the bilinear morphism \((a,b) \mapsto b \otimes a\) from \(A \times B\) to \(B \otimes A\):
sage: def f(a, b): ....: return tensor([b,a])
>>> from sage.all import * >>> def f(a, b): ... return tensor([b,a])
def f(a, b): return tensor([b,a])
Now, calling applying \(f\) on \(a \otimes b\) returns the same as \(f(a,b)\):
sage: # needs sage.modules sage: a = A.monomial(1) + 2 * A.monomial(2); a A[1] + 2*A[2] sage: b = B.monomial(3) - 2 * B.monomial(4); b B[3] - 2*B[4] sage: f(a, b) B[3] # A[1] + 2*B[3] # A[2] - 2*B[4] # A[1] - 4*B[4] # A[2] sage: tensor([a, b]).apply_multilinear_morphism(f) B[3] # A[1] + 2*B[3] # A[2] - 2*B[4] # A[1] - 4*B[4] # A[2]
>>> from sage.all import * >>> # needs sage.modules >>> a = A.monomial(Integer(1)) + Integer(2) * A.monomial(Integer(2)); a A[1] + 2*A[2] >>> b = B.monomial(Integer(3)) - Integer(2) * B.monomial(Integer(4)); b B[3] - 2*B[4] >>> f(a, b) B[3] # A[1] + 2*B[3] # A[2] - 2*B[4] # A[1] - 4*B[4] # A[2] >>> tensor([a, b]).apply_multilinear_morphism(f) B[3] # A[1] + 2*B[3] # A[2] - 2*B[4] # A[1] - 4*B[4] # A[2]
# needs sage.modules a = A.monomial(1) + 2 * A.monomial(2); a b = B.monomial(3) - 2 * B.monomial(4); b f(a, b) tensor([a, b]).apply_multilinear_morphism(f)
\(f\) may be a bilinear morphism to any module over the base ring of \(A\) and \(B\). Here the codomain is \(\ZZ\):
sage: def f(a, b): ....: return sum(a.coefficients(), 0) * sum(b.coefficients(), 0) sage: f(a, b) # needs sage.modules -3 sage: tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules -3
>>> from sage.all import * >>> def f(a, b): ... return sum(a.coefficients(), Integer(0)) * sum(b.coefficients(), Integer(0)) >>> f(a, b) # needs sage.modules -3 >>> tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules -3
def f(a, b): return sum(a.coefficients(), 0) * sum(b.coefficients(), 0) f(a, b) # needs sage.modules tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules
Mind the \(0\) in the sums above; otherwise \(f\) would not return \(0\) in \(\ZZ\):
sage: def f(a, b): ....: return sum(a.coefficients()) * sum(b.coefficients()) sage: type(f(A.zero(), B.zero())) # needs sage.modules <... 'int'>
>>> from sage.all import * >>> def f(a, b): ... return sum(a.coefficients()) * sum(b.coefficients()) >>> type(f(A.zero(), B.zero())) # needs sage.modules <... 'int'>
def f(a, b): return sum(a.coefficients()) * sum(b.coefficients()) type(f(A.zero(), B.zero())) # needs sage.modules
Which would be wrong and break this method:
sage: tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules Traceback (most recent call last): ... AttributeError: 'int' object has no attribute 'parent'...
>>> from sage.all import * >>> tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules Traceback (most recent call last): ... AttributeError: 'int' object has no attribute 'parent'...
tensor([a, b]).apply_multilinear_morphism(f) # needs sage.modules
Here we consider an example where the codomain is a module with basis with a different base ring:
sage: # needs sage.modules sage: C = CombinatorialFreeModule(QQ, [(1,3),(2,4)], prefix='C') sage: C.rename('C') sage: def f(a, b): ....: return C.sum_of_terms([((1,3), QQ(a[1]*b[3])), ....: ((2,4), QQ(a[2]*b[4]))]) sage: f(a,b) C[(1, 3)] - 4*C[(2, 4)] sage: tensor([a, b]).apply_multilinear_morphism(f) C[(1, 3)] - 4*C[(2, 4)] We conclude with a real life application, where we check that the antipode of the Hopf algebra of Symmetric functions on the Schur basis satisfies its defining formula:: sage: # needs lrcalc_python sage.combinat sage.modules sage: Sym = SymmetricFunctions(QQ) sage: s = Sym.schur() sage: def f(a, b): return a * b.antipode() sage: x = 4 * s.an_element(); x 8*s[] + 8*s[1] + 12*s[2] sage: x.coproduct().apply_multilinear_morphism(f) 8*s[] sage: x.coproduct().apply_multilinear_morphism(f) == x.counit() True
We recover the constant term of \(x\), as desired.
Todo
Extract a method to linearize a multilinear morphism, and delegate the work there.
- class ParentMethods[source]¶
Bases:
object
Implement operations on tensor products of modules with basis.
- extra_super_categories()[source]¶
EXAMPLES:
sage: ModulesWithBasis(QQ).TensorProducts().extra_super_categories() [Category of vector spaces with basis over Rational Field] sage: ModulesWithBasis(QQ).TensorProducts().super_categories() [Category of tensor products of modules with basis over Rational Field, Category of vector spaces with basis over Rational Field, Category of tensor products of vector spaces over Rational Field]
>>> from sage.all import * >>> ModulesWithBasis(QQ).TensorProducts().extra_super_categories() [Category of vector spaces with basis over Rational Field] >>> ModulesWithBasis(QQ).TensorProducts().super_categories() [Category of tensor products of modules with basis over Rational Field, Category of vector spaces with basis over Rational Field, Category of tensor products of vector spaces over Rational Field]
ModulesWithBasis(QQ).TensorProducts().extra_super_categories() ModulesWithBasis(QQ).TensorProducts().super_categories()
- is_abelian()[source]¶
Return whether this category is abelian.
This is the case if and only if the base ring is a field.
EXAMPLES:
sage: ModulesWithBasis(QQ).is_abelian() True sage: ModulesWithBasis(ZZ).is_abelian() False
>>> from sage.all import * >>> ModulesWithBasis(QQ).is_abelian() True >>> ModulesWithBasis(ZZ).is_abelian() False
ModulesWithBasis(QQ).is_abelian() ModulesWithBasis(ZZ).is_abelian()