ssmmi2.f 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. *DECK SSMMI2
  2. SUBROUTINE SSMMI2 (N, B, X, IL, JL, L, DINV, IU, JU, U)
  3. C***BEGIN PROLOGUE SSMMI2
  4. C***PURPOSE SLAP Backsolve for LDU Factorization of Normal Equations.
  5. C To solve a system of the form (L*D*U)*(L*D*U)' X = B,
  6. C where L is a unit lower triangular matrix, D is a diagonal
  7. C matrix, and U is a unit upper triangular matrix and '
  8. C denotes transpose.
  9. C***LIBRARY SLATEC (SLAP)
  10. C***CATEGORY D2E
  11. C***TYPE SINGLE PRECISION (SSMMI2-S, DSMMI2-D)
  12. C***KEYWORDS ITERATIVE PRECONDITION, LINEAR SYSTEM, SLAP, SPARSE
  13. C***AUTHOR Greenbaum, Anne, (Courant Institute)
  14. C Seager, Mark K., (LLNL)
  15. C Lawrence Livermore National Laboratory
  16. C PO BOX 808, L-60
  17. C Livermore, CA 94550 (510) 423-3141
  18. C seager@llnl.gov
  19. C***DESCRIPTION
  20. C
  21. C *Usage:
  22. C INTEGER N, IL(NL), JL(NL), IU(NU), JU(NU)
  23. C REAL B(N), X(N), L(NL), DINV(N), U(NU)
  24. C
  25. C CALL SSMMI2( N, B, X, IL, JL, L, DINV, IU, JU, U )
  26. C
  27. C *Arguments:
  28. C N :IN Integer
  29. C Order of the Matrix.
  30. C B :IN Real B(N).
  31. C Right hand side.
  32. C X :OUT Real X(N).
  33. C Solution of (L*D*U)(L*D*U)trans x = b.
  34. C IL :IN Integer IL(NL).
  35. C JL :IN Integer JL(NL).
  36. C L :IN Real L(NL).
  37. C IL, JL, L contain the unit lower triangular factor of the
  38. C incomplete decomposition of some matrix stored in SLAP Row
  39. C format. The diagonal of ones *IS* stored. This structure
  40. C can be set up by the SSILUS routine. See the
  41. C "Description", below for more details about the SLAP
  42. C format. (NL is the number of non-zeros in the L array.)
  43. C DINV :IN Real DINV(N).
  44. C Inverse of the diagonal matrix D.
  45. C IU :IN Integer IU(NU).
  46. C JU :IN Integer JU(NU).
  47. C U :IN Real U(NU).
  48. C IU, JU, U contain the unit upper triangular factor of the
  49. C incomplete decomposition of some matrix stored in SLAP
  50. C Column format. The diagonal of ones *IS* stored. This
  51. C structure can be set up by the SSILUS routine. See the
  52. C "Description", below for more details about the SLAP
  53. C format. (NU is the number of non-zeros in the U array.)
  54. C
  55. C *Description:
  56. C This routine is supplied with the SLAP package as a routine
  57. C to perform the MSOLVE operation in the SBCGN iteration
  58. C routine for the driver SSLUCN. It must be called via the
  59. C SLAP MSOLVE calling sequence convention interface routine
  60. C SSMMTI.
  61. C **** THIS ROUTINE ITSELF DOES NOT CONFORM TO THE ****
  62. C **** SLAP MSOLVE CALLING CONVENTION ****
  63. C
  64. C IL, JL, L should contain the unit lower triangular factor of
  65. C the incomplete decomposition of the A matrix stored in SLAP
  66. C Row format. IU, JU, U should contain the unit upper factor
  67. C of the incomplete decomposition of the A matrix stored in
  68. C SLAP Column format This ILU factorization can be computed by
  69. C the SSILUS routine. The diagonals (which are all one's) are
  70. C stored.
  71. C
  72. C =================== S L A P Column format ==================
  73. C
  74. C This routine requires that the matrix A be stored in the
  75. C SLAP Column format. In this format the non-zeros are stored
  76. C counting down columns (except for the diagonal entry, which
  77. C must appear first in each "column") and are stored in the
  78. C real array A. In other words, for each column in the matrix
  79. C put the diagonal entry in A. Then put in the other non-zero
  80. C elements going down the column (except the diagonal) in
  81. C order. The IA array holds the row index for each non-zero.
  82. C The JA array holds the offsets into the IA, A arrays for the
  83. C beginning of each column. That is, IA(JA(ICOL)),
  84. C A(JA(ICOL)) points to the beginning of the ICOL-th column in
  85. C IA and A. IA(JA(ICOL+1)-1), A(JA(ICOL+1)-1) points to the
  86. C end of the ICOL-th column. Note that we always have
  87. C JA(N+1) = NELT+1, where N is the number of columns in the
  88. C matrix and NELT is the number of non-zeros in the matrix.
  89. C
  90. C Here is an example of the SLAP Column storage format for a
  91. C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
  92. C column):
  93. C
  94. C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
  95. C 1 2 3 4 5 6 7 8 9 10 11
  96. C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
  97. C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
  98. C | 0 0 33 0 35| JA: 1 4 6 8 9 12
  99. C | 0 0 0 44 0|
  100. C |51 0 53 0 55|
  101. C
  102. C ==================== S L A P Row format ====================
  103. C
  104. C This routine requires that the matrix A be stored in the
  105. C SLAP Row format. In this format the non-zeros are stored
  106. C counting across rows (except for the diagonal entry, which
  107. C must appear first in each "row") and are stored in the real
  108. C array A. In other words, for each row in the matrix put the
  109. C diagonal entry in A. Then put in the other non-zero
  110. C elements going across the row (except the diagonal) in
  111. C order. The JA array holds the column index for each
  112. C non-zero. The IA array holds the offsets into the JA, A
  113. C arrays for the beginning of each row. That is,
  114. C JA(IA(IROW)), A(IA(IROW)) points to the beginning of the
  115. C IROW-th row in JA and A. JA(IA(IROW+1)-1), A(IA(IROW+1)-1)
  116. C points to the end of the IROW-th row. Note that we always
  117. C have IA(N+1) = NELT+1, where N is the number of rows in
  118. C the matrix and NELT is the number of non-zeros in the
  119. C matrix.
  120. C
  121. C Here is an example of the SLAP Row storage format for a 5x5
  122. C Matrix (in the A and JA arrays '|' denotes the end of a row):
  123. C
  124. C 5x5 Matrix SLAP Row format for 5x5 matrix on left.
  125. C 1 2 3 4 5 6 7 8 9 10 11
  126. C |11 12 0 0 15| A: 11 12 15 | 22 21 | 33 35 | 44 | 55 51 53
  127. C |21 22 0 0 0| JA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
  128. C | 0 0 33 0 35| IA: 1 4 6 8 9 12
  129. C | 0 0 0 44 0|
  130. C |51 0 53 0 55|
  131. C
  132. C With the SLAP format the "inner loops" of this routine
  133. C should vectorize on machines with hardware support for
  134. C vector gather/scatter operations. Your compiler may require
  135. C a compiler directive to convince it that there are no
  136. C implicit vector dependencies. Compiler directives for the
  137. C Alliant FX/Fortran and CRI CFT/CFT77 compilers are supplied
  138. C with the standard SLAP distribution.
  139. C
  140. C***SEE ALSO SSILUS
  141. C***REFERENCES (NONE)
  142. C***ROUTINES CALLED (NONE)
  143. C***REVISION HISTORY (YYMMDD)
  144. C 871119 DATE WRITTEN
  145. C 881213 Previous REVISION DATE
  146. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  147. C 890922 Numerous changes to prologue to make closer to SLATEC
  148. C standard. (FNF)
  149. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  150. C 910411 Prologue converted to Version 4.0 format. (BAB)
  151. C 920511 Added complete declaration section. (WRB)
  152. C 921113 Corrected C***CATEGORY line. (FNF)
  153. C 930701 Updated CATEGORY section. (FNF, WRB)
  154. C***END PROLOGUE SSMMI2
  155. C .. Scalar Arguments ..
  156. INTEGER N
  157. C .. Array Arguments ..
  158. REAL B(N), DINV(N), L(*), U(N), X(N)
  159. INTEGER IL(*), IU(*), JL(*), JU(*)
  160. C .. Local Scalars ..
  161. INTEGER I, ICOL, IROW, J, JBGN, JEND
  162. C***FIRST EXECUTABLE STATEMENT SSMMI2
  163. C
  164. C Solve L*Y = B, storing result in X, L stored by rows.
  165. C
  166. DO 10 I = 1, N
  167. X(I) = B(I)
  168. 10 CONTINUE
  169. DO 30 IROW = 2, N
  170. JBGN = IL(IROW)
  171. JEND = IL(IROW+1)-1
  172. IF( JBGN.LE.JEND ) THEN
  173. CLLL. OPTION ASSERT (NOHAZARD)
  174. CDIR$ IVDEP
  175. CVD$ ASSOC
  176. CVD$ NODEPCHK
  177. DO 20 J = JBGN, JEND
  178. X(IROW) = X(IROW) - L(J)*X(JL(J))
  179. 20 CONTINUE
  180. ENDIF
  181. 30 CONTINUE
  182. C
  183. C Solve D*Z = Y, storing result in X.
  184. DO 40 I=1,N
  185. X(I) = X(I)*DINV(I)
  186. 40 CONTINUE
  187. C
  188. C Solve U*X = Z, U stored by columns.
  189. DO 60 ICOL = N, 2, -1
  190. JBGN = JU(ICOL)
  191. JEND = JU(ICOL+1)-1
  192. IF( JBGN.LE.JEND ) THEN
  193. CLLL. OPTION ASSERT (NOHAZARD)
  194. CDIR$ IVDEP
  195. CVD$ NODEPCHK
  196. DO 50 J = JBGN, JEND
  197. X(IU(J)) = X(IU(J)) - U(J)*X(ICOL)
  198. 50 CONTINUE
  199. ENDIF
  200. 60 CONTINUE
  201. C
  202. C Solve U'*Y = X, storing result in X, U stored by columns.
  203. DO 80 IROW = 2, N
  204. JBGN = JU(IROW)
  205. JEND = JU(IROW+1) - 1
  206. IF( JBGN.LE.JEND ) THEN
  207. CLLL. OPTION ASSERT (NOHAZARD)
  208. CDIR$ IVDEP
  209. CVD$ ASSOC
  210. CVD$ NODEPCHK
  211. DO 70 J = JBGN, JEND
  212. X(IROW) = X(IROW) - U(J)*X(IU(J))
  213. 70 CONTINUE
  214. ENDIF
  215. 80 CONTINUE
  216. C
  217. C Solve D*Z = Y, storing result in X.
  218. DO 90 I = 1, N
  219. X(I) = X(I)*DINV(I)
  220. 90 CONTINUE
  221. C
  222. C Solve L'*X = Z, L stored by rows.
  223. DO 110 ICOL = N, 2, -1
  224. JBGN = IL(ICOL)
  225. JEND = IL(ICOL+1) - 1
  226. IF( JBGN.LE.JEND ) THEN
  227. CLLL. OPTION ASSERT (NOHAZARD)
  228. CDIR$ IVDEP
  229. CVD$ NODEPCHK
  230. DO 100 J = JBGN, JEND
  231. X(JL(J)) = X(JL(J)) - L(J)*X(ICOL)
  232. 100 CONTINUE
  233. ENDIF
  234. 110 CONTINUE
  235. C
  236. RETURN
  237. C------------- LAST LINE OF SSMMI2 FOLLOWS ----------------------------
  238. END