Robert,
This excerpt from the .texi file describes the functions I propose to add. These are not already in Maxima.
Hunter
@deffn {Function} permutationp (@var{permutation})
Returns true if the input is a list containing the integers from 1 to length(@var{permutation})
exactly once.
@c ===beg===
@c permutationp([2,3,1]);
@c permutationp([a,b,c]);
@c ===end===
@example
(%i1) permutationp([2,3,1]);
(%o1) true
(%i2) permutationp([2,3,1,1]);
(%o2) false
(%i3) permutationp([a,b,c]);
(%o3) false
@end example
@opencatbox
@category{Permutations package,Predicates}
@closecatbox
@end deffn
@deffn {Function} inverse_permutation (@var{permutation})
For a permutation of the integers from 1 to length(@var{permutation}),
inverse_permutation returns the permutation which is the inverse of @var{permutation}.
in the lexicographic ordering.
@c ===beg===
@c inverse_permutation([2,3,1]);
@c ===end===
@example
(%i1) inverse_permutation([2,3,1]);
(%o1) [3, 1, 2]
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@deffn {Function} minimum_change_permutations (@var{list})
Lists all permutations of list @var{list} in which each permutation differs
from the one before by only one transposition.
@c ===beg===
@c minimum_change_permutations([1,2,3]);
@c ===end===
@example
(%i1) minimum_change_permutations([1,2,3]);
(%o1) [[1, 2, 3], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [3, 2, 1]]
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@deffn {Function} rank_permutation (@var{permutation})
For a permutation of the integers from 1 to length(@var{permutation}), rank_permutation
returns the position of permutation @var{permutation} in the lexicographic ordering, where
first element is position zero.
@c ===beg===
@c permutations([1,2,3]);
@c rank_permutation([1,2,3]);
@c rank_permutation([3,2,1]);
@c ===end===
@example
(%i1) permutations([1,2,3]);
(%o1) {[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]}
(%i2) rank_permutation([1,2,3]);
(%o2) 0
(%i3) rank_permutation([3,2,1]);
(%o3) 5
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@deffn {Function} inversion_vector(p) (@var{permutation})
For a permutation of the integers from 1 to length(@var{permutation}), inversion_vector
computes the vector of inversions for the permutation.
@c ===beg===
@c inversion_vector([1,4,3,2]);
@c ===end===
@example
(%i1) inversion_vector([1,4,3,2]);
(%o1) [0,2,1]
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@deffn {Function} from_inversion_vector(p) (@var{list})
For a vector of inversions for a permutation, produces a permutation of the integers from 1 to length(@var{permutation}).
@c ===beg===
@c from_inversion_vector([0,2,1]);
@c ===end===
@example
(%i1) from_inversion_vector([0,2,1]);
(%o1) [1,4,3,2]
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@deffn {Function} inversions(p) (@var{permutation})
For a permutation of the integers from 1 to length(@var{permutation}), inversions
computes the vector of inversions for the permutation.
@c ===beg===
@c inversions([1,4,3,2]);
@c ===end===
@example
(%i1) inversions([1,4,3,2]);
(%o1) 3
@end example
@opencatbox
@category{Permutations package}
@closecatbox
@end deffn
@bye