PermutationToRightInversion - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Iterator[Inversion]

  

PermutationToRightInversion

  

convert permutation to right inversion table

 

Calling Sequence

Parameters

Description

Examples

References

Compatibility

Calling Sequence

PermutationToRightInversion(a,c)

Parameters

a

-

{list,rtable}; permutation of integers starting at one

c

-

rtable; (optional) storage for inversion table

Description

• 

PermutationToRightInversion returns the inversion table of a permutation, a, of the integers 1 to n.

• 

The a parameter is a permutation of the consecutive integers from 1 to n; it may be a list or a one-dimensional rtable indexed from one.

• 

The optional c parameter is a one-dimensional rtable indexed from 1 with at least n slots. If provided, it is used to store the inversion table.

• 

The output is an Array, c, indexed from 1 to n, with cj the number of elements to the right of j in a that are less than j.

Examples

withIterator:-Inversion:

PermutationToRightInversion1,2,3,4

0000

(1)

PermutationToRightInversion4,3,2,1

0123

(2)

Use an existing vector to store the computed inversion table. Doing so reduces memory allocation when converting permutations to inversion tables in a loop.

cVector4:

PermutationToRightInversion4,3,2,1,c:

c

0123

(3)

References

  

Knuth, Donald Ervin. The Art of Computer Programming, volume 3, 2nd ed. sorting and searching, sec. 5.1.1, inversions, pp. 11-17 and exercise 7, p. 18.

Compatibility

• 

The Iterator[Inversion][PermutationToRightInversion] command was introduced in Maple 2016.

• 

For more information on Maple 2016 changes, see Updates in Maple 2016.

See Also

Iterator

Iterator[Inversion]