|
kusano |
2b45e8 |
SUBROUTINE ZGETRSF( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- LAPACK routine (version 3.0) --
|
|
kusano |
2b45e8 |
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
|
|
kusano |
2b45e8 |
* Courant Institute, Argonne National Lab, and Rice University
|
|
kusano |
2b45e8 |
* September 30, 1994
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
CHARACTER TRANS
|
|
kusano |
2b45e8 |
INTEGER INFO, LDA, LDB, N, NRHS
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
INTEGER IPIV( * )
|
|
kusano |
2b45e8 |
COMPLEX*16 A( LDA, * ), B( LDB, * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* ZGETRS solves a system of linear equations
|
|
kusano |
2b45e8 |
* A * X = B, A**T * X = B, or A**H * X = B
|
|
kusano |
2b45e8 |
* with a general N-by-N matrix A using the LU factorization computed
|
|
kusano |
2b45e8 |
* by ZGETRF.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* =========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* TRANS (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* Specifies the form of the system of equations:
|
|
kusano |
2b45e8 |
* = 'N': A * X = B (No transpose)
|
|
kusano |
2b45e8 |
* = 'T': A**T * X = B (Transpose)
|
|
kusano |
2b45e8 |
* = 'C': A**H * X = B (Conjugate transpose)
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N (input) INTEGER
|
|
kusano |
2b45e8 |
* The order of the matrix A. N >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* NRHS (input) INTEGER
|
|
kusano |
2b45e8 |
* The number of right hand sides, i.e., the number of columns
|
|
kusano |
2b45e8 |
* of the matrix B. NRHS >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A (input) COMPLEX*16 array, dimension (LDA,N)
|
|
kusano |
2b45e8 |
* The factors L and U from the factorization A = P*L*U
|
|
kusano |
2b45e8 |
* as computed by ZGETRF.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA (input) INTEGER
|
|
kusano |
2b45e8 |
* The leading dimension of the array A. LDA >= max(1,N).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* IPIV (input) INTEGER array, dimension (N)
|
|
kusano |
2b45e8 |
* The pivot indices from ZGETRF; for 1<=i<=N, row i of the
|
|
kusano |
2b45e8 |
* matrix was interchanged with row IPIV(i).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* B (input/output) COMPLEX*16 array, dimension (LDB,NRHS)
|
|
kusano |
2b45e8 |
* On entry, the right hand side matrix B.
|
|
kusano |
2b45e8 |
* On exit, the solution matrix X.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDB (input) INTEGER
|
|
kusano |
2b45e8 |
* The leading dimension of the array B. LDB >= max(1,N).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* INFO (output) INTEGER
|
|
kusano |
2b45e8 |
* = 0: successful exit
|
|
kusano |
2b45e8 |
* < 0: if INFO = -i, the i-th argument had an illegal value
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
COMPLEX*16 ONE
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ) )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
LOGICAL NOTRAN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL XERBLA, ZLASWP, ZTRSM
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC MAX
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
NOTRAN = LSAME( TRANS, 'N' ) .OR. LSAME(TRANS, 'R')
|
|
kusano |
2b45e8 |
IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
|
|
kusano |
2b45e8 |
$ LSAME( TRANS, 'C' ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -1
|
|
kusano |
2b45e8 |
ELSE IF( N.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = -2
|
|
kusano |
2b45e8 |
ELSE IF( NRHS.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = -3
|
|
kusano |
2b45e8 |
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -5
|
|
kusano |
2b45e8 |
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -8
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 ) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'ZGETRS', -INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( N.EQ.0 .OR. NRHS.EQ.0 )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( NOTRAN ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve A * X = B.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Apply row interchanges to the right hand sides.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve L*X = B, overwriting B with X.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZTRSM( 'Left', 'Lower', TRANS, 'Unit', N, NRHS,
|
|
kusano |
2b45e8 |
$ ONE, A, LDA, B, LDB )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve U*X = B, overwriting B with X.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZTRSM( 'Left', 'Upper', TRANS, 'Non-unit', N,
|
|
kusano |
2b45e8 |
$ NRHS, ONE, A, LDA, B, LDB )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve A**T * X = B or A**H * X = B.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve U'*X = B, overwriting B with X.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZTRSM( 'Left', 'Upper', TRANS, 'Non-unit', N, NRHS, ONE,
|
|
kusano |
2b45e8 |
$ A, LDA, B, LDB )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Solve L'*X = B, overwriting B with X.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZTRSM( 'Left', 'Lower', TRANS, 'Unit', N, NRHS, ONE, A,
|
|
kusano |
2b45e8 |
$ LDA, B, LDB )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Apply row interchanges to the solution vectors.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL ZLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of ZGETRS
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|