FUNCTION: Perm2Desc - compute the list of descents of a permutation
CALLING SEQUENCE:
- Perm2Desc(perm)
- SG[Perm2Desc](perm)
-
PARAMETERS:
- perm = any list denoting a permutation
SYNOPSIS:
- The Perm2Desc function computes the list of descents of the permutation
perm, i.e. the list of positions i, such that perm[i] > perm[i+1].
- When called with the second argument 'nb', it returns the number of
descents of the permutation perm.
- When called with the second argument 'maj', it returns the sum of the
descent positions.
- When called with the second argument 'comaj', it returns the sum of all
values (n - descent position), where n is equal to nops(perm).
- Whenever there is a conflict between the function name Perm2Desc and
and another name used in the same session, use the long form
SG['Perm2Desc'].
EXAMPLES:
> with(SG):
> perm:=[3,1,4,2,6,5,7]:
> Perm2Desc(perm);
[1, 3, 5]
> Perm2Desc(perm, 'nb');
3
> Perm2Desc(perm, 'maj');
9
> Perm2Desc(perm, 'comaj');
12
SEE ALSO: Perm2Rise