Hello Nicolas,
Sorry for such the delay in getting back to you -- things have pretty
quite busy for me these past few months. I'm currently spending the
semester in Madison, WI sitting in on Arun Ram's course on Lie
algebras.
I wanted to let you know that I finally have an initial version of my
combinatorics package in SAGE. As you may have guessed, it's pretty
heavily influenced by MuPAD-Combinat so it shouldn't be terribly
uncomfortable for you to use ;)
One of the main differences is that specific combinatorial classes (
such as partitions of 5 ) are represented by Python objects. Their
class (in the object-oriented sense of class) is a subclass of
CombinatorialClass. For example,
sage: p5 = Partitions(5)
sage: type(p5)
<class 'sage.combinat.partition.Partitions_n'>
sage: p5.list()
[[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]]
sage: p5.count()
7
sage: [i for i in p5]
[[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]]
sage: p5[0]
[5]
sage: p5[3]
[3, 1, 1]
sage: p5.random()
[5]
sage: p5.rank([4,1])
1
sage: p5.unrank(1)
[4, 1]
sage: [2,1,1] in p5
False
sage: [2,2,1] in p5
True
This way, additional parameters are passed in at the beginning and not
to the individual functions (list, count, etc.).
sage: p = Partitions(5, min_part=2)
sage: type(p)
<class 'sage.combinat.partition.Partitions_constraints'>
sage: p.list()
[[5], [3, 2]]
As with MuPAD-Combinat, you only _really_ need to provide routines
that will generate all the elements of the class (iterator, list,
first/next, last/previous, etc.), and CombinatorialClass provides
default implementations for the others.
I also have a very initial version of CombinatorialAlgebra. For
example, here is a minimal definition for the symmetric group algebra:
class SymmetricGroupAlgebra_n(CombinatorialAlgebra):
def __init__(self, R, n):
self.n = n
self._combinatorial_class = permutation.Permutations(n)
self._name = "Symmetric group algebra of order %s"%self.n
self._one = permutation.Permutation(range(1,n+1))
self._prefix = ""
CombinatorialAlgebra.__init__(self, R)
def _multiply_basis(self, left, right):
return left * right
and it in use:
sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
sage: a = QS3([1,2,3]) + QS3([2,1,3]); a
[1, 2, 3] + [2, 1, 3]
sage: a^2
2*[1, 2, 3] + 2*[2, 1, 3]
You can also work with symmetric functions (which follows Magma's
design closely).
sage: s = SFASchur(QQ)
sage: m = SFAMonomial(QQ)
sage: a = s([2,1])
sage: b = a^2; b
s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[3, 3] +
s[4, 1, 1] + s[4, 2]
sage: c = m(b); c
80*m[1, 1, 1, 1, 1, 1] + 40*m[2, 1, 1, 1, 1] + 20*m[2, 2, 1, 1] +
10*m[2, 2, 2] + 12*m[3, 1, 1, 1] + 6*m[3, 2, 1] + 2*m[3, 3] + 2*m[4,
1, 1] + m[4, 2]
sage: a(a) #plethysm
s[2, 2, 2, 2, 1] + s[3, 2, 1, 1, 1, 1] + 2*s[3, 2, 2, 1, 1] + s[3, 2,
2, 2] + s[3, 3, 1, 1, 1] + 3*s[3, 3, 2, 1] + 2*s[4, 2, 1, 1, 1] +
3*s[4, 2, 2, 1] + 3*s[4, 3, 1, 1] + 3*s[4, 3, 2] + s[4, 4, 1] + s[5,
1, 1, 1, 1] + 2*s[5, 2, 1, 1] + s[5, 2, 2] + 2*s[5, 3, 1] + s[5, 4] +
s[6, 2, 1]
There's definitely a lot left that I want to do such as
Hall-Littlewood and Macdonald polynomials and combinatorial species.
I've started looking at Ralf and Martin's species stuff this weekend
and was able to get their (lazy, recursion supporting) power series
working in SAGE.
If you're interested, I could make a page on the SAGE Wiki describing
the relationship between my SAGE code and MuPAD-Combinat.
Hope you're enjoying UC-Davis!
--Mike
P.S. These are the files that are in the current version of SAGE.
Most of them correspond the the files in MuPAD-combinat:
alternating_sign_matrix.py, cartesian_product.py, choose_nk.py,
combination.py, combinatorial_algebra.py, combinat.py, composition.py,
composition_signed.py, dyck_word.py, generator.py, integer_list.py,
integer_vector.py, integer_vector_weighted.py, lyndon_word.py,
misc.py, multichoose_nk.py, necklace.py, partition_algebra.py,
partition.py, permutation_nk.py, permutation.py, q_analogues.py,
ranker.py, ribbon.py, schubert_polynomial.py,
set_partition_ordered.py, set_partition.py, sfa.py, skew_partition.py,
skew_tableau.py, sloane_functions.py, split_nk.py, subset.py,
subword.py, symmetric_group_algebra.py, tableau.py, tools.py,
tuple.py, word.py
|