|
kusano |
2b45e8 |
SUBROUTINE DTRTRIF( UPLO, DIAG, N, A, LDA, 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 |
* March 31, 1993
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
CHARACTER DIAG, UPLO
|
|
kusano |
2b45e8 |
INTEGER INFO, LDA, N
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION A( LDA, * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DTRTRI computes the inverse of a real upper or lower triangular
|
|
kusano |
2b45e8 |
* matrix A.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* This is the Level 3 BLAS version of the algorithm.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* =========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* = 'U': A is upper triangular;
|
|
kusano |
2b45e8 |
* = 'L': A is lower triangular.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DIAG (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* = 'N': A is non-unit triangular;
|
|
kusano |
2b45e8 |
* = 'U': A is unit triangular.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N (input) INTEGER
|
|
kusano |
2b45e8 |
* The order of the matrix A. N >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
|
|
kusano |
2b45e8 |
* On entry, the triangular matrix A. If UPLO = 'U', the
|
|
kusano |
2b45e8 |
* leading N-by-N upper triangular part of the array A contains
|
|
kusano |
2b45e8 |
* the upper triangular matrix, and the strictly lower
|
|
kusano |
2b45e8 |
* triangular part of A is not referenced. If UPLO = 'L', the
|
|
kusano |
2b45e8 |
* leading N-by-N lower triangular part of the array A contains
|
|
kusano |
2b45e8 |
* the lower triangular matrix, and the strictly upper
|
|
kusano |
2b45e8 |
* triangular part of A is not referenced. If DIAG = 'U', the
|
|
kusano |
2b45e8 |
* diagonal elements of A are also not referenced and are
|
|
kusano |
2b45e8 |
* assumed to be 1.
|
|
kusano |
2b45e8 |
* On exit, the (triangular) inverse of the original matrix, in
|
|
kusano |
2b45e8 |
* the same storage format.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA (input) INTEGER
|
|
kusano |
2b45e8 |
* The leading dimension of the array A. LDA >= 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 |
* > 0: if INFO = i, A(i,i) is exactly zero. The triangular
|
|
kusano |
2b45e8 |
* matrix is singular and its inverse can not be computed.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION ONE, ZERO
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
LOGICAL NOUNIT, UPPER
|
|
kusano |
2b45e8 |
INTEGER J, JB, NB, NN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL DTRMM, DTRSM, DTRTI2, XERBLA
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC MAX, MIN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
UPPER = LSAME( UPLO, 'U' )
|
|
kusano |
2b45e8 |
NOUNIT = LSAME( DIAG, 'N' )
|
|
kusano |
2b45e8 |
IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -1
|
|
kusano |
2b45e8 |
ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -2
|
|
kusano |
2b45e8 |
ELSE IF( N.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = -3
|
|
kusano |
2b45e8 |
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -5
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 ) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'DTRTRI', -INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( N.EQ.0 )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Check for singularity if non-unit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( NOUNIT ) THEN
|
|
kusano |
2b45e8 |
DO 10 INFO = 1, N
|
|
kusano |
2b45e8 |
IF( A( INFO, INFO ).EQ.ZERO )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Determine the block size for this environment.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
NB = 128
|
|
kusano |
2b45e8 |
IF( NB.LE.1 .OR. NB.GE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use unblocked code
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRTI2( UPLO, DIAG, N, A, LDA, INFO )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use blocked code
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( UPPER ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of upper triangular matrix
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 20 J = 1, N, NB
|
|
kusano |
2b45e8 |
JB = MIN( NB, N-J+1 )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute rows 1:j-1 of current block column
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRMM( 'Left', 'Upper', 'No transpose', DIAG, J-1,
|
|
kusano |
2b45e8 |
$ JB, ONE, A, LDA, A( 1, J ), LDA )
|
|
kusano |
2b45e8 |
CALL DTRSM( 'Right', 'Upper', 'No transpose', DIAG, J-1,
|
|
kusano |
2b45e8 |
$ JB, -ONE, A( J, J ), LDA, A( 1, J ), LDA )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of current diagonal block
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRTI2( 'Upper', DIAG, JB, A( J, J ), LDA, INFO )
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of lower triangular matrix
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
NN = ( ( N-1 ) / NB )*NB + 1
|
|
kusano |
2b45e8 |
DO 30 J = NN, 1, -NB
|
|
kusano |
2b45e8 |
JB = MIN( NB, N-J+1 )
|
|
kusano |
2b45e8 |
IF( J+JB.LE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute rows j+jb:n of current block column
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRMM( 'Left', 'Lower', 'No transpose', DIAG,
|
|
kusano |
2b45e8 |
$ N-J-JB+1, JB, ONE, A( J+JB, J+JB ), LDA,
|
|
kusano |
2b45e8 |
$ A( J+JB, J ), LDA )
|
|
kusano |
2b45e8 |
CALL DTRSM( 'Right', 'Lower', 'No transpose', DIAG,
|
|
kusano |
2b45e8 |
$ N-J-JB+1, JB, -ONE, A( J, J ), LDA,
|
|
kusano |
2b45e8 |
$ A( J+JB, J ), LDA )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of current diagonal block
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRTI2( 'Lower', DIAG, JB, A( J, J ), LDA, INFO )
|
|
kusano |
2b45e8 |
30 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of DTRTRI
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|