cgbfa.f 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. *DECK CGBFA
  2. SUBROUTINE CGBFA (ABD, LDA, N, ML, MU, IPVT, INFO)
  3. C***BEGIN PROLOGUE CGBFA
  4. C***PURPOSE Factor a band matrix using Gaussian elimination.
  5. C***LIBRARY SLATEC (LINPACK)
  6. C***CATEGORY D2C2
  7. C***TYPE COMPLEX (SGBFA-S, DGBFA-D, CGBFA-C)
  8. C***KEYWORDS BANDED, LINEAR ALGEBRA, LINPACK, MATRIX FACTORIZATION
  9. C***AUTHOR Moler, C. B., (U. of New Mexico)
  10. C***DESCRIPTION
  11. C
  12. C CGBFA factors a complex band matrix by elimination.
  13. C
  14. C CGBFA is usually called by CGBCO, but it can be called
  15. C directly with a saving in time if RCOND is not needed.
  16. C
  17. C On Entry
  18. C
  19. C ABD COMPLEX(LDA, N)
  20. C contains the matrix in band storage. The columns
  21. C of the matrix are stored in the columns of ABD and
  22. C the diagonals of the matrix are stored in rows
  23. C ML+1 through 2*ML+MU+1 of ABD .
  24. C See the comments below for details.
  25. C
  26. C LDA INTEGER
  27. C the leading dimension of the array ABD .
  28. C LDA must be .GE. 2*ML + MU + 1 .
  29. C
  30. C N INTEGER
  31. C the order of the original matrix.
  32. C
  33. C ML INTEGER
  34. C number of diagonals below the main diagonal.
  35. C 0 .LE. ML .LT. N .
  36. C
  37. C MU INTEGER
  38. C number of diagonals above the main diagonal.
  39. C 0 .LE. MU .LT. N .
  40. C More efficient if ML .LE. MU .
  41. C On Return
  42. C
  43. C ABD an upper triangular matrix in band storage and
  44. C the multipliers which were used to obtain it.
  45. C The factorization can be written A = L*U where
  46. C L is a product of permutation and unit lower
  47. C triangular matrices and U is upper triangular.
  48. C
  49. C IPVT INTEGER(N)
  50. C an integer vector of pivot indices.
  51. C
  52. C INFO INTEGER
  53. C = 0 normal value.
  54. C = K if U(K,K) .EQ. 0.0 . This is not an error
  55. C condition for this subroutine, but it does
  56. C indicate that CGBSL will divide by zero if
  57. C called. Use RCOND in CGBCO for a reliable
  58. C indication of singularity.
  59. C
  60. C Band Storage
  61. C
  62. C If A is a band matrix, the following program segment
  63. C will set up the input.
  64. C
  65. C ML = (band width below the diagonal)
  66. C MU = (band width above the diagonal)
  67. C M = ML + MU + 1
  68. C DO 20 J = 1, N
  69. C I1 = MAX(1, J-MU)
  70. C I2 = MIN(N, J+ML)
  71. C DO 10 I = I1, I2
  72. C K = I - J + M
  73. C ABD(K,J) = A(I,J)
  74. C 10 CONTINUE
  75. C 20 CONTINUE
  76. C
  77. C This uses rows ML+1 through 2*ML+MU+1 of ABD .
  78. C In addition, the first ML rows in ABD are used for
  79. C elements generated during the triangularization.
  80. C The total number of rows needed in ABD is 2*ML+MU+1 .
  81. C The ML+MU by ML+MU upper left triangle and the
  82. C ML by ML lower right triangle are not referenced.
  83. C
  84. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  85. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  86. C***ROUTINES CALLED CAXPY, CSCAL, ICAMAX
  87. C***REVISION HISTORY (YYMMDD)
  88. C 780814 DATE WRITTEN
  89. C 890531 Changed all specific intrinsics to generic. (WRB)
  90. C 890831 Modified array declarations. (WRB)
  91. C 890831 REVISION DATE from Version 3.2
  92. C 891214 Prologue converted to Version 4.0 format. (BAB)
  93. C 900326 Removed duplicate information from DESCRIPTION section.
  94. C (WRB)
  95. C 920501 Reformatted the REFERENCES section. (WRB)
  96. C***END PROLOGUE CGBFA
  97. INTEGER LDA,N,ML,MU,IPVT(*),INFO
  98. COMPLEX ABD(LDA,*)
  99. C
  100. COMPLEX T
  101. INTEGER I,ICAMAX,I0,J,JU,JZ,J0,J1,K,KP1,L,LM,M,MM,NM1
  102. COMPLEX ZDUM
  103. REAL CABS1
  104. CABS1(ZDUM) = ABS(REAL(ZDUM)) + ABS(AIMAG(ZDUM))
  105. C
  106. C***FIRST EXECUTABLE STATEMENT CGBFA
  107. M = ML + MU + 1
  108. INFO = 0
  109. C
  110. C ZERO INITIAL FILL-IN COLUMNS
  111. C
  112. J0 = MU + 2
  113. J1 = MIN(N,M) - 1
  114. IF (J1 .LT. J0) GO TO 30
  115. DO 20 JZ = J0, J1
  116. I0 = M + 1 - JZ
  117. DO 10 I = I0, ML
  118. ABD(I,JZ) = (0.0E0,0.0E0)
  119. 10 CONTINUE
  120. 20 CONTINUE
  121. 30 CONTINUE
  122. JZ = J1
  123. JU = 0
  124. C
  125. C GAUSSIAN ELIMINATION WITH PARTIAL PIVOTING
  126. C
  127. NM1 = N - 1
  128. IF (NM1 .LT. 1) GO TO 130
  129. DO 120 K = 1, NM1
  130. KP1 = K + 1
  131. C
  132. C ZERO NEXT FILL-IN COLUMN
  133. C
  134. JZ = JZ + 1
  135. IF (JZ .GT. N) GO TO 50
  136. IF (ML .LT. 1) GO TO 50
  137. DO 40 I = 1, ML
  138. ABD(I,JZ) = (0.0E0,0.0E0)
  139. 40 CONTINUE
  140. 50 CONTINUE
  141. C
  142. C FIND L = PIVOT INDEX
  143. C
  144. LM = MIN(ML,N-K)
  145. L = ICAMAX(LM+1,ABD(M,K),1) + M - 1
  146. IPVT(K) = L + K - M
  147. C
  148. C ZERO PIVOT IMPLIES THIS COLUMN ALREADY TRIANGULARIZED
  149. C
  150. IF (CABS1(ABD(L,K)) .EQ. 0.0E0) GO TO 100
  151. C
  152. C INTERCHANGE IF NECESSARY
  153. C
  154. IF (L .EQ. M) GO TO 60
  155. T = ABD(L,K)
  156. ABD(L,K) = ABD(M,K)
  157. ABD(M,K) = T
  158. 60 CONTINUE
  159. C
  160. C COMPUTE MULTIPLIERS
  161. C
  162. T = -(1.0E0,0.0E0)/ABD(M,K)
  163. CALL CSCAL(LM,T,ABD(M+1,K),1)
  164. C
  165. C ROW ELIMINATION WITH COLUMN INDEXING
  166. C
  167. JU = MIN(MAX(JU,MU+IPVT(K)),N)
  168. MM = M
  169. IF (JU .LT. KP1) GO TO 90
  170. DO 80 J = KP1, JU
  171. L = L - 1
  172. MM = MM - 1
  173. T = ABD(L,J)
  174. IF (L .EQ. MM) GO TO 70
  175. ABD(L,J) = ABD(MM,J)
  176. ABD(MM,J) = T
  177. 70 CONTINUE
  178. CALL CAXPY(LM,T,ABD(M+1,K),1,ABD(MM+1,J),1)
  179. 80 CONTINUE
  180. 90 CONTINUE
  181. GO TO 110
  182. 100 CONTINUE
  183. INFO = K
  184. 110 CONTINUE
  185. 120 CONTINUE
  186. 130 CONTINUE
  187. IPVT(N) = N
  188. IF (CABS1(ABD(M,N)) .EQ. 0.0E0) INFO = N
  189. RETURN
  190. END