# Permutations indexed from zero

Is there an option to have permutations indexed from zero instead of one, in other words can we have permutations on the integers 0 to n-1 instead of permutations on the integers 1 to n. This would be useful since indexation for lists, tuples, and iterables in general is usually from zero. Indices for variable names of generators of various algebraic structures, such as multivariate polynomial rings, finitely presented groups, etc., also start from zero.

I saw that PermutationOptions lets you choose how to display permutations, and whether to multiply them from left to right or right to left, but found nothing about having indices starting from zero versus one.

edit retag close merge delete

Sort by » oldest newest most voted

You may use the permutation in sage.groups instead of the one in sage.combinat. They can be defined on any domain (at least on recent enough versions of Sage):

sage: S = SymmetricGroup(['a','b','c','d'])
sage: s = S([('a','b'),('c','d')])
sage: s
('a','b')('c','d')
sage: s('a')
'b'


in particular the domain can be {0, ..., v-1}.

Vincent

more

The permutation code in Sage is suboptimal and needs a rewrite. The check for positive input was introduced as a workaround to make the code usable, see http://trac.sagemath.org/ticket/13742 . There you can find that this check can be turned off via

sage: Permutation(range(5),check_input=False)
[0, 1, 2, 3, 4]


This is not recommended and will lead to other problems.

more