rg.f 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. *DECK RG
  2. SUBROUTINE RG (NM, N, A, WR, WI, MATZ, Z, IV1, FV1, IERR)
  3. C***BEGIN PROLOGUE RG
  4. C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
  5. C of a real general matrix.
  6. C***LIBRARY SLATEC (EISPACK)
  7. C***CATEGORY D4A2
  8. C***TYPE SINGLE PRECISION (RG-S, CG-C)
  9. C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
  10. C***AUTHOR Smith, B. T., et al.
  11. C***DESCRIPTION
  12. C
  13. C This subroutine calls the recommended sequence of
  14. C subroutines from the eigensystem subroutine package (EISPACK)
  15. C To find the eigenvalues and eigenvectors (if desired)
  16. C of a REAL GENERAL matrix.
  17. C
  18. C On Input
  19. C
  20. C NM must be set to the row dimension of the two-dimensional
  21. C array parameters, A and Z, as declared in the calling
  22. C program dimension statement. NM is an INTEGER variable.
  23. C
  24. C N is the order of the matrix A. N is an INTEGER variable.
  25. C N must be less than or equal to NM.
  26. C
  27. C A contains the real general matrix. A is a two-dimensional
  28. C REAL array, dimensioned A(NM,N).
  29. C
  30. C MATZ is an INTEGER variable set equal to zero if only
  31. C eigenvalues are desired. Otherwise, it is set to any
  32. C non-zero integer for both eigenvalues and eigenvectors.
  33. C
  34. C On Output
  35. C
  36. C A has been destroyed.
  37. C
  38. C WR and WI contain the real and imaginary parts, respectively,
  39. C of the eigenvalues. The eigenvalues are unordered except
  40. C that complex conjugate pairs of eigenvalues appear consecu-
  41. C tively with the eigenvalue having the positive imaginary part
  42. C first. If an error exit is made, the eigenvalues should be
  43. C correct for indices IERR+1, IERR+2, ..., N. WR and WI are
  44. C one-dimensional REAL arrays, dimensioned WR(N) and WI(N).
  45. C
  46. C Z contains the real and imaginary parts of the eigenvectors
  47. C if MATZ is not zero. If the J-th eigenvalue is real, the
  48. C J-th column of Z contains its eigenvector. If the J-th
  49. C eigenvalue is complex with positive imaginary part, the
  50. C J-th and (J+1)-th columns of Z contain the real and
  51. C imaginary parts of its eigenvector. The conjugate of this
  52. C vector is the eigenvector for the conjugate eigenvalue.
  53. C Z is a two-dimensional REAL array, dimensioned Z(NM,N).
  54. C
  55. C IERR is an INTEGER flag set to
  56. C Zero for normal return,
  57. C 10*N if N is greater than NM,
  58. C J if the J-th eigenvalue has not been
  59. C determined after a total of 30 iterations.
  60. C The eigenvalues should be correct for indices
  61. C IERR+1, IERR+2, ..., N, but no eigenvectors are
  62. C computed.
  63. C
  64. C IV1 and FV1 are one-dimensional temporary storage arrays of
  65. C dimension N. IV1 is of type INTEGER and FV1 of type REAL.
  66. C
  67. C Questions and comments should be directed to B. S. Garbow,
  68. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  69. C ------------------------------------------------------------------
  70. C
  71. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  72. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  73. C system Routines - EISPACK Guide, Springer-Verlag,
  74. C 1976.
  75. C***ROUTINES CALLED BALANC, BALBAK, ELMHES, ELTRAN, HQR, HQR2
  76. C***REVISION HISTORY (YYMMDD)
  77. C 760101 DATE WRITTEN
  78. C 890831 Modified array declarations. (WRB)
  79. C 890831 REVISION DATE from Version 3.2
  80. C 891214 Prologue converted to Version 4.0 format. (BAB)
  81. C 920501 Reformatted the REFERENCES section. (WRB)
  82. C 921103 Corrected description of IV1. (DWL, FNF and WRB)
  83. C***END PROLOGUE RG
  84. C
  85. INTEGER N,NM,IS1,IS2,IERR,MATZ
  86. REAL A(NM,*),WR(*),WI(*),Z(NM,*),FV1(*)
  87. INTEGER IV1(*)
  88. C
  89. C***FIRST EXECUTABLE STATEMENT RG
  90. IF (N .LE. NM) GO TO 10
  91. IERR = 10 * N
  92. GO TO 50
  93. C
  94. 10 CALL BALANC(NM,N,A,IS1,IS2,FV1)
  95. CALL ELMHES(NM,N,IS1,IS2,A,IV1)
  96. IF (MATZ .NE. 0) GO TO 20
  97. C .......... FIND EIGENVALUES ONLY ..........
  98. CALL HQR(NM,N,IS1,IS2,A,WR,WI,IERR)
  99. GO TO 50
  100. C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
  101. 20 CALL ELTRAN(NM,N,IS1,IS2,A,IV1,Z)
  102. CALL HQR2(NM,N,IS1,IS2,A,WR,WI,Z,IERR)
  103. IF (IERR .NE. 0) GO TO 50
  104. CALL BALBAK(NM,N,IS1,IS2,FV1,N,Z)
  105. 50 RETURN
  106. END