FUNCTION: Perm2Rise - compute the list of rises of a permutation
CALLING SEQUENCE:
- Perm2Rise(perm)
- SG[Perm2Rise](perm)
-
PARAMETERS:
- perm = any list denoting a permutation
SYNOPSIS:
- The Perm2Rise function computes the list of rises 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
rises of the permutation perm.
- When called with the second argument 'rin', it returns the sum of the
rise positions (rise index).
- When called with the second argument 'corin', it returns the sum of the
values (n - rise position), where n is equal to nops(perm).
- Whenever there is a conflict between the function name Perm2Rise and
another name used in the same session, use the long form
SG['Perm2Rise'].
EXAMPLES:
> with(SG):
> perm:=[3,1,4,2,6,5,7,8]:
> Perm2Rise(perm);
[2, 4, 6, 7]
> Perm2Rise(perm, 'nb');
4
> Perm2Rise(perm, 'rin');
9
> Perm2Rise(perm, 'corin');
13
SEE ALSO: Perm2Desc