dslui2.f 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. *DECK DSLUI2
  2. SUBROUTINE DSLUI2 (N, B, X, IL, JL, L, DINV, IU, JU, U)
  3. C***BEGIN PROLOGUE DSLUI2
  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.
  8. C***LIBRARY SLATEC (SLAP)
  9. C***CATEGORY D2E
  10. C***TYPE DOUBLE PRECISION (SSLUI2-S, DSLUI2-D)
  11. C***KEYWORDS ITERATIVE PRECONDITION, NON-SYMMETRIC LINEAR SYSTEM SOLVE,
  12. C 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 DOUBLE PRECISION B(N), X(N), L(NL), DINV(N), U(NU)
  24. C
  25. C CALL DSLUI2( 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 Double Precision B(N).
  31. C Right hand side.
  32. C X :OUT Double Precision X(N).
  33. C Solution of L*D*U x = b.
  34. C IL :IN Integer IL(NL).
  35. C JL :IN Integer JL(NL).
  36. C L :IN Double Precision 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 DSILUS 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 Double Precision 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 Double Precision 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 DSILUS 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 SIR and SBCG
  58. C iteration routines for the drivers DSILUR and DSLUBC. It
  59. C must be called via the SLAP MSOLVE calling sequence
  60. C convention interface routine DSLUI.
  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 DSILUS 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 double precision array A. In other words, for each column
  79. C in the matrix put the diagonal entry in A. Then put in the
  80. C other non-zero elements going down the column (except the
  81. C diagonal) in order. The IA array holds the row index for
  82. C each non-zero. The JA array holds the offsets into the IA,
  83. C A arrays for the beginning of each column. That is,
  84. C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
  85. C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
  86. C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
  87. C Note that we always have JA(N+1) = NELT+1, where N is the
  88. C number of columns in the matrix and NELT is the number of
  89. C 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
  109. C double precision array A. In other words, for each row in
  110. C the matrix put the diagonal entry in A. Then put in the
  111. C other non-zero elements going across the row (except the
  112. C diagonal) in order. The JA array holds the column index for
  113. C each non-zero. The IA array holds the offsets into the JA,
  114. C A arrays for the beginning of each row. That is,
  115. C JA(IA(IROW)),A(IA(IROW)) are the first elements of the IROW-
  116. C th row in JA and A, and JA(IA(IROW+1)-1), A(IA(IROW+1)-1)
  117. C are the last elements of the IROW-th row. Note that we
  118. C always have IA(N+1) = NELT+1, where N is the number of rows
  119. C in 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 DSILUS
  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 DSLUI2
  156. C .. Scalar Arguments ..
  157. INTEGER N
  158. C .. Array Arguments ..
  159. DOUBLE PRECISION 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 DSLUI2
  164. C
  165. C Solve L*Y = B, storing result in X, L stored by rows.
  166. C
  167. DO 10 I = 1, N
  168. X(I) = B(I)
  169. 10 CONTINUE
  170. DO 30 IROW = 2, N
  171. JBGN = IL(IROW)
  172. JEND = IL(IROW+1)-1
  173. IF( JBGN.LE.JEND ) THEN
  174. CLLL. OPTION ASSERT (NOHAZARD)
  175. CDIR$ IVDEP
  176. CVD$ ASSOC
  177. CVD$ NODEPCHK
  178. DO 20 J = JBGN, JEND
  179. X(IROW) = X(IROW) - L(J)*X(JL(J))
  180. 20 CONTINUE
  181. ENDIF
  182. 30 CONTINUE
  183. C
  184. C Solve D*Z = Y, storing result in X.
  185. DO 40 I=1,N
  186. X(I) = X(I)*DINV(I)
  187. 40 CONTINUE
  188. C
  189. C Solve U*X = Z, U stored by columns.
  190. DO 60 ICOL = N, 2, -1
  191. JBGN = JU(ICOL)
  192. JEND = JU(ICOL+1)-1
  193. IF( JBGN.LE.JEND ) THEN
  194. CLLL. OPTION ASSERT (NOHAZARD)
  195. CDIR$ IVDEP
  196. CVD$ NODEPCHK
  197. DO 50 J = JBGN, JEND
  198. X(IU(J)) = X(IU(J)) - U(J)*X(ICOL)
  199. 50 CONTINUE
  200. ENDIF
  201. 60 CONTINUE
  202. C
  203. RETURN
  204. C------------- LAST LINE OF DSLUI2 FOLLOWS ----------------------------
  205. END