snbfa.f 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. *DECK SNBFA
  2. SUBROUTINE SNBFA (ABE, LDA, N, ML, MU, IPVT, INFO)
  3. C***BEGIN PROLOGUE SNBFA
  4. C***PURPOSE Factor a real band matrix by elimination.
  5. C***LIBRARY SLATEC
  6. C***CATEGORY D2A2
  7. C***TYPE SINGLE PRECISION (SNBFA-S, DNBFA-D, CNBFA-C)
  8. C***KEYWORDS BANDED, LINEAR EQUATIONS, MATRIX FACTORIZATION,
  9. C NONSYMMETRIC
  10. C***AUTHOR Voorhees, E. A., (LANL)
  11. C***DESCRIPTION
  12. C
  13. C SNBFA factors a real band matrix by elimination.
  14. C
  15. C SNBFA is usually called by SNBCO, but it can be called
  16. C directly with a saving in time if RCOND is not needed.
  17. C
  18. C On Entry
  19. C
  20. C ABE REAL(LDA, NC)
  21. C contains the matrix in band storage. The rows
  22. C of the original matrix are stored in the rows
  23. C of ABE and the diagonals of the original matrix
  24. C are stored in columns 1 through ML+MU+1 of ABE.
  25. C NC must be .GE. 2*ML+MU+1 .
  26. C See the comments below for details.
  27. C
  28. C LDA INTEGER
  29. C the leading dimension of the array ABE.
  30. C LDA must be .GE. N .
  31. C
  32. C N INTEGER
  33. C the order of the original matrix.
  34. C
  35. C ML INTEGER
  36. C number of diagonals below the main diagonal.
  37. C 0 .LE. ML .LT. N .
  38. C
  39. C MU INTEGER
  40. C number of diagonals above the main diagonal.
  41. C 0 .LE. MU .LT. N .
  42. C More efficient if ML .LE. MU .
  43. C
  44. C On Return
  45. C
  46. C ABE an upper triangular matrix in band storage
  47. C and the multipliers which were used to obtain it.
  48. C The factorization can be written A = L*U , where
  49. C L is a product of permutation and unit lower
  50. C triangular matrices and U is upper triangular.
  51. C
  52. C IPVT INTEGER(N)
  53. C an integer vector of pivot indices.
  54. C
  55. C INFO INTEGER
  56. C =0 normal value
  57. C =K if U(K,K) .EQ. 0.0 . This is not an error
  58. C condition for this subroutine, but it does
  59. C indicate that SNBSL will divide by zero if
  60. C called. Use RCOND in SNBCO for a reliable
  61. C indication of singularity.
  62. C
  63. C Band Storage
  64. C
  65. C If A is a band matrix, the following program segment
  66. C will set up the input.
  67. C
  68. C ML = (band width below the diagonal)
  69. C MU = (band width above the diagonal)
  70. C DO 20 I = 1, N
  71. C J1 = MAX(1, I-ML)
  72. C J2 = MIN(N, I+MU)
  73. C DO 10 J = J1, J2
  74. C K = J - I + ML + 1
  75. C ABE(I,K) = A(I,J)
  76. C 10 CONTINUE
  77. C 20 CONTINUE
  78. C
  79. C This uses columns 1 through ML+MU+1 of ABE .
  80. C Furthermore, ML additional columns are needed in
  81. C ABE starting with column ML+MU+2 for elements
  82. C generated during the triangularization. The total
  83. C number of columns needed in ABE is 2*ML+MU+1 .
  84. C
  85. C Example: If the original matrix is
  86. C
  87. C 11 12 13 0 0 0
  88. C 21 22 23 24 0 0
  89. C 0 32 33 34 35 0
  90. C 0 0 43 44 45 46
  91. C 0 0 0 54 55 56
  92. C 0 0 0 0 65 66
  93. C
  94. C then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain
  95. C
  96. C * 11 12 13 + , * = not used
  97. C 21 22 23 24 + , + = used for pivoting
  98. C 32 33 34 35 +
  99. C 43 44 45 46 +
  100. C 54 55 56 * +
  101. C 65 66 * * +
  102. C
  103. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  104. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  105. C***ROUTINES CALLED ISAMAX, SAXPY, SSCAL, SSWAP
  106. C***REVISION HISTORY (YYMMDD)
  107. C 800606 DATE WRITTEN
  108. C 890531 Changed all specific intrinsics to generic. (WRB)
  109. C 890831 Modified array declarations. (WRB)
  110. C 890831 REVISION DATE from Version 3.2
  111. C 891214 Prologue converted to Version 4.0 format. (BAB)
  112. C 920501 Reformatted the REFERENCES section. (WRB)
  113. C***END PROLOGUE SNBFA
  114. INTEGER LDA,N,ML,MU,IPVT(*),INFO
  115. REAL ABE(LDA,*)
  116. C
  117. INTEGER ML1,MB,M,N1,LDB,I,J,K,L,LM,LM1,LM2,MP,ISAMAX
  118. REAL T
  119. C***FIRST EXECUTABLE STATEMENT SNBFA
  120. ML1=ML+1
  121. MB=ML+MU
  122. M=ML+MU+1
  123. N1=N-1
  124. LDB=LDA-1
  125. INFO=0
  126. C
  127. C SET FILL-IN COLUMNS TO ZERO
  128. C
  129. IF(N.LE.1)GO TO 50
  130. IF(ML.LE.0)GO TO 7
  131. DO 6 J=1,ML
  132. DO 5 I=1,N
  133. ABE(I,M+J)=0.0E0
  134. 5 CONTINUE
  135. 6 CONTINUE
  136. 7 CONTINUE
  137. C
  138. C GAUSSIAN ELIMINATION WITH PARTIAL ELIMINATION
  139. C
  140. DO 40 K=1,N1
  141. LM=MIN(N-K,ML)
  142. LM1=LM+1
  143. LM2=ML1-LM
  144. C
  145. C SEARCH FOR PIVOT INDEX
  146. C
  147. L=-ISAMAX(LM1,ABE(LM+K,LM2),LDB)+LM1+K
  148. IPVT(K)=L
  149. MP=MIN(MB,N-K)
  150. C
  151. C SWAP ROWS IF NECESSARY
  152. C
  153. IF(L.NE.K)CALL SSWAP(MP+1,ABE(K,ML1),LDA,ABE(L,ML1+K-L),LDA)
  154. C
  155. C SKIP COLUMN REDUCTION IF PIVOT IS ZERO
  156. C
  157. IF(ABE(K,ML1).EQ.0.0E0) GO TO 20
  158. C
  159. C COMPUTE MULTIPLIERS
  160. C
  161. T=-1.0/ABE(K,ML1)
  162. CALL SSCAL(LM,T,ABE(LM+K,LM2),LDB)
  163. C
  164. C ROW ELIMINATION WITH COLUMN INDEXING
  165. C
  166. DO 10 J=1,MP
  167. CALL SAXPY (LM,ABE(K,ML1+J),ABE(LM+K,LM2),LDB,ABE(LM+K,LM2+J),
  168. 1 LDB)
  169. 10 CONTINUE
  170. GO TO 30
  171. 20 CONTINUE
  172. INFO=K
  173. 30 CONTINUE
  174. 40 CONTINUE
  175. 50 CONTINUE
  176. IPVT(N)=N
  177. IF(ABE(N,ML1).EQ.0.0E0) INFO=N
  178. RETURN
  179. END