reduc2.f 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. *DECK REDUC2
  2. SUBROUTINE REDUC2 (NM, N, A, B, DL, IERR)
  3. C***BEGIN PROLOGUE REDUC2
  4. C***PURPOSE Reduce a certain generalized symmetric eigenproblem to a
  5. C standard symmetric eigenproblem using Cholesky
  6. C factorization.
  7. C***LIBRARY SLATEC (EISPACK)
  8. C***CATEGORY D4C1C
  9. C***TYPE SINGLE PRECISION (REDUC2-S)
  10. C***KEYWORDS EIGENVALUES, EIGENVECTORS, EISPACK
  11. C***AUTHOR Smith, B. T., et al.
  12. C***DESCRIPTION
  13. C
  14. C This subroutine is a translation of the ALGOL procedure REDUC2,
  15. C NUM. MATH. 11, 99-110(1968) by Martin and Wilkinson.
  16. C HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 303-314(1971).
  17. C
  18. C This subroutine reduces the generalized SYMMETRIC eigenproblems
  19. C ABx=(LAMBDA)x OR BAy=(LAMBDA)y, where B is POSITIVE DEFINITE,
  20. C to the standard symmetric eigenproblem using the Cholesky
  21. C factorization of B.
  22. C
  23. C On Input
  24. C
  25. C NM must be set to the row dimension of the two-dimensional
  26. C array parameters, A and B, as declared in the calling
  27. C program dimension statement. NM is an INTEGER variable.
  28. C
  29. C N is the order of the matrices A and B. If the Cholesky
  30. C factor L of B is already available, N should be prefixed
  31. C with a minus sign. N is an INTEGER variable.
  32. C
  33. C A and B contain the real symmetric input matrices. Only
  34. C the full upper triangles of the matrices need be supplied.
  35. C If N is negative, the strict lower triangle of B contains,
  36. C instead, the strict lower triangle of its Cholesky factor L.
  37. C A and B are two-dimensional REAL arrays, dimensioned A(NM,N)
  38. C and B(NM,N).
  39. C
  40. C DL contains, if N is negative, the diagonal elements of L.
  41. C DL is a one-dimensional REAL array, dimensioned DL(N).
  42. C
  43. C On Output
  44. C
  45. C A contains in its full lower triangle the full lower triangle
  46. C of the symmetric matrix derived from the reduction to the
  47. C standard form. The strict upper triangle of A is unaltered.
  48. C
  49. C B contains in its strict lower triangle the strict lower
  50. C triangle of its Cholesky factor L. The full upper triangle
  51. C of B is unaltered.
  52. C
  53. C DL contains the diagonal elements of L.
  54. C
  55. C IERR is an INTEGER flag set to
  56. C Zero for normal return,
  57. C 7*N+1 if B is not positive definite.
  58. C
  59. C Questions and comments should be directed to B. S. Garbow,
  60. C APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
  61. C ------------------------------------------------------------------
  62. C
  63. C***REFERENCES B. T. Smith, J. M. Boyle, J. J. Dongarra, B. S. Garbow,
  64. C Y. Ikebe, V. C. Klema and C. B. Moler, Matrix Eigen-
  65. C system Routines - EISPACK Guide, Springer-Verlag,
  66. C 1976.
  67. C***ROUTINES CALLED (NONE)
  68. C***REVISION HISTORY (YYMMDD)
  69. C 760101 DATE WRITTEN
  70. C 890531 Changed all specific intrinsics to generic. (WRB)
  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 REDUC2
  76. C
  77. INTEGER I,J,K,N,I1,J1,NM,NN,IERR
  78. REAL A(NM,*),B(NM,*),DL(*)
  79. REAL X,Y
  80. C
  81. C***FIRST EXECUTABLE STATEMENT REDUC2
  82. IERR = 0
  83. NN = ABS(N)
  84. IF (N .LT. 0) GO TO 100
  85. C .......... FORM L IN THE ARRAYS B AND DL ..........
  86. DO 80 I = 1, N
  87. I1 = I - 1
  88. C
  89. DO 80 J = I, N
  90. X = B(I,J)
  91. IF (I .EQ. 1) GO TO 40
  92. C
  93. DO 20 K = 1, I1
  94. 20 X = X - B(I,K) * B(J,K)
  95. C
  96. 40 IF (J .NE. I) GO TO 60
  97. IF (X .LE. 0.0E0) GO TO 1000
  98. Y = SQRT(X)
  99. DL(I) = Y
  100. GO TO 80
  101. 60 B(J,I) = X / Y
  102. 80 CONTINUE
  103. C .......... FORM THE LOWER TRIANGLE OF A*L
  104. C IN THE LOWER TRIANGLE OF THE ARRAY A ..........
  105. 100 DO 200 I = 1, NN
  106. I1 = I + 1
  107. C
  108. DO 200 J = 1, I
  109. X = A(J,I) * DL(J)
  110. IF (J .EQ. I) GO TO 140
  111. J1 = J + 1
  112. C
  113. DO 120 K = J1, I
  114. 120 X = X + A(K,I) * B(K,J)
  115. C
  116. 140 IF (I .EQ. NN) GO TO 180
  117. C
  118. DO 160 K = I1, NN
  119. 160 X = X + A(I,K) * B(K,J)
  120. C
  121. 180 A(I,J) = X
  122. 200 CONTINUE
  123. C .......... PRE-MULTIPLY BY TRANSPOSE(L) AND OVERWRITE ..........
  124. DO 300 I = 1, NN
  125. I1 = I + 1
  126. Y = DL(I)
  127. C
  128. DO 300 J = 1, I
  129. X = Y * A(I,J)
  130. IF (I .EQ. NN) GO TO 280
  131. C
  132. DO 260 K = I1, NN
  133. 260 X = X + A(K,J) * B(K,I)
  134. C
  135. 280 A(I,J) = X
  136. 300 CONTINUE
  137. C
  138. GO TO 1001
  139. C .......... SET ERROR -- B IS NOT POSITIVE DEFINITE ..........
  140. 1000 IERR = 7 * N + 1
  141. 1001 RETURN
  142. END