1
SUBROUTINE GAL_DGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB,
4
* -- LAPACK routine (version 1.1) --
5
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
6
* Courant Institute, Argonne National Lab, and Rice University
9
* .. Scalar Arguments ..
11
INTEGER INFO, LDA, LDB, N, NRHS
13
* .. Array Arguments ..
15
DOUBLE PRECISION A( LDA, * ), B( LDB, * )
21
* GAL_DGETRS solves a system of linear equations
22
* A * X = B or A' * X = B
23
* with a general N-by-N matrix A using the LU factorization computed
29
* TRANS (input) CHARACTER*1
30
* Specifies the form of the system of equations:
31
* = 'N': A * X = B (No transpose)
32
* = 'T': A'* X = B (Transpose)
33
* = 'C': A'* X = B (Conjugate transpose = Transpose)
36
* The order of the matrix A. N >= 0.
38
* NRHS (input) INTEGER
39
* The number of right hand sides, i.e., the number of columns
40
* of the matrix B. NRHS >= 0.
42
* A (input) DOUBLE PRECISION array, dimension (LDA,N)
43
* The factors L and U from the factorization A = P*L*U
44
* as computed by GAL_DGETRF.
47
* The leading dimension of the array A. LDA >= max(1,N).
49
* IPIV (input) INTEGER array, dimension (N)
50
* The pivot indices from GAL_DGETRF; for 1<=i<=N, row i of the
51
* matrix was interchanged with row IPIV(i).
53
* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
54
* On entry, the right hand side matrix B.
55
* On exit, the solution matrix X.
58
* The leading dimension of the array B. LDB >= max(1,N).
60
* INFO (output) INTEGER
61
* = 0: successful exit
62
* < 0: if INFO = -i, the i-th argument had an illegal value
64
* =====================================================================
68
PARAMETER ( ONE = 1.0D+0 )
73
* .. External Functions ..
77
* .. External Subroutines ..
78
EXTERNAL GAL_DLASWP, GAL_DTRSM, GAL_XERBLA
80
* .. Intrinsic Functions ..
83
* .. Executable Statements ..
85
* Test the input parameters.
88
NOTRAN = GAL_LSAME( TRANS, 'N' )
89
IF( .NOT.NOTRAN .AND. .NOT.GAL_LSAME( TRANS, 'T' ) .AND. .NOT.
90
$ GAL_LSAME( TRANS, 'C' ) ) THEN
92
ELSE IF( N.LT.0 ) THEN
94
ELSE IF( NRHS.LT.0 ) THEN
96
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
98
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
102
CALL GAL_XERBLA( 'GAL_DGETRS', -INFO )
106
* Quick return if possible
108
IF( N.EQ.0 .OR. NRHS.EQ.0 )
115
* Apply row interchanges to the right hand sides.
117
CALL GAL_DLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
119
* Solve L*X = B, overwriting B with X.
121
CALL GAL_DTRSM( 'Left', 'Lower', 'No transpose', 'Unit', N,
122
$ NRHS, ONE, A, LDA, B, LDB )
124
* Solve U*X = B, overwriting B with X.
126
CALL GAL_DTRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,
127
$ NRHS, ONE, A, LDA, B, LDB )
132
* Solve U'*X = B, overwriting B with X.
134
CALL GAL_DTRSM( 'Left', 'Upper', 'Transpose', 'Non-unit', N,
135
$ NRHS, ONE, A, LDA, B, LDB )
137
* Solve L'*X = B, overwriting B with X.
139
CALL GAL_DTRSM( 'Left', 'Lower', 'Transpose', 'Unit', N, NRHS,
140
$ ONE, A, LDA, B, LDB )
142
* Apply row interchanges to the solution vectors.
144
CALL GAL_DLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )