PDA_IPERM

Forms the inverse of a permutation

Description:

This routine inverts a permutation in place. It can be used to transform an index vector (from a sort) into a rank vector and vice versa.

Invocation

CALL PDA_IPERM( N, X )

Arguments

N = INTEGER (Read)
Number of elements.
X( N ) = _INTEGER (Read and Write)
The permutation. On exit this contains the inverse.

Notes:

The permutation must consist of positive integers. The permutation inverse Y(X(I))=I for I=1,N can be formed trivially with 2*N arrays.

References

The Art of Computer Programming, Fundamental Algorithms Vol 1, by Donald E. Knuth (Addison-Wesley).

Timing

Proportional to N.