cg.f 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. *DECK CG
  2. SUBROUTINE CG (NM, N, AR, AI, WR, WI, MATZ, ZR, ZI, FV1, FV2, FV3,
  3. + IERR)
  4. C***BEGIN PROLOGUE CG
  5. C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
  6. C of a complex general matrix.
  7. C***LIBRARY SLATEC (EISPACK)
  8. C***CATEGORY D4A4
  9. C***TYPE COMPLEX (RG-S, CG-C)
  10. C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
  11. C***AUTHOR Smith, B. T., et al.
  12. C***DESCRIPTION
  13. C
  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.
  18. C
  19. C On INPUT
  20. C
  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
  24. C variable.
  25. C
  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.
  28. C
  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).
  32. C
  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.
  36. C
  37. C On OUTPUT
  38. C
  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).
  42. C
  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
  46. C ZI(NM,N).
  47. C
  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
  55. C computed.
  56. C
  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).
  59. C
  60. C Questions and comments should be directed to B. S. Garbow,
  61. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  62. C ------------------------------------------------------------------
  63. 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,
  67. C 1976.
  68. C***ROUTINES CALLED CBABK2, CBAL, COMQR, COMQR2, CORTH
  69. C***REVISION HISTORY (YYMMDD)
  70. C 760101 DATE WRITTEN
  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)
  75. C***END PROLOGUE CG
  76. C
  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(*)
  80. C
  81. C***FIRST EXECUTABLE STATEMENT CG
  82. IF (N .LE. NM) GO TO 10
  83. IERR = 10 * N
  84. GO TO 50
  85. C
  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)
  91. GO TO 50
  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)
  96. 50 RETURN
  97. END