sspev.f 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. *DECK SSPEV
  2. SUBROUTINE SSPEV (A, N, E, V, LDV, WORK, JOB, INFO)
  3. C***BEGIN PROLOGUE SSPEV
  4. C***PURPOSE Compute the eigenvalues and, optionally, the eigenvectors
  5. C of a real symmetric matrix stored in packed form.
  6. C***LIBRARY SLATEC (EISPACK)
  7. C***CATEGORY D4A1
  8. C***TYPE SINGLE PRECISION (SSPEV-S)
  9. C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK, PACKED, SYMMETRIC
  10. C***AUTHOR Kahaner, D. K., (NBS)
  11. C Moler, C. B., (U. of New Mexico)
  12. C Stewart, G. W., (U. of Maryland)
  13. C***DESCRIPTION
  14. C
  15. C Abstract
  16. C SSPEV computes the eigenvalues and, optionally, the eigenvectors
  17. C of a real symmetric matrix stored in packed form.
  18. C
  19. C Call Sequence Parameters-
  20. C (The values of parameters marked with * (star) will be changed
  21. C by SSPEV.)
  22. C
  23. C A* REAL(N*(N+1)/2)
  24. C real symmetric packed input matrix. Contains upper
  25. C triangle and diagonal of A, by column (elements
  26. C 11, 12, 22, 13, 23, 33, ...).
  27. C
  28. C N INTEGER
  29. C set by the user to
  30. C the order of the matrix A.
  31. C
  32. C E* REAL(N)
  33. C on return from SSPEV, E contains the eigenvalues of A.
  34. C See also INFO below.
  35. C
  36. C V* REAL(LDV,N)
  37. C on return from SSPEV, if the user has set JOB
  38. C = 0 V is not referenced.
  39. C = nonzero the N eigenvectors of A are stored in the
  40. C first N columns of V. See also INFO below.
  41. C
  42. C LDV INTEGER
  43. C set by the user to
  44. C the leading dimension of the array V if JOB is also
  45. C set nonzero. In that case, N must be .LE. LDV.
  46. C If JOB is set to zero, LDV is not referenced.
  47. C
  48. C WORK* REAL(2N)
  49. C temporary storage vector. Contents changed by SSPEV.
  50. C
  51. C JOB INTEGER
  52. C set by the user to
  53. C = 0 eigenvalues only to be calculated by SSPEV.
  54. C Neither V nor LDV are referenced.
  55. C = nonzero eigenvalues and vectors to be calculated.
  56. C In this case, A & V must be distinct arrays.
  57. C Also, if LDA .GT. LDV, SSPEV changes all the
  58. C elements of A thru column N. If LDA < LDV,
  59. C SSPEV changes all the elements of V through
  60. C column N. If LDA=LDV, only A(I,J) and V(I,
  61. C J) for I,J = 1,...,N are changed by SSPEV.
  62. C
  63. C INFO* INTEGER
  64. C on return from SSPEV, the value of INFO is
  65. C = 0 for normal return.
  66. C = K if the eigenvalue iteration fails to converge.
  67. C Eigenvalues and vectors 1 through K-1 are correct.
  68. C
  69. C
  70. C Error Messages-
  71. C No. 1 recoverable N is greater than LDV and JOB is nonzero
  72. C No. 2 recoverable N is less than one
  73. C
  74. C***REFERENCES (NONE)
  75. C***ROUTINES CALLED IMTQL2, TQLRAT, TRBAK3, TRED3, XERMSG
  76. C***REVISION HISTORY (YYMMDD)
  77. C 800808 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 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  82. C 900326 Removed duplicate information from DESCRIPTION section.
  83. C (WRB)
  84. C***END PROLOGUE SSPEV
  85. INTEGER I,INFO,J,LDV,M,N
  86. REAL A(*),E(*),V(LDV,*),WORK(*)
  87. C***FIRST EXECUTABLE STATEMENT SSPEV
  88. IF (N .GT. LDV) CALL XERMSG ('SLATEC', 'SSPEV', 'N .GT. LDV.',
  89. + 1, 1)
  90. IF(N .GT. LDV) RETURN
  91. IF (N .LT. 1) CALL XERMSG ('SLATEC', 'SSPEV', 'N .LT. 1', 2, 1)
  92. IF(N .LT. 1) RETURN
  93. C
  94. C CHECK N=1 CASE
  95. C
  96. E(1) = A(1)
  97. INFO = 0
  98. IF(N .EQ. 1) RETURN
  99. C
  100. IF(JOB.NE.0) GO TO 20
  101. C
  102. C EIGENVALUES ONLY
  103. C
  104. CALL TRED3(N,1,A,E,WORK(1),WORK(N+1))
  105. CALL TQLRAT(N,E,WORK(N+1),INFO)
  106. RETURN
  107. C
  108. C EIGENVALUES AND EIGENVECTORS
  109. C
  110. 20 CALL TRED3(N,1,A,E,WORK(1),WORK(1))
  111. DO 30 I = 1, N
  112. DO 25 J = 1, N
  113. 25 V(I,J) = 0.
  114. 30 V(I,I) = 1.
  115. CALL IMTQL2(LDV,N,E,WORK,V,INFO)
  116. M = N
  117. IF(INFO .NE. 0) M = INFO - 1
  118. CALL TRBAK3(LDV,N,1,A,M,V)
  119. RETURN
  120. END