|
kusano |
2b45e8 |
SUBROUTINE DTRTI2F( UPLO, DIAG, N, A, LDA, INFO )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- LAPACK routine (version 3.1) --
|
|
kusano |
2b45e8 |
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
|
|
kusano |
2b45e8 |
* November 2006
|
|
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 |
* DTRTI2 computes the inverse of a real upper or lower triangular
|
|
kusano |
2b45e8 |
* matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* This is the Level 2 BLAS version of the algorithm.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* =========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* Specifies whether the matrix A is upper or lower triangular.
|
|
kusano |
2b45e8 |
* = 'U': Upper triangular
|
|
kusano |
2b45e8 |
* = 'L': Lower triangular
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DIAG (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* Specifies whether or not the matrix A is unit triangular.
|
|
kusano |
2b45e8 |
* = 'N': Non-unit triangular
|
|
kusano |
2b45e8 |
* = 'U': 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 |
*
|
|
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 = -k, the k-th argument had an illegal value
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION ONE
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = 1.0D+0 )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
LOGICAL NOUNIT, UPPER
|
|
kusano |
2b45e8 |
INTEGER J
|
|
kusano |
2b45e8 |
DOUBLE PRECISION AJJ
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL DSCAL, DTRMV, XERBLA
|
|
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 |
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( 'DTRTI2', -INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( UPPER ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of upper triangular matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 10 J = 1, N
|
|
kusano |
2b45e8 |
IF( NOUNIT ) THEN
|
|
kusano |
2b45e8 |
A( J, J ) = ONE / A( J, J )
|
|
kusano |
2b45e8 |
AJJ = -A( J, J )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AJJ = -ONE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute elements 1:j-1 of j-th column.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRMV( 'Upper', 'No transpose', DIAG, J-1, A, LDA,
|
|
kusano |
2b45e8 |
$ A( 1, J ), 1 )
|
|
kusano |
2b45e8 |
CALL DSCAL( J-1, AJJ, A( 1, J ), 1 )
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute inverse of lower triangular matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 20 J = N, 1, -1
|
|
kusano |
2b45e8 |
IF( NOUNIT ) THEN
|
|
kusano |
2b45e8 |
A( J, J ) = ONE / A( J, J )
|
|
kusano |
2b45e8 |
AJJ = -A( J, J )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AJJ = -ONE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( J.LT.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute elements j+1:n of j-th column.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL DTRMV( 'Lower', 'No transpose', DIAG, N-J,
|
|
kusano |
2b45e8 |
$ A( J+1, J+1 ), LDA, A( J+1, J ), 1 )
|
|
kusano |
2b45e8 |
CALL DSCAL( N-J, AJJ, A( J+1, J ), 1 )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of DTRTI2
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|