ch.f 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. *DECK CH
  2. SUBROUTINE CH (NM, N, AR, AI, W, MATZ, ZR, ZI, FV1, FV2, FM1,
  3. + IERR)
  4. C***BEGIN PROLOGUE CH
  5. C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
  6. C of a complex Hermitian matrix.
  7. C***LIBRARY SLATEC (EISPACK)
  8. C***CATEGORY D4A3
  9. C***TYPE COMPLEX (RS-S, CH-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 HERMITIAN 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 Hermitian matrix. AR and AI are
  31. C two-dimensional REAL arrays, dimensioned AR(NM,N)
  32. C and AI(NM,N).
  33. C
  34. C MATZ is an INTEGER variable set equal to zero if only
  35. C eigenvalues are desired. Otherwise, it is set to any
  36. C non-zero integer for both eigenvalues and eigenvectors.
  37. C
  38. C On OUTPUT
  39. C
  40. C W contains the eigenvalues in ascending order.
  41. C W is a one-dimensional REAL array, dimensioned W(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 1, 2, ..., IERR-1, but no eigenvectors are
  55. C computed.
  56. C
  57. C FV1 and FV2 are one-dimensional REAL arrays used for
  58. C temporary storage, dimensioned FV1(N) and FV2(N).
  59. C
  60. C FM1 is a two-dimensional REAL array used for temporary
  61. C storage, dimensioned FM1(2,N).
  62. C
  63. C Questions and comments should be directed to B. S. Garbow,
  64. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  65. C ------------------------------------------------------------------
  66. C
  67. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  68. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  69. C system Routines - EISPACK Guide, Springer-Verlag,
  70. C 1976.
  71. C***ROUTINES CALLED HTRIBK, HTRIDI, TQL2, TQLRAT
  72. C***REVISION HISTORY (YYMMDD)
  73. C 760101 DATE WRITTEN
  74. C 890831 Modified array declarations. (WRB)
  75. C 890831 REVISION DATE from Version 3.2
  76. C 891214 Prologue converted to Version 4.0 format. (BAB)
  77. C 920501 Reformatted the REFERENCES section. (WRB)
  78. C***END PROLOGUE CH
  79. C
  80. INTEGER I,J,N,NM,IERR,MATZ
  81. REAL AR(NM,*),AI(NM,*),W(*),ZR(NM,*),ZI(NM,*)
  82. REAL FV1(*),FV2(*),FM1(2,*)
  83. C
  84. C***FIRST EXECUTABLE STATEMENT CH
  85. IF (N .LE. NM) GO TO 10
  86. IERR = 10 * N
  87. GO TO 50
  88. C
  89. 10 CALL HTRIDI(NM,N,AR,AI,W,FV1,FV2,FM1)
  90. IF (MATZ .NE. 0) GO TO 20
  91. C .......... FIND EIGENVALUES ONLY ..........
  92. CALL TQLRAT(N,W,FV2,IERR)
  93. GO TO 50
  94. C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
  95. 20 DO 40 I = 1, N
  96. C
  97. DO 30 J = 1, N
  98. ZR(J,I) = 0.0E0
  99. 30 CONTINUE
  100. C
  101. ZR(I,I) = 1.0E0
  102. 40 CONTINUE
  103. C
  104. CALL TQL2(NM,N,W,FV1,ZR,IERR)
  105. IF (IERR .NE. 0) GO TO 50
  106. CALL HTRIBK(NM,N,AR,AI,FM1,N,ZR,ZI)
  107. 50 RETURN
  108. END