sslui4.f 8.7 KB

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