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 real c_b18 = 1.f;
9 static real c_b22 = -1.f;
11 /* Subroutine */ int strtri_(char *uplo, char *diag, integer *n, real *a,
12 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 *);
26 extern /* Subroutine */ int strmm_(char *, char *, char *, char *,
27 integer *, integer *, real *, real *, integer *, real *, integer *
28 ), strsm_(char *, char *, char *,
29 char *, integer *, integer *, real *, real *, integer *, real *,
30 integer *), strti2_(char *, char *
31 , integer *, real *, integer *, integer *),
32 xerbla_(char *, integer *);
33 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
34 integer *, integer *);
38 /* -- LAPACK routine (version 3.1) -- */
39 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
42 /* .. Scalar Arguments .. */
44 /* .. Array Arguments .. */
50 /* STRTRI computes the inverse of a real upper or lower triangular */
53 /* This is the Level 3 BLAS version of the algorithm. */
58 /* UPLO (input) CHARACTER*1 */
59 /* = 'U': A is upper triangular; */
60 /* = 'L': A is lower triangular. */
62 /* DIAG (input) CHARACTER*1 */
63 /* = 'N': A is non-unit triangular; */
64 /* = 'U': A is unit triangular. */
66 /* N (input) INTEGER */
67 /* The order of the matrix A. N >= 0. */
69 /* A (input/output) REAL array, dimension (LDA,N) */
70 /* On entry, the triangular matrix A. If UPLO = 'U', the */
71 /* leading N-by-N upper triangular part of the array A contains */
72 /* the upper triangular matrix, and the strictly lower */
73 /* triangular part of A is not referenced. If UPLO = 'L', the */
74 /* leading N-by-N lower triangular part of the array A contains */
75 /* the lower triangular matrix, and the strictly upper */
76 /* triangular part of A is not referenced. If DIAG = 'U', the */
77 /* diagonal elements of A are also not referenced and are */
78 /* assumed to be 1. */
79 /* On exit, the (triangular) inverse of the original matrix, in */
80 /* the same storage format. */
82 /* LDA (input) INTEGER */
83 /* The leading dimension of the array A. LDA >= max(1,N). */
85 /* INFO (output) INTEGER */
86 /* = 0: successful exit */
87 /* < 0: if INFO = -i, the i-th argument had an illegal value */
88 /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */
89 /* matrix is singular and its inverse can not be computed. */
91 /* ===================================================================== */
93 /* .. Parameters .. */
95 /* .. Local Scalars .. */
97 /* .. External Functions .. */
99 /* .. External Subroutines .. */
101 /* .. Intrinsic Functions .. */
103 /* .. Executable Statements .. */
105 /* Test the input parameters. */
107 /* Parameter adjustments */
109 a_offset = 1 + a_dim1;
114 upper = lsame_(uplo, "U");
115 nounit = lsame_(diag, "N");
116 if (! upper && ! lsame_(uplo, "L")) {
118 } else if (! nounit && ! lsame_(diag, "U")) {
122 } else if (*lda < max(1,*n)) {
127 xerbla_("STRTRI", &i__1);
131 /* Quick return if possible */
137 /* Check for singularity if non-unit. */
141 for (*info = 1; *info <= i__1; ++(*info)) {
142 if (a[*info + *info * a_dim1] == 0.f) {
150 /* Determine the block size for this environment. */
152 /* Writing concatenation */
153 i__2[0] = 1, a__1[0] = uplo;
154 i__2[1] = 1, a__1[1] = diag;
155 s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
156 nb = ilaenv_(&c__1, "STRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
157 if (nb <= 1 || nb >= *n) {
159 /* Use unblocked code */
161 strti2_(uplo, diag, n, &a[a_offset], lda, info);
164 /* Use blocked code */
168 /* Compute inverse of upper triangular matrix */
172 for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
174 i__4 = nb, i__5 = *n - j + 1;
177 /* Compute rows 1:j-1 of current block column */
180 strmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
181 c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
183 strsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
184 c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1],
187 /* Compute inverse of current diagonal block */
189 strti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
194 /* Compute inverse of lower triangular matrix */
196 nn = (*n - 1) / nb * nb + 1;
198 for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
200 i__1 = nb, i__4 = *n - j + 1;
204 /* Compute rows j+jb:n of current block column */
206 i__1 = *n - j - jb + 1;
207 strmm_("Left", "Lower", "No transpose", diag, &i__1, &jb,
208 &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j
209 + jb + j * a_dim1], lda);
210 i__1 = *n - j - jb + 1;
211 strsm_("Right", "Lower", "No transpose", diag, &i__1, &jb,
212 &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j *
216 /* Compute inverse of current diagonal block */
218 strti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);