OpenLibm/slatec/dslui2.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

205 lines
8.7 KiB
Fortran

*DECK DSLUI2
SUBROUTINE DSLUI2 (N, B, X, IL, JL, L, DINV, IU, JU, U)
C***BEGIN PROLOGUE DSLUI2
C***PURPOSE SLAP Backsolve for LDU Factorization.
C Routine to solve a system of the form L*D*U X = B,
C where L is a unit lower triangular matrix, D is a diagonal
C matrix, and U is a unit upper triangular matrix.
C***LIBRARY SLATEC (SLAP)
C***CATEGORY D2E
C***TYPE DOUBLE PRECISION (SSLUI2-S, DSLUI2-D)
C***KEYWORDS ITERATIVE PRECONDITION, NON-SYMMETRIC LINEAR SYSTEM SOLVE,
C SLAP, SPARSE
C***AUTHOR Greenbaum, Anne, (Courant Institute)
C Seager, Mark K., (LLNL)
C Lawrence Livermore National Laboratory
C PO BOX 808, L-60
C Livermore, CA 94550 (510) 423-3141
C seager@llnl.gov
C***DESCRIPTION
C
C *Usage:
C INTEGER N, IL(NL), JL(NL), IU(NU), JU(NU)
C DOUBLE PRECISION B(N), X(N), L(NL), DINV(N), U(NU)
C
C CALL DSLUI2( N, B, X, IL, JL, L, DINV, IU, JU, U )
C
C *Arguments:
C N :IN Integer
C Order of the Matrix.
C B :IN Double Precision B(N).
C Right hand side.
C X :OUT Double Precision X(N).
C Solution of L*D*U x = b.
C IL :IN Integer IL(NL).
C JL :IN Integer JL(NL).
C L :IN Double Precision L(NL).
C IL, JL, L contain the unit lower triangular factor of the
C incomplete decomposition of some matrix stored in SLAP Row
C format. The diagonal of ones *IS* stored. This structure
C can be set up by the DSILUS routine. See the
C "Description", below for more details about the SLAP
C format. (NL is the number of non-zeros in the L array.)
C DINV :IN Double Precision DINV(N).
C Inverse of the diagonal matrix D.
C IU :IN Integer IU(NU).
C JU :IN Integer JU(NU).
C U :IN Double Precision U(NU).
C IU, JU, U contain the unit upper triangular factor of the
C incomplete decomposition of some matrix stored in SLAP
C Column format. The diagonal of ones *IS* stored. This
C structure can be set up by the DSILUS routine. See the
C "Description", below for more details about the SLAP
C format. (NU is the number of non-zeros in the U array.)
C
C *Description:
C This routine is supplied with the SLAP package as a routine
C to perform the MSOLVE operation in the SIR and SBCG
C iteration routines for the drivers DSILUR and DSLUBC. It
C must be called via the SLAP MSOLVE calling sequence
C convention interface routine DSLUI.
C **** THIS ROUTINE ITSELF DOES NOT CONFORM TO THE ****
C **** SLAP MSOLVE CALLING CONVENTION ****
C
C IL, JL, L should contain the unit lower triangular factor of
C the incomplete decomposition of the A matrix stored in SLAP
C Row format. IU, JU, U should contain the unit upper factor
C of the incomplete decomposition of the A matrix stored in
C SLAP Column format This ILU factorization can be computed by
C the DSILUS routine. The diagonals (which are all one's) are
C stored.
C
C =================== S L A P Column format ==================
C
C This routine requires that the matrix A be stored in the
C SLAP Column format. In this format the non-zeros are stored
C counting down columns (except for the diagonal entry, which
C must appear first in each "column") and are stored in the
C double precision array A. In other words, for each column
C in the matrix put the diagonal entry in A. Then put in the
C other non-zero elements going down the column (except the
C diagonal) in order. The IA array holds the row index for
C each non-zero. The JA array holds the offsets into the IA,
C A arrays for the beginning of each column. That is,
C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
C Note that we always have JA(N+1) = NELT+1, where N is the
C number of columns in the matrix and NELT is the number of
C non-zeros in the matrix.
C
C Here is an example of the SLAP Column storage format for a
C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
C column):
C
C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
C 1 2 3 4 5 6 7 8 9 10 11
C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
C | 0 0 33 0 35| JA: 1 4 6 8 9 12
C | 0 0 0 44 0|
C |51 0 53 0 55|
C
C ==================== S L A P Row format ====================
C
C This routine requires that the matrix A be stored in the
C SLAP Row format. In this format the non-zeros are stored
C counting across rows (except for the diagonal entry, which
C must appear first in each "row") and are stored in the
C double precision array A. In other words, for each row in
C the matrix put the diagonal entry in A. Then put in the
C other non-zero elements going across the row (except the
C diagonal) in order. The JA array holds the column index for
C each non-zero. The IA array holds the offsets into the JA,
C A arrays for the beginning of each row. That is,
C JA(IA(IROW)),A(IA(IROW)) are the first elements of the IROW-
C th row in JA and A, and JA(IA(IROW+1)-1), A(IA(IROW+1)-1)
C are the last elements of the IROW-th row. Note that we
C always have IA(N+1) = NELT+1, where N is the number of rows
C in the matrix and NELT is the number of non-zeros in the
C matrix.
C
C Here is an example of the SLAP Row storage format for a 5x5
C Matrix (in the A and JA arrays '|' denotes the end of a row):
C
C 5x5 Matrix SLAP Row format for 5x5 matrix on left.
C 1 2 3 4 5 6 7 8 9 10 11
C |11 12 0 0 15| A: 11 12 15 | 22 21 | 33 35 | 44 | 55 51 53
C |21 22 0 0 0| JA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
C | 0 0 33 0 35| IA: 1 4 6 8 9 12
C | 0 0 0 44 0|
C |51 0 53 0 55|
C
C With the SLAP format the "inner loops" of this routine
C should vectorize on machines with hardware support for
C vector gather/scatter operations. Your compiler may require
C a compiler directive to convince it that there are no
C implicit vector dependencies. Compiler directives for the
C Alliant FX/Fortran and CRI CFT/CFT77 compilers are supplied
C with the standard SLAP distribution.
C
C***SEE ALSO DSILUS
C***REFERENCES (NONE)
C***ROUTINES CALLED (NONE)
C***REVISION HISTORY (YYMMDD)
C 871119 DATE WRITTEN
C 881213 Previous REVISION DATE
C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
C 890922 Numerous changes to prologue to make closer to SLATEC
C standard. (FNF)
C 890929 Numerous changes to reduce SP/DP differences. (FNF)
C 910411 Prologue converted to Version 4.0 format. (BAB)
C 920511 Added complete declaration section. (WRB)
C 921113 Corrected C***CATEGORY line. (FNF)
C 930701 Updated CATEGORY section. (FNF, WRB)
C***END PROLOGUE DSLUI2
C .. Scalar Arguments ..
INTEGER N
C .. Array Arguments ..
DOUBLE PRECISION B(N), DINV(N), L(*), U(*), X(N)
INTEGER IL(*), IU(*), JL(*), JU(*)
C .. Local Scalars ..
INTEGER I, ICOL, IROW, J, JBGN, JEND
C***FIRST EXECUTABLE STATEMENT DSLUI2
C
C Solve L*Y = B, storing result in X, L stored by rows.
C
DO 10 I = 1, N
X(I) = B(I)
10 CONTINUE
DO 30 IROW = 2, N
JBGN = IL(IROW)
JEND = IL(IROW+1)-1
IF( JBGN.LE.JEND ) THEN
CLLL. OPTION ASSERT (NOHAZARD)
CDIR$ IVDEP
CVD$ ASSOC
CVD$ NODEPCHK
DO 20 J = JBGN, JEND
X(IROW) = X(IROW) - L(J)*X(JL(J))
20 CONTINUE
ENDIF
30 CONTINUE
C
C Solve D*Z = Y, storing result in X.
DO 40 I=1,N
X(I) = X(I)*DINV(I)
40 CONTINUE
C
C Solve U*X = Z, U stored by columns.
DO 60 ICOL = N, 2, -1
JBGN = JU(ICOL)
JEND = JU(ICOL+1)-1
IF( JBGN.LE.JEND ) THEN
CLLL. OPTION ASSERT (NOHAZARD)
CDIR$ IVDEP
CVD$ NODEPCHK
DO 50 J = JBGN, JEND
X(IU(J)) = X(IU(J)) - U(J)*X(ICOL)
50 CONTINUE
ENDIF
60 CONTINUE
C
RETURN
C------------- LAST LINE OF DSLUI2 FOLLOWS ----------------------------
END