ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 14 Jul 2014 11:43:22 +0200Permutations indexed from zerohttps://ask.sagemath.org/question/23402/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.
Sun, 13 Jul 2014 19:10:27 +0200https://ask.sagemath.org/question/23402/permutations-indexed-from-zero/Answer by rws for <p>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.</p>
<p>I saw that <code>PermutationOptions</code> 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.</p>
https://ask.sagemath.org/question/23402/permutations-indexed-from-zero/?answer=23414#post-id-23414The 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.Mon, 14 Jul 2014 07:57:41 +0200https://ask.sagemath.org/question/23402/permutations-indexed-from-zero/?answer=23414#post-id-23414Answer by vdelecroix for <p>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.</p>
<p>I saw that <code>PermutationOptions</code> 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.</p>
https://ask.sagemath.org/question/23402/permutations-indexed-from-zero/?answer=23416#post-id-23416You 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}.
VincentMon, 14 Jul 2014 11:43:22 +0200https://ask.sagemath.org/question/23402/permutations-indexed-from-zero/?answer=23416#post-id-23416