1 SUBROUTINE DTRTRI
( UPLO
, DIAG
, N
, A
, LDA
, INFO
)
3 * -- LAPACK routine
(version
3.1) --
4 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
7 * .. Scalar Arguments
..
11 * .. Array Arguments
..
12 DOUBLE PRECISION A
( LDA
, * )
18 * DTRTRI computes the inverse of a
real upper or lower triangular
21 * This is the Level
3 BLAS version of the algorithm
.
26 * UPLO
(input
) CHARACTER*1
27 * = 'U': A is upper triangular
;
28 * = 'L': A is lower triangular
.
30 * DIAG
(input
) CHARACTER*1
31 * = 'N': A is non
-unit triangular
;
32 * = 'U': A is unit triangular
.
35 * The order of the matrix A
. N
>= 0.
37 * A
(input
/output
) DOUBLE PRECISION array
, dimension (LDA
,N
)
38 * On entry
, the triangular matrix A
. If UPLO
= 'U', the
39 * leading N
-by
-N upper triangular part of the array A contains
40 * the upper triangular matrix
, and the strictly lower
41 * triangular part of A is not referenced
. If UPLO
= 'L', the
42 * leading N
-by
-N lower triangular part of the array A contains
43 * the lower triangular matrix
, and the strictly upper
44 * triangular part of A is not referenced
. If DIAG
= 'U', the
45 * diagonal elements of A are also not referenced and are
47 * On exit
, the
(triangular
) inverse of the original matrix
, in
48 * the same storage
format.
51 * The leading
dimension of the array A
. LDA
>= max
(1,N
).
53 * INFO
(output
) INTEGER
54 * = 0: successful exit
55 * < 0: if INFO
= -i
, the i
-th argument had an illegal value
56 * > 0: if INFO
= i
, A
(i
,i
) is exactly zero
. The triangular
57 * matrix is singular and its inverse can not be computed
.
59 * =====================================================================
62 DOUBLE PRECISION ONE
, ZERO
63 PARAMETER ( ONE
= 1.0D
+0, ZERO
= 0.0D
+0 )
69 * .. External Functions
..
72 EXTERNAL LSAME
, ILAENV
74 * .. External Subroutines
..
75 EXTERNAL DTRMM
, DTRSM
, DTRTI2
, XERBLA
77 * .. Intrinsic Functions
..
80 * .. Executable Statements
..
82 * Test the input parameters
.
85 UPPER
= LSAME
( UPLO
, 'U' )
86 NOUNIT
= LSAME
( DIAG
, 'N' )
87 IF( .NOT
.UPPER
.AND
. .NOT
.LSAME
( UPLO
, 'L' ) ) THEN
89 ELSE IF( .NOT
.NOUNIT
.AND
. .NOT
.LSAME
( DIAG
, 'U' ) ) THEN
91 ELSE IF( N
.LT
.0 ) THEN
93 ELSE IF( LDA
.LT
.MAX
( 1, N
) ) THEN
97 CALL XERBLA
( 'DTRTRI', -INFO
)
101 * Quick
return if possible
106 * Check
for singularity
if non
-unit
.
110 IF( A
( INFO
, INFO
).EQ
.ZERO
)
116 * Determine the block size
for this environment
.
118 NB
= ILAENV
( 1, 'DTRTRI', UPLO
// DIAG
, N
, -1, -1, -1 )
119 IF( NB
.LE
.1 .OR
. NB
.GE
.N
) THEN
123 CALL DTRTI2
( UPLO
, DIAG
, N
, A
, LDA
, INFO
)
130 * Compute inverse of upper triangular matrix
133 JB
= MIN
( NB
, N
-J
+1 )
135 * Compute rows
1:j
-1 of current block column
137 CALL DTRMM
( 'Left', 'Upper', 'No transpose', DIAG
, J
-1,
138 $ JB
, ONE
, A
, LDA
, A
( 1, J
), LDA
)
139 CALL DTRSM
( 'Right', 'Upper', 'No transpose', DIAG
, J
-1,
140 $ JB
, -ONE
, A
( J
, J
), LDA
, A
( 1, J
), LDA
)
142 * Compute inverse of current diagonal block
144 CALL DTRTI2
( 'Upper', DIAG
, JB
, A
( J
, J
), LDA
, INFO
)
148 * Compute inverse of lower triangular matrix
150 NN
= ( ( N
-1 ) / NB
)*NB
+ 1
152 JB
= MIN
( NB
, N
-J
+1 )
155 * Compute rows j
+jb
:n of current block column
157 CALL DTRMM
( 'Left', 'Lower', 'No transpose', DIAG
,
158 $ N
-J
-JB
+1, JB
, ONE
, A
( J
+JB
, J
+JB
), LDA
,
159 $ A
( J
+JB
, J
), LDA
)
160 CALL DTRSM
( 'Right', 'Lower', 'No transpose', DIAG
,
161 $ N
-J
-JB
+1, JB
, -ONE
, A
( J
, J
), LDA
,
162 $ A
( J
+JB
, J
), LDA
)
165 * Compute inverse of current diagonal block
167 CALL DTRTI2
( 'Lower', DIAG
, JB
, A
( J
, J
), LDA
, INFO
)