Package sage :: Package combinat :: Module combinatorial_algebra
[hide private]
[frames] | no frames]

Module combinatorial_algebra

source code


Combinatorial Algebras

A combinatorial algebra is an algebra whose basis elements are indexed
by a combinatorial class.  Some examples of combinatorial algebras are
the symmetric group algebra of order n (indexed by permutations of size n)
and the algebra of symmetric functions (indexed by integer partitions).

The CombinatorialAlgebra base class makes it easy to define and work
with new combinatorial algebras in Sage.  For example, the following
code constructs an algebra which models the power-sum symmetric
functions.

sage: class PowerSums(CombinatorialAlgebra):
...     def __init__(self, R):
...         self._combinatorial_class = Partitions()
...         self._one = Partition([])
...         self._name = 'Power-sum symmetric functions'
...         self._prefix = 'p'
...         CombinatorialAlgebra.__init__(self, R)
...     def _multiply_basis(self, a, b):
...         l = list(a)+list(b)
...         l.sort(reverse=True)
...         return Partition(l)
... 

sage: ps = PowerSums(QQ); ps
Power-sum symmetric functions over Rational Field
sage: ps([2,1])^2
p[2, 2, 1, 1]
sage: ps([2,1])+2*ps([1,1,1])
2*p[1, 1, 1] + p[2, 1]
sage: ps(2)
2*p[]
 
The important things to define are ._combinatorial_class which specifies
the combinatorial class that indexes the basis elements, ._one which
specifies the identity element in the algebra, ._name which specifies
the name of the algebra, ._prefix which is the string put in front of
each basis element, and finally a _multiply or _multiply basis method
that defines the multiplication in the algebra.



Classes [hide private]
  CombinatorialAlgebraElement
  CombinatorialAlgebra