Hi Dima, > > 1) It is also already implemented in permutation.py: > > > > OK. I should have looked at the member functions of a permutation... > > > sage: Permutation([1,4,2,3]).signature() > > 1 > > sage: Permutation([1,4,3,2]).signature() > > -1 > > > > 2) if you want to play with large permutations, there is a much better > > algorithm, namely, decompose the permutations into cycles an return > > n-#cycles if the permutations belongs to SG_n. > > Indeed, but you need to return the parity (1 if even, else -1) of the > number of cycles of even length.
Sorry, I should have written (-1)^(n-#cycles) > Is it the way the member function is implemented? Yes ! And they are several implementation of the cycle decomposition depending on the size of the permutation but As far as I remember only the default one is used in signature. Clearly all these should be optimize in Cython however for this, we need a better data structure. I'm working (slowly) on this. Cheers, Florent -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
