Debian Codegraph @

debian/external_deps/fetk/punc/src/blas/dtrsv.c

raw
1 /* ./src_f77/dtrsv.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Subroutine */ int dtrsv_(char *uplo, char *trans, char *diag, integer *n,
9 doublereal *a, integer *lda, doublereal *x, integer *incx, ftnlen
10 uplo_len, ftnlen trans_len, ftnlen diag_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2;
14
15 /* Local variables */
16 static integer i__, j, ix, jx, kx, info;
17 static doublereal temp;
18 extern logical lsame_(char *, char *, ftnlen, ftnlen);
19 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
20 static logical nounit;
21
22 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
24 /* .. */
25
26 /* Purpose */
27 /* ======= */
28
29 /* DTRSV solves one of the systems of equations */
30
31 /* A*x = b, or A'*x = b, */
32
33 /* where b and x are n element vectors and A is an n by n unit, or */
34 /* non-unit, upper or lower triangular matrix. */
35
36 /* No test for singularity or near-singularity is included in this */
37 /* routine. Such tests must be performed before calling this routine. */
38
39 /* Parameters */
40 /* ========== */
41
42 /* UPLO - CHARACTER*1. */
43 /* On entry, UPLO specifies whether the matrix is an upper or */
44 /* lower triangular matrix as follows: */
45
46 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
47
48 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
49
50 /* Unchanged on exit. */
51
52 /* TRANS - CHARACTER*1. */
53 /* On entry, TRANS specifies the equations to be solved as */
54 /* follows: */
55
56 /* TRANS = 'N' or 'n' A*x = b. */
57
58 /* TRANS = 'T' or 't' A'*x = b. */
59
60 /* TRANS = 'C' or 'c' A'*x = b. */
61
62 /* Unchanged on exit. */
63
64 /* DIAG - CHARACTER*1. */
65 /* On entry, DIAG specifies whether or not A is unit */
66 /* triangular as follows: */
67
68 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
69
70 /* DIAG = 'N' or 'n' A is not assumed to be unit */
71 /* triangular. */
72
73 /* Unchanged on exit. */
74
75 /* N - INTEGER. */
76 /* On entry, N specifies the order of the matrix A. */
77 /* N must be at least zero. */
78 /* Unchanged on exit. */
79
80 /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
81 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
82 /* upper triangular part of the array A must contain the upper */
83 /* triangular matrix and the strictly lower triangular part of */
84 /* A is not referenced. */
85 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
86 /* lower triangular part of the array A must contain the lower */
87 /* triangular matrix and the strictly upper triangular part of */
88 /* A is not referenced. */
89 /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
90 /* A are not referenced either, but are assumed to be unity. */
91 /* Unchanged on exit. */
92
93 /* LDA - INTEGER. */
94 /* On entry, LDA specifies the first dimension of A as declared */
95 /* in the calling (sub) program. LDA must be at least */
96 /* max( 1, n ). */
97 /* Unchanged on exit. */
98
99 /* X - DOUBLE PRECISION array of dimension at least */
100 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
101 /* Before entry, the incremented array X must contain the n */
102 /* element right-hand side vector b. On exit, X is overwritten */
103 /* with the solution vector x. */
104
105 /* INCX - INTEGER. */
106 /* On entry, INCX specifies the increment for the elements of */
107 /* X. INCX must not be zero. */
108 /* Unchanged on exit. */
109
110
111 /* Level 2 Blas routine. */
112
113 /* -- Written on 22-October-1986. */
114 /* Jack Dongarra, Argonne National Lab. */
115 /* Jeremy Du Croz, Nag Central Office. */
116 /* Sven Hammarling, Nag Central Office. */
117 /* Richard Hanson, Sandia National Labs. */
118
119
120 /* .. Parameters .. */
121 /* .. Local Scalars .. */
122 /* .. External Functions .. */
123 /* .. External Subroutines .. */
124 /* .. Intrinsic Functions .. */
125 /* .. */
126 /* .. Executable Statements .. */
127
128 /* Test the input parameters. */
129
130 /* Parameter adjustments */
131 a_dim1 = *lda;
132 a_offset = 1 + a_dim1;
133 a -= a_offset;
134 --x;
135
136 /* Function Body */
137 info = 0;
138 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
139 ftnlen)1, (ftnlen)1)) {
140 info = 1;
141 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
142 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
143 ftnlen)1)) {
144 info = 2;
145 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
146 "N", (ftnlen)1, (ftnlen)1)) {
147 info = 3;
148 } else if (*n < 0) {
149 info = 4;
150 } else if (*lda < max(1,*n)) {
151 info = 6;
152 } else if (*incx == 0) {
153 info = 8;
154 }
155 if (info != 0) {
156 xerbla_("DTRSV ", &info, (ftnlen)6);
157 return 0;
158 }
159
160 /* Quick return if possible. */
161
162 if (*n == 0) {
163 return 0;
164 }
165
166 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
167
168 /* Set up the start point in X if the increment is not unity. This */
169 /* will be ( N - 1 )*INCX too small for descending loops. */
170
171 if (*incx <= 0) {
172 kx = 1 - (*n - 1) * *incx;
173 } else if (*incx != 1) {
174 kx = 1;
175 }
176
177 /* Start the operations. In this version the elements of A are */
178 /* accessed sequentially with one pass through A. */
179
180 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
181
182 /* Form x := inv( A )*x. */
183
184 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
185 if (*incx == 1) {
186 for (j = *n; j >= 1; --j) {
187 if (x[j] != 0.) {
188 if (nounit) {
189 x[j] /= a[j + j * a_dim1];
190 }
191 temp = x[j];
192 for (i__ = j - 1; i__ >= 1; --i__) {
193 x[i__] -= temp * a[i__ + j * a_dim1];
194 /* L10: */
195 }
196 }
197 /* L20: */
198 }
199 } else {
200 jx = kx + (*n - 1) * *incx;
201 for (j = *n; j >= 1; --j) {
202 if (x[jx] != 0.) {
203 if (nounit) {
204 x[jx] /= a[j + j * a_dim1];
205 }
206 temp = x[jx];
207 ix = jx;
208 for (i__ = j - 1; i__ >= 1; --i__) {
209 ix -= *incx;
210 x[ix] -= temp * a[i__ + j * a_dim1];
211 /* L30: */
212 }
213 }
214 jx -= *incx;
215 /* L40: */
216 }
217 }
218 } else {
219 if (*incx == 1) {
220 i__1 = *n;
221 for (j = 1; j <= i__1; ++j) {
222 if (x[j] != 0.) {
223 if (nounit) {
224 x[j] /= a[j + j * a_dim1];
225 }
226 temp = x[j];
227 i__2 = *n;
228 for (i__ = j + 1; i__ <= i__2; ++i__) {
229 x[i__] -= temp * a[i__ + j * a_dim1];
230 /* L50: */
231 }
232 }
233 /* L60: */
234 }
235 } else {
236 jx = kx;
237 i__1 = *n;
238 for (j = 1; j <= i__1; ++j) {
239 if (x[jx] != 0.) {
240 if (nounit) {
241 x[jx] /= a[j + j * a_dim1];
242 }
243 temp = x[jx];
244 ix = jx;
245 i__2 = *n;
246 for (i__ = j + 1; i__ <= i__2; ++i__) {
247 ix += *incx;
248 x[ix] -= temp * a[i__ + j * a_dim1];
249 /* L70: */
250 }
251 }
252 jx += *incx;
253 /* L80: */
254 }
255 }
256 }
257 } else {
258
259 /* Form x := inv( A' )*x. */
260
261 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
262 if (*incx == 1) {
263 i__1 = *n;
264 for (j = 1; j <= i__1; ++j) {
265 temp = x[j];
266 i__2 = j - 1;
267 for (i__ = 1; i__ <= i__2; ++i__) {
268 temp -= a[i__ + j * a_dim1] * x[i__];
269 /* L90: */
270 }
271 if (nounit) {
272 temp /= a[j + j * a_dim1];
273 }
274 x[j] = temp;
275 /* L100: */
276 }
277 } else {
278 jx = kx;
279 i__1 = *n;
280 for (j = 1; j <= i__1; ++j) {
281 temp = x[jx];
282 ix = kx;
283 i__2 = j - 1;
284 for (i__ = 1; i__ <= i__2; ++i__) {
285 temp -= a[i__ + j * a_dim1] * x[ix];
286 ix += *incx;
287 /* L110: */
288 }
289 if (nounit) {
290 temp /= a[j + j * a_dim1];
291 }
292 x[jx] = temp;
293 jx += *incx;
294 /* L120: */
295 }
296 }
297 } else {
298 if (*incx == 1) {
299 for (j = *n; j >= 1; --j) {
300 temp = x[j];
301 i__1 = j + 1;
302 for (i__ = *n; i__ >= i__1; --i__) {
303 temp -= a[i__ + j * a_dim1] * x[i__];
304 /* L130: */
305 }
306 if (nounit) {
307 temp /= a[j + j * a_dim1];
308 }
309 x[j] = temp;
310 /* L140: */
311 }
312 } else {
313 kx += (*n - 1) * *incx;
314 jx = kx;
315 for (j = *n; j >= 1; --j) {
316 temp = x[jx];
317 ix = kx;
318 i__1 = j + 1;
319 for (i__ = *n; i__ >= i__1; --i__) {
320 temp -= a[i__ + j * a_dim1] * x[ix];
321 ix -= *incx;
322 /* L150: */
323 }
324 if (nounit) {
325 temp /= a[j + j * a_dim1];
326 }
327 x[jx] = temp;
328 jx -= *incx;
329 /* L160: */
330 }
331 }
332 }
333 }
334
335 return 0;
336
337 /* End of DTRSV . */
338
339 } /* dtrsv_ */
340