comparison ext/clapack/src/dtrtri.c @ 430:335af74a25b6

Merge from branch clapack-included
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 30 Sep 2016 16:24:24 +0100
parents 905e45637745
children
comparison
equal deleted inserted replaced
426:a23b9f8b4a59 430:335af74a25b6
1 /* dtrtri.f -- translated by f2c (version 20061008).
2 You must link the resulting object file with libf2c:
3 on Microsoft Windows system, link with libf2c.lib;
4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5 or, if you install libf2c.a in a standard place, with -lf2c -lm
6 -- in that order, at the end of the command line, as in
7 cc *.o -lf2c -lm
8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
9
10 http://www.netlib.org/f2c/libf2c.zip
11 */
12
13 #include "f2c.h"
14 #include "blaswrap.h"
15
16 /* Table of constant values */
17
18 static integer c__1 = 1;
19 static integer c_n1 = -1;
20 static integer c__2 = 2;
21 static doublereal c_b18 = 1.;
22 static doublereal c_b22 = -1.;
23
24 /* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *
25 a, integer *lda, integer *info)
26 {
27 /* System generated locals */
28 address a__1[2];
29 integer a_dim1, a_offset, i__1, i__2[2], i__3, i__4, i__5;
30 char ch__1[2];
31
32 /* Builtin functions */
33 /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
34
35 /* Local variables */
36 integer j, jb, nb, nn;
37 extern logical lsame_(char *, char *);
38 extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *,
39 integer *, integer *, doublereal *, doublereal *, integer *,
40 doublereal *, integer *), dtrsm_(
41 char *, char *, char *, char *, integer *, integer *, doublereal *
42 , doublereal *, integer *, doublereal *, integer *);
43 logical upper;
44 extern /* Subroutine */ int dtrti2_(char *, char *, integer *, doublereal
45 *, integer *, integer *), xerbla_(char *, integer
46 *);
47 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
48 integer *, integer *);
49 logical nounit;
50
51
52 /* -- LAPACK routine (version 3.2) -- */
53 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
54 /* November 2006 */
55
56 /* .. Scalar Arguments .. */
57 /* .. */
58 /* .. Array Arguments .. */
59 /* .. */
60
61 /* Purpose */
62 /* ======= */
63
64 /* DTRTRI computes the inverse of a real upper or lower triangular */
65 /* matrix A. */
66
67 /* This is the Level 3 BLAS version of the algorithm. */
68
69 /* Arguments */
70 /* ========= */
71
72 /* UPLO (input) CHARACTER*1 */
73 /* = 'U': A is upper triangular; */
74 /* = 'L': A is lower triangular. */
75
76 /* DIAG (input) CHARACTER*1 */
77 /* = 'N': A is non-unit triangular; */
78 /* = 'U': A is unit triangular. */
79
80 /* N (input) INTEGER */
81 /* The order of the matrix A. N >= 0. */
82
83 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
84 /* On entry, the triangular matrix A. If UPLO = 'U', the */
85 /* leading N-by-N upper triangular part of the array A contains */
86 /* the upper triangular matrix, and the strictly lower */
87 /* triangular part of A is not referenced. If UPLO = 'L', the */
88 /* leading N-by-N lower triangular part of the array A contains */
89 /* the lower triangular matrix, and the strictly upper */
90 /* triangular part of A is not referenced. If DIAG = 'U', the */
91 /* diagonal elements of A are also not referenced and are */
92 /* assumed to be 1. */
93 /* On exit, the (triangular) inverse of the original matrix, in */
94 /* the same storage format. */
95
96 /* LDA (input) INTEGER */
97 /* The leading dimension of the array A. LDA >= max(1,N). */
98
99 /* INFO (output) INTEGER */
100 /* = 0: successful exit */
101 /* < 0: if INFO = -i, the i-th argument had an illegal value */
102 /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */
103 /* matrix is singular and its inverse can not be computed. */
104
105 /* ===================================================================== */
106
107 /* .. Parameters .. */
108 /* .. */
109 /* .. Local Scalars .. */
110 /* .. */
111 /* .. External Functions .. */
112 /* .. */
113 /* .. External Subroutines .. */
114 /* .. */
115 /* .. Intrinsic Functions .. */
116 /* .. */
117 /* .. Executable Statements .. */
118
119 /* Test the input parameters. */
120
121 /* Parameter adjustments */
122 a_dim1 = *lda;
123 a_offset = 1 + a_dim1;
124 a -= a_offset;
125
126 /* Function Body */
127 *info = 0;
128 upper = lsame_(uplo, "U");
129 nounit = lsame_(diag, "N");
130 if (! upper && ! lsame_(uplo, "L")) {
131 *info = -1;
132 } else if (! nounit && ! lsame_(diag, "U")) {
133 *info = -2;
134 } else if (*n < 0) {
135 *info = -3;
136 } else if (*lda < max(1,*n)) {
137 *info = -5;
138 }
139 if (*info != 0) {
140 i__1 = -(*info);
141 xerbla_("DTRTRI", &i__1);
142 return 0;
143 }
144
145 /* Quick return if possible */
146
147 if (*n == 0) {
148 return 0;
149 }
150
151 /* Check for singularity if non-unit. */
152
153 if (nounit) {
154 i__1 = *n;
155 for (*info = 1; *info <= i__1; ++(*info)) {
156 if (a[*info + *info * a_dim1] == 0.) {
157 return 0;
158 }
159 /* L10: */
160 }
161 *info = 0;
162 }
163
164 /* Determine the block size for this environment. */
165
166 /* Writing concatenation */
167 i__2[0] = 1, a__1[0] = uplo;
168 i__2[1] = 1, a__1[1] = diag;
169 s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
170 nb = ilaenv_(&c__1, "DTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
171 if (nb <= 1 || nb >= *n) {
172
173 /* Use unblocked code */
174
175 dtrti2_(uplo, diag, n, &a[a_offset], lda, info);
176 } else {
177
178 /* Use blocked code */
179
180 if (upper) {
181
182 /* Compute inverse of upper triangular matrix */
183
184 i__1 = *n;
185 i__3 = nb;
186 for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
187 /* Computing MIN */
188 i__4 = nb, i__5 = *n - j + 1;
189 jb = min(i__4,i__5);
190
191 /* Compute rows 1:j-1 of current block column */
192
193 i__4 = j - 1;
194 dtrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
195 c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
196 i__4 = j - 1;
197 dtrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
198 c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1],
199 lda);
200
201 /* Compute inverse of current diagonal block */
202
203 dtrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
204 /* L20: */
205 }
206 } else {
207
208 /* Compute inverse of lower triangular matrix */
209
210 nn = (*n - 1) / nb * nb + 1;
211 i__3 = -nb;
212 for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
213 /* Computing MIN */
214 i__1 = nb, i__4 = *n - j + 1;
215 jb = min(i__1,i__4);
216 if (j + jb <= *n) {
217
218 /* Compute rows j+jb:n of current block column */
219
220 i__1 = *n - j - jb + 1;
221 dtrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb,
222 &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j
223 + jb + j * a_dim1], lda);
224 i__1 = *n - j - jb + 1;
225 dtrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb,
226 &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j *
227 a_dim1], lda);
228 }
229
230 /* Compute inverse of current diagonal block */
231
232 dtrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
233 /* L30: */
234 }
235 }
236 }
237
238 return 0;
239
240 /* End of DTRTRI */
241
242 } /* dtrtri_ */