Permute vector

F_SPERMUTE/F_DPERMUTE/F_CPERMUTE/F_ZPERMUTE

Name F_SPERMUTE/F_DPERMUTE/F_CPERMUTE/F_ZPERMUTE Permute vector

Purpose F_xPERMUTE permutes the entries of a vector x according to the permutation vector p. If n is less than or equal to zero, the routine returns immediately.

An n-by-npermutation matrix P is represented as a product of at most

n interchange permutations. An interchange permutation E is a permutation obtained by swapping two rows of the identity matrix. An efficient way to represent a general permutation matrix P is with an integer vector p of length n. In other words, P = En...E1 and each Ei is the identity with rows i and pi interchanged:

For i = n to 1 and incp < 0, x(i) ↔ x( p(i))

For i = 1 to n and incp > 0, x(i) ↔ x( p(i))

Usage

VECLIB:

 

 

INTEGER*4

INCP, INCX, N

 

INTEGER

P( * )

 

REAL*4

X( * )

 

SUBROUTINE F_SPERMUTE (N, P, INCP, X, INCX)

 

INTEGER*4

INCP, INCX, N

 

INTEGER

P( * )

 

REAL*8

X( * )

 

SUBROUTINE F_DPERMUTE (N, P, INCP, X, INCX)

 

INTEGER*4

INCP, INCX, N

 

INTEGER

P( * )

 

COMPLEX*8

X( * )

 

SUBROUTINE F_CPERMUTE (N, P, INCP, X, INCX)

 

INTEGER*4

INCP, INCX, N

 

INTEGER

P( * )

 

COMPLEX*16

X( * )

SUBROUTINE F_ZPERMUTE (N, P, INCP, X, INCX)

VECLIB8:

INTEGER*8

INCP, INCX, N

INTEGER

P( * )

REAL*4

X( * )

SUBROUTINE F_SPERMUTE (N, P, INCP, X, INCX)

Chapter 2 Basic Vector Operations 187