reduc.f 4.6 KB

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