home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
library
/
ssp
/
mateigen
/
nroot.for
< prev
Wrap
Text File
|
1985-11-29
|
4KB
|
144 lines
C
C ..................................................................
C
C SUBROUTINE NROOT
C
C PURPOSE
C COMPUTE EIGENVALUES AND EIGENVECTORS OF A REAL NONSYMMETRIC
C MATRIX OF THE FORM B-INVERSE TIMES A. THIS SUBROUTINE IS
C NORMALLY CALLED BY SUBROUTINE CANOR IN PERFORMING A
C CANONICAL CORRELATION ANALYSIS.
C
C USAGE
C CALL NROOT (M,A,B,XL,X)
C
C DESCRIPTION OF PARAMETERS
C M - ORDER OF SQUARE MATRICES A, B, AND X.
C A - INPUT MATRIX (M X M).
C B - INPUT MATRIX (M X M).
C XL - OUTPUT VECTOR OF LENGTH M CONTAINING EIGENVALUES OF
C B-INVERSE TIMES A.
C X - OUTPUT MATRIX (M X M) CONTAINING EIGENVECTORS COLUMN-
C WISE.
C
C REMARKS
C NONE
C
C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C EIGEN
C
C METHOD
C REFER TO W. W. COOLEY AND P. R. LOHNES, 'MULTIVARIATE PRO-
C CEDURES FOR THE BEHAVIORAL SCIENCES', JOHN WILEY AND SONS,
C 1962, CHAPTER 3.
C
C ..................................................................
C
SUBROUTINE NROOT (M,A,B,XL,X)
DIMENSION A(1),B(1),XL(1),X(1)
C
C ...............................................................
C
C IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE
C C IN COLUMN 1 SHOULD BE REMOVED FROM THE DOUBLE PRECISION
C STATEMENT WHICH FOLLOWS.
C
C DOUBLE PRECISION A,B,XL,X,SUMV
C
C THE C MUST ALSO BE REMOVED FROM DOUBLE PRECISION STATEMENTS
C APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS
C ROUTINE.
C
C THE DOUBLE PRECISION VERSION OF THIS SUBROUTINE MUST ALSO
C CONTAIN DOUBLE PRECISION FORTRAN FUNCTIONS. SQRT IN STATEMENTS
C 110 AND 175 MUST BE CHANGED TO DSQRT. ABS IN STATEMENT 110
C MUST BE CHANGED TO DABS.
C
C ...............................................................
C
C COMPUTE EIGENVALUES AND EIGENVECTORS OF B
C
K=1
DO 100 J=2,M
L=M*(J-1)
DO 100 I=1,J
L=L+1
K=K+1
100 B(K)=B(L)
C
C THE MATRIX B IS A REAL SYMMETRIC MATRIX.
C
MV=0
CALL EIGEN (B,X,M,MV)
C
C FORM RECIPROCALS OF SQUARE ROOT OF EIGENVALUES. THE RESULTS
C ARE PREMULTIPLIED BY THE ASSOCIATED EIGENVECTORS.
C
L=0
DO 110 J=1,M
L=L+J
110 XL(J)=1.0/ SQRT( ABS(B(L)))
K=0
DO 115 J=1,M
DO 115 I=1,M
K=K+1
115 B(K)=X(K)*XL(J)
C
C FORM (B**(-1/2))PRIME * A * (B**(-1/2))
C
DO 120 I=1,M
N2=0
DO 120 J=1,M
N1=M*(I-1)
L=M*(J-1)+I
X(L)=0.0
DO 120 K=1,M
N1=N1+1
N2=N2+1
120 X(L)=X(L)+B(N1)*A(N2)
L=0
DO 130 J=1,M
DO 130 I=1,J
N1=I-M
N2=M*(J-1)
L=L+1
A(L)=0.0
DO 130 K=1,M
N1=N1+M
N2=N2+1
130 A(L)=A(L)+X(N1)*B(N2)
C
C COMPUTE EIGENVALUES AND EIGENVECTORS OF A
C
CALL EIGEN (A,X,M,MV)
L=0
DO 140 I=1,M
L=L+I
140 XL(I)=A(L)
C
C COMPUTE THE NORMALIZED EIGENVECTORS
C
DO 150 I=1,M
N2=0
DO 150 J=1,M
N1=I-M
L=M*(J-1)+I
A(L)=0.0
DO 150 K=1,M
N1=N1+M
N2=N2+1
150 A(L)=A(L)+B(N1)*X(N2)
L=0
K=0
DO 180 J=1,M
SUMV=0.0
DO 170 I=1,M
L=L+1
170 SUMV=SUMV+A(L)*A(L)
175 SUMV= SQRT(SUMV)
DO 180 I=1,M
K=K+1
180 X(K)=A(K)/SUMV
RETURN
END