rsp.f 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. *DECK RSP
  2. SUBROUTINE RSP (NM, N, NV, A, W, MATZ, Z, FV1, FV2, IERR)
  3. C***BEGIN PROLOGUE RSP
  4. C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
  5. C of a real symmetric matrix packed into a one dimensional
  6. C array.
  7. C***LIBRARY SLATEC (EISPACK)
  8. C***CATEGORY D4A1
  9. C***TYPE SINGLE PRECISION (RSP-S)
  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 REAL SYMMETRIC PACKED 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 parameter, Z, as declared in the calling program
  23. C dimension statement. NM is an INTEGER variable.
  24. C
  25. C N is the order of the matrix A. N is an INTEGER variable.
  26. C N must be less than or equal to NM.
  27. C
  28. C NV is an INTEGER variable set equal to the dimension of the
  29. C array A as specified in the calling program. NV must not
  30. C be less than N*(N+1)/2.
  31. C
  32. C A contains the lower triangle, stored row-wise, of the real
  33. C symmetric packed matrix. A is a one-dimensional REAL
  34. C array, dimensioned A(NV).
  35. C
  36. C MATZ is an INTEGER variable set equal to zero if only
  37. C eigenvalues are desired. Otherwise, it is set to any
  38. C non-zero integer for both eigenvalues and eigenvectors.
  39. C
  40. C On Output
  41. C
  42. C A has been destroyed.
  43. C
  44. C W contains the eigenvalues in ascending order. W is a
  45. C one-dimensional REAL array, dimensioned W(N).
  46. C
  47. C Z contains the eigenvectors if MATZ is not zero. The eigen-
  48. C vectors are orthonormal. Z is a two-dimensional REAL array,
  49. C dimensioned Z(NM,N).
  50. C
  51. C IERR is an INTEGER flag set to
  52. C Zero for normal return,
  53. C 10*N if N is greater than NM,
  54. C 20*N if NV is less than N*(N+1)/2,
  55. C J if the J-th eigenvalue has not been
  56. C determined after 30 iterations.
  57. C The eigenvalues and eigenvectors in the W and Z
  58. C arrays should be correct for indices
  59. C 1, 2, ..., IERR-1.
  60. C
  61. C FV1 and FV2 are one-dimensional REAL arrays used for temporary
  62. C storage, dimensioned FV1(N) and FV2(N).
  63. C
  64. C Questions and comments should be directed to B. S. Garbow,
  65. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  66. C ------------------------------------------------------------------
  67. C
  68. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  69. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  70. C system Routines - EISPACK Guide, Springer-Verlag,
  71. C 1976.
  72. C***ROUTINES CALLED TQL2, TQLRAT, TRBAK3, TRED3
  73. C***REVISION HISTORY (YYMMDD)
  74. C 760101 DATE WRITTEN
  75. C 890831 Modified array declarations. (WRB)
  76. C 890831 REVISION DATE from Version 3.2
  77. C 891214 Prologue converted to Version 4.0 format. (BAB)
  78. C 920501 Reformatted the REFERENCES section. (WRB)
  79. C***END PROLOGUE RSP
  80. C
  81. INTEGER I,J,N,NM,NV,IERR,MATZ
  82. REAL A(*),W(*),Z(NM,*),FV1(*),FV2(*)
  83. C
  84. C***FIRST EXECUTABLE STATEMENT RSP
  85. IF (N .LE. NM) GO TO 5
  86. IERR = 10 * N
  87. GO TO 50
  88. 5 IF (NV .GE. (N * (N + 1)) / 2) GO TO 10
  89. IERR = 20 * N
  90. GO TO 50
  91. C
  92. 10 CALL TRED3(N,NV,A,W,FV1,FV2)
  93. IF (MATZ .NE. 0) GO TO 20
  94. C .......... FIND EIGENVALUES ONLY ..........
  95. CALL TQLRAT(N,W,FV2,IERR)
  96. GO TO 50
  97. C .......... FIND BOTH EIGENVALUES AND EIGENVECTORS ..........
  98. 20 DO 40 I = 1, N
  99. C
  100. DO 30 J = 1, N
  101. Z(J,I) = 0.0E0
  102. 30 CONTINUE
  103. C
  104. Z(I,I) = 1.0E0
  105. 40 CONTINUE
  106. C
  107. CALL TQL2(NM,N,W,FV1,Z,IERR)
  108. IF (IERR .NE. 0) GO TO 50
  109. CALL TRBAK3(NM,N,NV,A,N,Z)
  110. 50 RETURN
  111. END