1 SUBROUTINE DTRTI2
( 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 * DTRTI2 computes the inverse of a
real upper or lower triangular
21 * This is the Level
2 BLAS version of the algorithm
.
26 * UPLO
(input
) CHARACTER*1
27 * Specifies whether the matrix A is upper or lower triangular
.
28 * = 'U': Upper triangular
29 * = 'L': Lower triangular
31 * DIAG
(input
) CHARACTER*1
32 * Specifies whether or not the matrix A is unit triangular
.
33 * = 'N': Non
-unit triangular
34 * = 'U': Unit triangular
37 * The order of the matrix A
. N
>= 0.
39 * A
(input
/output
) DOUBLE PRECISION array
, dimension (LDA
,N
)
40 * On entry
, the triangular matrix A
. If UPLO
= 'U', the
41 * leading n by n upper triangular part of the array A contains
42 * the upper triangular matrix
, and the strictly lower
43 * triangular part of A is not referenced
. If UPLO
= 'L', the
44 * leading n by n lower triangular part of the array A contains
45 * the lower triangular matrix
, and the strictly upper
46 * triangular part of A is not referenced
. If DIAG
= 'U', the
47 * diagonal elements of A are also not referenced and are
50 * On exit
, the
(triangular
) inverse of the original matrix
, in
51 * the same storage
format.
54 * The leading
dimension of the array A
. LDA
>= max
(1,N
).
56 * INFO
(output
) INTEGER
57 * = 0: successful exit
58 * < 0: if INFO
= -k
, the k
-th argument had an illegal value
60 * =====================================================================
64 PARAMETER ( ONE
= 1.0D
+0 )
71 * .. External Functions
..
75 * .. External Subroutines
..
76 EXTERNAL DSCAL
, DTRMV
, XERBLA
78 * .. Intrinsic Functions
..
81 * .. Executable Statements
..
83 * Test the input parameters
.
86 UPPER
= LSAME
( UPLO
, 'U' )
87 NOUNIT
= LSAME
( DIAG
, 'N' )
88 IF( .NOT
.UPPER
.AND
. .NOT
.LSAME
( UPLO
, 'L' ) ) THEN
90 ELSE IF( .NOT
.NOUNIT
.AND
. .NOT
.LSAME
( DIAG
, 'U' ) ) THEN
92 ELSE IF( N
.LT
.0 ) THEN
94 ELSE IF( LDA
.LT
.MAX
( 1, N
) ) THEN
98 CALL XERBLA
( 'DTRTI2', -INFO
)
104 * Compute inverse of upper triangular matrix
.
108 A
( J
, J
) = ONE
/ A
( J
, J
)
114 * Compute elements
1:j
-1 of j
-th column
.
116 CALL DTRMV
( 'Upper', 'No transpose', DIAG
, J
-1, A
, LDA
,
118 CALL DSCAL
( J
-1, AJJ
, A
( 1, J
), 1 )
122 * Compute inverse of lower triangular matrix
.
126 A
( J
, J
) = ONE
/ A
( J
, J
)
133 * Compute elements j
+1:n of j
-th column
.
135 CALL DTRMV
( 'Lower', 'No transpose', DIAG
, N
-J
,
136 $ A
( J
+1, J
+1 ), LDA
, A
( J
+1, J
), 1 )
137 CALL DSCAL
( N
-J
, AJJ
, A
( J
+1, J
), 1 )