forked from lijiext/lammps
226 lines
5.9 KiB
Fortran
226 lines
5.9 KiB
Fortran
*> \brief \b DGETRS
|
|
*
|
|
* =========== DOCUMENTATION ===========
|
|
*
|
|
* Online html documentation available at
|
|
* http://www.netlib.org/lapack/explore-html/
|
|
*
|
|
*> \htmlonly
|
|
*> Download DGETRS + dependencies
|
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgetrs.f">
|
|
*> [TGZ]</a>
|
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgetrs.f">
|
|
*> [ZIP]</a>
|
|
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgetrs.f">
|
|
*> [TXT]</a>
|
|
*> \endhtmlonly
|
|
*
|
|
* Definition:
|
|
* ===========
|
|
*
|
|
* SUBROUTINE DGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
|
|
*
|
|
* .. Scalar Arguments ..
|
|
* CHARACTER TRANS
|
|
* INTEGER INFO, LDA, LDB, N, NRHS
|
|
* ..
|
|
* .. Array Arguments ..
|
|
* INTEGER IPIV( * )
|
|
* DOUBLE PRECISION A( LDA, * ), B( LDB, * )
|
|
* ..
|
|
*
|
|
*
|
|
*> \par Purpose:
|
|
* =============
|
|
*>
|
|
*> \verbatim
|
|
*>
|
|
*> DGETRS solves a system of linear equations
|
|
*> A * X = B or A**T * X = B
|
|
*> with a general N-by-N matrix A using the LU factorization computed
|
|
*> by DGETRF.
|
|
*> \endverbatim
|
|
*
|
|
* Arguments:
|
|
* ==========
|
|
*
|
|
*> \param[in] TRANS
|
|
*> \verbatim
|
|
*> TRANS is CHARACTER*1
|
|
*> Specifies the form of the system of equations:
|
|
*> = 'N': A * X = B (No transpose)
|
|
*> = 'T': A**T* X = B (Transpose)
|
|
*> = 'C': A**T* X = B (Conjugate transpose = Transpose)
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] N
|
|
*> \verbatim
|
|
*> N is INTEGER
|
|
*> The order of the matrix A. N >= 0.
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] NRHS
|
|
*> \verbatim
|
|
*> NRHS is INTEGER
|
|
*> The number of right hand sides, i.e., the number of columns
|
|
*> of the matrix B. NRHS >= 0.
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] A
|
|
*> \verbatim
|
|
*> A is DOUBLE PRECISION array, dimension (LDA,N)
|
|
*> The factors L and U from the factorization A = P*L*U
|
|
*> as computed by DGETRF.
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] LDA
|
|
*> \verbatim
|
|
*> LDA is INTEGER
|
|
*> The leading dimension of the array A. LDA >= max(1,N).
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] IPIV
|
|
*> \verbatim
|
|
*> IPIV is INTEGER array, dimension (N)
|
|
*> The pivot indices from DGETRF; for 1<=i<=N, row i of the
|
|
*> matrix was interchanged with row IPIV(i).
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in,out] B
|
|
*> \verbatim
|
|
*> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
|
|
*> On entry, the right hand side matrix B.
|
|
*> On exit, the solution matrix X.
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[in] LDB
|
|
*> \verbatim
|
|
*> LDB is INTEGER
|
|
*> The leading dimension of the array B. LDB >= max(1,N).
|
|
*> \endverbatim
|
|
*>
|
|
*> \param[out] INFO
|
|
*> \verbatim
|
|
*> INFO is INTEGER
|
|
*> = 0: successful exit
|
|
*> < 0: if INFO = -i, the i-th argument had an illegal value
|
|
*> \endverbatim
|
|
*
|
|
* Authors:
|
|
* ========
|
|
*
|
|
*> \author Univ. of Tennessee
|
|
*> \author Univ. of California Berkeley
|
|
*> \author Univ. of Colorado Denver
|
|
*> \author NAG Ltd.
|
|
*
|
|
*> \date December 2016
|
|
*
|
|
*> \ingroup doubleGEcomputational
|
|
*
|
|
* =====================================================================
|
|
SUBROUTINE DGETRS( TRANS, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
|
|
*
|
|
* -- LAPACK computational routine (version 3.7.0) --
|
|
* -- LAPACK is a software package provided by Univ. of Tennessee, --
|
|
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
|
|
* December 2016
|
|
*
|
|
* .. Scalar Arguments ..
|
|
CHARACTER TRANS
|
|
INTEGER INFO, LDA, LDB, N, NRHS
|
|
* ..
|
|
* .. Array Arguments ..
|
|
INTEGER IPIV( * )
|
|
DOUBLE PRECISION A( LDA, * ), B( LDB, * )
|
|
* ..
|
|
*
|
|
* =====================================================================
|
|
*
|
|
* .. Parameters ..
|
|
DOUBLE PRECISION ONE
|
|
PARAMETER ( ONE = 1.0D+0 )
|
|
* ..
|
|
* .. Local Scalars ..
|
|
LOGICAL NOTRAN
|
|
* ..
|
|
* .. External Functions ..
|
|
LOGICAL LSAME
|
|
EXTERNAL LSAME
|
|
* ..
|
|
* .. External Subroutines ..
|
|
EXTERNAL DLASWP, DTRSM, XERBLA
|
|
* ..
|
|
* .. Intrinsic Functions ..
|
|
INTRINSIC MAX
|
|
* ..
|
|
* .. Executable Statements ..
|
|
*
|
|
* Test the input parameters.
|
|
*
|
|
INFO = 0
|
|
NOTRAN = LSAME( TRANS, 'N' )
|
|
IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
|
|
$ LSAME( TRANS, 'C' ) ) THEN
|
|
INFO = -1
|
|
ELSE IF( N.LT.0 ) THEN
|
|
INFO = -2
|
|
ELSE IF( NRHS.LT.0 ) THEN
|
|
INFO = -3
|
|
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
|
|
INFO = -5
|
|
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
|
|
INFO = -8
|
|
END IF
|
|
IF( INFO.NE.0 ) THEN
|
|
CALL XERBLA( 'DGETRS', -INFO )
|
|
RETURN
|
|
END IF
|
|
*
|
|
* Quick return if possible
|
|
*
|
|
IF( N.EQ.0 .OR. NRHS.EQ.0 )
|
|
$ RETURN
|
|
*
|
|
IF( NOTRAN ) THEN
|
|
*
|
|
* Solve A * X = B.
|
|
*
|
|
* Apply row interchanges to the right hand sides.
|
|
*
|
|
CALL DLASWP( NRHS, B, LDB, 1, N, IPIV, 1 )
|
|
*
|
|
* Solve L*X = B, overwriting B with X.
|
|
*
|
|
CALL DTRSM( 'Left', 'Lower', 'No transpose', 'Unit', N, NRHS,
|
|
$ ONE, A, LDA, B, LDB )
|
|
*
|
|
* Solve U*X = B, overwriting B with X.
|
|
*
|
|
CALL DTRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,
|
|
$ NRHS, ONE, A, LDA, B, LDB )
|
|
ELSE
|
|
*
|
|
* Solve A**T * X = B.
|
|
*
|
|
* Solve U**T *X = B, overwriting B with X.
|
|
*
|
|
CALL DTRSM( 'Left', 'Upper', 'Transpose', 'Non-unit', N, NRHS,
|
|
$ ONE, A, LDA, B, LDB )
|
|
*
|
|
* Solve L**T *X = B, overwriting B with X.
|
|
*
|
|
CALL DTRSM( 'Left', 'Lower', 'Transpose', 'Unit', N, NRHS, ONE,
|
|
$ A, LDA, B, LDB )
|
|
*
|
|
* Apply row interchanges to the solution vectors.
|
|
*
|
|
CALL DLASWP( NRHS, B, LDB, 1, N, IPIV, -1 )
|
|
END IF
|
|
*
|
|
RETURN
|
|
*
|
|
* End of DGETRS
|
|
*
|
|
END
|