2
SUBROUTINE CG (NM, N, AR, AI, WR, WI, MATZ, ZR, ZI, FV1, FV2, FV3,
5
C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
6
C of a complex general matrix.
7
C***LIBRARY SLATEC (EISPACK)
9
C***TYPE COMPLEX (RG-S, CG-C)
10
C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
11
C***AUTHOR Smith, B. T., et al.
14
C This subroutine calls the recommended sequence of
15
C subroutines from the eigensystem subroutine package (EISPACK)
16
C to find the eigenvalues and eigenvectors (if desired)
17
C of a COMPLEX GENERAL matrix.
21
C NM must be set to the row dimension of the two-dimensional
22
C array parameters, AR, AI, ZR and ZI, as declared in the
23
C calling program dimension statement. NM is an INTEGER
26
C N is the order of the matrix A=(AR,AI). N is an INTEGER
27
C variable. N must be less than or equal to NM.
29
C AR and AI contain the real and imaginary parts, respectively,
30
C of the complex general matrix. AR and AI are two-dimensional
31
C REAL arrays, dimensioned AR(NM,N) and AI(NM,N).
33
C MATZ is an INTEGER variable set equal to zero if only
34
C eigenvalues are desired. Otherwise, it is set to any
35
C non-zero integer for both eigenvalues and eigenvectors.
39
C WR and WI contain the real and imaginary parts, respectively,
40
C of the eigenvalues. WR and WI are one-dimensional REAL
41
C arrays, dimensioned WR(N) and WI(N).
43
C ZR and ZI contain the real and imaginary parts, respectively,
44
C of the eigenvectors if MATZ is not zero. ZR and ZI are
45
C two-dimensional REAL arrays, dimensioned ZR(NM,N) and
48
C IERR is an INTEGER flag set to
49
C Zero for normal return,
50
C 10*N if N is greater than NM,
51
C J if the J-th eigenvalue has not been
52
C determined after a total of 30 iterations.
53
C The eigenvalues should be correct for indices
54
C IERR+1, IERR+2, ..., N, but no eigenvectors are
57
C FV1, FV2, and FV3 are one-dimensional REAL arrays used for
58
C temporary storage, dimensioned FV1(N), FV2(N), and FV3(N).
60
C Questions and comments should be directed to B. S. Garbow,
61
C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
62
C ------------------------------------------------------------------
64
C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
65
C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
66
C system Routines - EISPACK Guide, Springer-Verlag,
68
C***ROUTINES CALLED CBABK2, CBAL, COMQR, COMQR2, CORTH
69
C***REVISION HISTORY (YYMMDD)
71
C 890831 Modified array declarations. (WRB)
72
C 890831 REVISION DATE from Version 3.2
73
C 891214 Prologue converted to Version 4.0 format. (BAB)
74
C 920501 Reformatted the REFERENCES section. (WRB)
77
INTEGER N,NM,IS1,IS2,IERR,MATZ
78
REAL AR(NM,*),AI(NM,*),WR(*),WI(*),ZR(NM,*),ZI(NM,*)
79
REAL FV1(*),FV2(*),FV3(*)
81
C***FIRST EXECUTABLE STATEMENT CG
82
IF (N .LE. NM) GO TO 10
86
10 CALL CBAL(NM,N,AR,AI,IS1,IS2,FV1)
87
CALL CORTH(NM,N,IS1,IS2,AR,AI,FV2,FV3)
88
IF (MATZ .NE. 0) GO TO 20
89
C .......... FIND EIGENVALUES ONLY ..........
90
CALL COMQR(NM,N,IS1,IS2,AR,AI,WR,WI,IERR)
92
C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
93
20 CALL COMQR2(NM,N,IS1,IS2,FV2,FV3,AR,AI,WR,WI,ZR,ZI,IERR)
94
IF (IERR .NE. 0) GO TO 50
95
CALL CBABK2(NM,N,IS1,IS2,FV1,N,ZR,ZI)