home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
library
/
ssp
/
matops
/
dmprc.for
< prev
next >
Wrap
Text File
|
1985-11-29
|
4KB
|
121 lines
C
C ..................................................................
C
C SUBROUTINE DMPRC
C
C PURPOSE
C TO PERMUTE THE ROWS OR COLUMNS OF A GIVEN MATRIX ACCORDING
C TO A GIVEN TRANSPOSITION VECTOR OR ITS INVERSE. (SEE THE
C DISCUSSION ON PERMUTATIONS FOR DEFINITIONS AND NOTATION.)
C
C USAGE
C CALL DMPRC(A,M,N,ITRA,INV,IROCO,IER)
C
C DESCRIPTION OF PARAMETERS
C A - GIVEN DOUBLE PRECISION M BY N MATRIX AND RESULTING
C PERMUTED MATRIX
C M - NUMBER OF ROWS OF A
C N - NUMBER OF COLUMNS OF A
C ITRA - GIVEN TRANSPOSITION VECTOR (DIMENSION M IF ROWS ARE
C PERMUTED, N IF COLUMNS ARE PERMUTED)
C INV - INPUT PARAMETER
C INV NON-ZERO - PERMUTE ACCORDING TO ITRA
C INV = 0 - PERMUTE ACCORDING TO ITRA INVERSE
C IROCO - INPUT PARAMETER
C IROCO NON-ZERO - PERMUTE THE COLUMNS OF A
C IROCO = 0 - PERMUTE THE ROWS OF A
C IER - RESULTING ERROR PARAMETER
C IER = -1 - M AND N ARE NOT BOTH POSITIVE
C IER = 0 - NO ERROR
C IER = 1 - ITRA IS NOT A TRANSPOSITION VECTOR ON
C 1,...,M IF ROWS ARE PERMUTED, 1,...,N
C IF COLUMNS ARE PERMUTED
C
C REMARKS
C (1) IF IER=-1 THERE IS NO COMPUTATION.
C (2) IF IER= 1, THEN COMPUTATION HAS BEEN UNSUCCESSFUL DUE
C TO ERROR, BUT THE MATRIX A WILL REFLECT THE ROW OR
C COLUMN INTERCHANGES PERFORMED BEFORE THE ERROR WAS
C DETECTED.
C (3) THE MATRIX A IS ASSUMED TO BE STORED COLUMNWISE.
C
C SUBROUTINES AND SUBPROGRAMS REQUIRED
C NONE
C
C METHOD
C THE ROWS OR COLUMNS ARE PERMUTED ELEMENTWISE, INTERCHANGING
C ROW OR COLUMN 1 AND ITRA(1),...,ROW OR COLUMN K AND ITRA(K)
C IN THAT ORDER IF INV=0, AND OTHERWISE INTERCHANGING ROW OR
C COLUMN K AND ITRA(K),...,ROW OR COLUMN 1 AND ITRA(1), WHERE
C K IS M OR N DEPENDING ON WHETHER WE PERMUTE ROWS OR COLUMNS.
C
C ..................................................................
C
SUBROUTINE DMPRC(A,M,N,ITRA,INV,IROCO,IER)
C
C
DIMENSION A(1),ITRA(1)
DOUBLE PRECISION A,SAVE
C
C TEST OF DIMENSIONS
IF(M)14,14,1
1 IF(N)14,14,2
C
C DETERMINE WHICH ARE TO BE PERMUTED-THE ROWS OR THE COLUMNS
2 IF(IROCO)3,4,3
C
C INITIALIZE FOR COLUMN INTERCHANGES
3 MM=M
MMM=-1
L=M
LL=N
GO TO 5
C
C INITIALIZE FOR ROW INTERCHANGES
4 MM=1
MMM=M
L=N
LL=M
C
C INITIALIZE LOOP OVER ALL ROWS OR COLUMNS
5 IA=1
ID=1
C
C TEST FOR INVERSE OPERATION
IF(INV)6,7,6
6 IA=LL
ID=-1
7 DO 12 I=1,LL
K=ITRA(IA)
IF(K-IA)8,12,9
8 IF(K)13,13,10
9 IF(LL-K)13,10,10
C
C INITIALIZE ROW OR COLUMN INTERCHANGE
10 IL=IA*MM
K=K*MM
C
C PERFORM ROW OR COLUMN INTERCHANGE
DO 11 J=1,L
SAVE=A(IL)
A(IL)=A(K)
A(K)=SAVE
K=K+MMM
11 IL=IL+MMM
C
C ADDRESS NEXT INTERCHANGE STEP
12 IA=IA+ID
C
C NORMAL EXIT
IER=0
RETURN
C
C ERROR RETURN IN CASE ITRA IS NOT A TRANSPOSITION VECTOR
13 IER=1
RETURN
C
C ERROR RETURN IN CASE OF ILLEGAL DIMENSIONS
14 IER=-1
RETURN
END