Examples of graded modules with basis¶
-
sage.categories.examples.graded_modules_with_basis.
Example
¶ This class illustrates an implementation of a graded module with basis: the free module over partitions.
INPUT:
R
– base ring
The implementation involves the following:
A choice of how to represent elements. In this case, the basis elements are partitions. The algebra is constructed as a
CombinatorialFreeModule
on the set of partitions, so it inherits all of the methods for such objects, and has operations like addition already defined.sage: A = GradedModulesWithBasis(QQ).example()
A basis function - this module is graded by the non-negative integers, so there is a function defined in this module, creatively called
basis()
, which takes an integer \(d\) as input and returns a family of partitions representing a basis for the algebra in degree \(d\).sage: A.basis(2) Lazy family (Term map from Partitions to An example of a graded module with basis: the free module on partitions over Rational Field(i))_{i in Partitions of the integer 2} sage: A.basis(6)[Partition([3,2,1])] P[3, 2, 1]
If the algebra is called
A
, then its basis function is stored asA.basis
. Thus the function can be used to find a basis for the degree \(d\) piece: essentially, just callA.basis(d)
. More precisely, callx
for eachx
inA.basis(d)
.sage: [m for m in A.basis(4)] [P[4], P[3, 1], P[2, 2], P[2, 1, 1], P[1, 1, 1, 1]]
For dealing with basis elements:
degree_on_basis()
, and_repr_term()
. The first of these defines the degree of any monomial, and then thedegree
method for elements – see the next item – uses it to compute the degree for a linear combination of monomials. The last of these determines the print representation for monomials, which automatically produces the print representation for general elements.sage: A.degree_on_basis(Partition([4,3])) 7 sage: A._repr_term(Partition([4,3])) 'P[4, 3]'
There is a class for elements, which inherits from
IndexedFreeModuleElement
. An element is determined by a dictionary whose keys are partitions and whose corresponding values are the coefficients. The class implements two things: anis_homogeneous
method and adegree
method.sage: p = A.monomial(Partition([3,2,1])); p P[3, 2, 1] sage: p.is_homogeneous() True sage: p.degree() 6
-
sage.categories.examples.graded_modules_with_basis.
GradedPartitionModule
¶ This class illustrates an implementation of a graded module with basis: the free module over partitions.
INPUT:
R
– base ring
The implementation involves the following:
A choice of how to represent elements. In this case, the basis elements are partitions. The algebra is constructed as a
CombinatorialFreeModule
on the set of partitions, so it inherits all of the methods for such objects, and has operations like addition already defined.sage: A = GradedModulesWithBasis(QQ).example()
A basis function - this module is graded by the non-negative integers, so there is a function defined in this module, creatively called
basis()
, which takes an integer \(d\) as input and returns a family of partitions representing a basis for the algebra in degree \(d\).sage: A.basis(2) Lazy family (Term map from Partitions to An example of a graded module with basis: the free module on partitions over Rational Field(i))_{i in Partitions of the integer 2} sage: A.basis(6)[Partition([3,2,1])] P[3, 2, 1]
If the algebra is called
A
, then its basis function is stored asA.basis
. Thus the function can be used to find a basis for the degree \(d\) piece: essentially, just callA.basis(d)
. More precisely, callx
for eachx
inA.basis(d)
.sage: [m for m in A.basis(4)] [P[4], P[3, 1], P[2, 2], P[2, 1, 1], P[1, 1, 1, 1]]
For dealing with basis elements:
degree_on_basis()
, and_repr_term()
. The first of these defines the degree of any monomial, and then thedegree
method for elements – see the next item – uses it to compute the degree for a linear combination of monomials. The last of these determines the print representation for monomials, which automatically produces the print representation for general elements.sage: A.degree_on_basis(Partition([4,3])) 7 sage: A._repr_term(Partition([4,3])) 'P[4, 3]'
There is a class for elements, which inherits from
IndexedFreeModuleElement
. An element is determined by a dictionary whose keys are partitions and whose corresponding values are the coefficients. The class implements two things: anis_homogeneous
method and adegree
method.sage: p = A.monomial(Partition([3,2,1])); p P[3, 2, 1] sage: p.is_homogeneous() True sage: p.degree() 6