3 /* Table of constant values */
5 static integer c__1 = 1;
6 static integer c_n1 = -1;
7 static integer c__2 = 2;
8 static doublereal c_b18 = 1.;
9 static doublereal c_b22 = -1.;
11 /* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *
12 a, integer *lda, integer *info)
14 /* System generated locals */
16 integer a_dim1, a_offset, i__1, i__2[2], i__3, i__4, i__5;
19 /* Builtin functions */
20 /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
23 integer j, jb, nb, nn;
24 extern logical lsame_(char *, char *);
25 extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *,
26 integer *, integer *, doublereal *, doublereal *, integer *,
27 doublereal *, integer *), dtrsm_(
28 char *, char *, char *, char *, integer *, integer *, doublereal *
29 , doublereal *, integer *, doublereal *, integer *);
31 extern /* Subroutine */ int dtrti2_(char *, char *, integer *, doublereal
32 *, integer *, integer *), xerbla_(char *, integer
34 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
35 integer *, integer *);
39 /* -- LAPACK routine (version 3.1) -- */
40 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
43 /* .. Scalar Arguments .. */
45 /* .. Array Arguments .. */
51 /* DTRTRI computes the inverse of a real upper or lower triangular */
54 /* This is the Level 3 BLAS version of the algorithm. */
59 /* UPLO (input) CHARACTER*1 */
60 /* = 'U': A is upper triangular; */
61 /* = 'L': A is lower triangular. */
63 /* DIAG (input) CHARACTER*1 */
64 /* = 'N': A is non-unit triangular; */
65 /* = 'U': A is unit triangular. */
67 /* N (input) INTEGER */
68 /* The order of the matrix A. N >= 0. */
70 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
71 /* On entry, the triangular matrix A. If UPLO = 'U', the */
72 /* leading N-by-N upper triangular part of the array A contains */
73 /* the upper triangular matrix, and the strictly lower */
74 /* triangular part of A is not referenced. If UPLO = 'L', the */
75 /* leading N-by-N lower triangular part of the array A contains */
76 /* the lower triangular matrix, and the strictly upper */
77 /* triangular part of A is not referenced. If DIAG = 'U', the */
78 /* diagonal elements of A are also not referenced and are */
79 /* assumed to be 1. */
80 /* On exit, the (triangular) inverse of the original matrix, in */
81 /* the same storage format. */
83 /* LDA (input) INTEGER */
84 /* The leading dimension of the array A. LDA >= max(1,N). */
86 /* INFO (output) INTEGER */
87 /* = 0: successful exit */
88 /* < 0: if INFO = -i, the i-th argument had an illegal value */
89 /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */
90 /* matrix is singular and its inverse can not be computed. */
92 /* ===================================================================== */
94 /* .. Parameters .. */
96 /* .. Local Scalars .. */
98 /* .. External Functions .. */
100 /* .. External Subroutines .. */
102 /* .. Intrinsic Functions .. */
104 /* .. Executable Statements .. */
106 /* Test the input parameters. */
108 /* Parameter adjustments */
110 a_offset = 1 + a_dim1;
115 upper = lsame_(uplo, "U");
116 nounit = lsame_(diag, "N");
117 if (! upper && ! lsame_(uplo, "L")) {
119 } else if (! nounit && ! lsame_(diag, "U")) {
123 } else if (*lda < max(1,*n)) {
128 xerbla_("DTRTRI", &i__1);
132 /* Quick return if possible */
138 /* Check for singularity if non-unit. */
142 for (*info = 1; *info <= i__1; ++(*info)) {
143 if (a[*info + *info * a_dim1] == 0.) {
151 /* Determine the block size for this environment. */
153 /* Writing concatenation */
154 i__2[0] = 1, a__1[0] = uplo;
155 i__2[1] = 1, a__1[1] = diag;
156 s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
157 nb = ilaenv_(&c__1, "DTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
158 if (nb <= 1 || nb >= *n) {
160 /* Use unblocked code */
162 dtrti2_(uplo, diag, n, &a[a_offset], lda, info);
165 /* Use blocked code */
169 /* Compute inverse of upper triangular matrix */
173 for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
175 i__4 = nb, i__5 = *n - j + 1;
178 /* Compute rows 1:j-1 of current block column */
181 dtrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
182 c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
184 dtrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
185 c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1],
188 /* Compute inverse of current diagonal block */
190 dtrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
195 /* Compute inverse of lower triangular matrix */
197 nn = (*n - 1) / nb * nb + 1;
199 for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
201 i__1 = nb, i__4 = *n - j + 1;
205 /* Compute rows j+jb:n of current block column */
207 i__1 = *n - j - jb + 1;
208 dtrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb,
209 &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j
210 + jb + j * a_dim1], lda);
211 i__1 = *n - j - jb + 1;
212 dtrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb,
213 &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j *
217 /* Compute inverse of current diagonal block */
219 dtrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);