Debian Codegraph @

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

raw
1 /* ./src_f77/ctrsv.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 ctrsv_(char *uplo, char *trans, char *diag, integer *n,
9 realcomplex *a, integer *lda, realcomplex *x, integer *incx, ftnlen uplo_len,
10 ftnlen trans_len, ftnlen diag_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
14 realcomplex q__1, q__2, q__3;
15
16 /* Builtin functions */
17 void c_div(realcomplex *, realcomplex *, realcomplex *), r_cnjg(realcomplex *, realcomplex *);
18
19 /* Local variables */
20 static integer i__, j, ix, jx, kx, info;
21 static realcomplex temp;
22 extern logical lsame_(char *, char *, ftnlen, ftnlen);
23 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
24 static logical noconj, nounit;
25
26 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
28 /* .. */
29
30 /* Purpose */
31 /* ======= */
32
33 /* CTRSV solves one of the systems of equations */
34
35 /* A*x = b, or A'*x = b, or conjg( A' )*x = b, */
36
37 /* where b and x are n element vectors and A is an n by n unit, or */
38 /* non-unit, upper or lower triangular matrix. */
39
40 /* No test for singularity or near-singularity is included in this */
41 /* routine. Such tests must be performed before calling this routine. */
42
43 /* Parameters */
44 /* ========== */
45
46 /* UPLO - CHARACTER*1. */
47 /* On entry, UPLO specifies whether the matrix is an upper or */
48 /* lower triangular matrix as follows: */
49
50 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
51
52 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
53
54 /* Unchanged on exit. */
55
56 /* TRANS - CHARACTER*1. */
57 /* On entry, TRANS specifies the equations to be solved as */
58 /* follows: */
59
60 /* TRANS = 'N' or 'n' A*x = b. */
61
62 /* TRANS = 'T' or 't' A'*x = b. */
63
64 /* TRANS = 'C' or 'c' conjg( A' )*x = b. */
65
66 /* Unchanged on exit. */
67
68 /* DIAG - CHARACTER*1. */
69 /* On entry, DIAG specifies whether or not A is unit */
70 /* triangular as follows: */
71
72 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
73
74 /* DIAG = 'N' or 'n' A is not assumed to be unit */
75 /* triangular. */
76
77 /* Unchanged on exit. */
78
79 /* N - INTEGER. */
80 /* On entry, N specifies the order of the matrix A. */
81 /* N must be at least zero. */
82 /* Unchanged on exit. */
83
84 /* A - COMPLEX array of DIMENSION ( LDA, n ). */
85 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
86 /* upper triangular part of the array A must contain the upper */
87 /* triangular matrix and the strictly lower triangular part of */
88 /* A is not referenced. */
89 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
90 /* lower triangular part of the array A must contain the lower */
91 /* triangular matrix and the strictly upper triangular part of */
92 /* A is not referenced. */
93 /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
94 /* A are not referenced either, but are assumed to be unity. */
95 /* Unchanged on exit. */
96
97 /* LDA - INTEGER. */
98 /* On entry, LDA specifies the first dimension of A as declared */
99 /* in the calling (sub) program. LDA must be at least */
100 /* max( 1, n ). */
101 /* Unchanged on exit. */
102
103 /* X - COMPLEX array of dimension at least */
104 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
105 /* Before entry, the incremented array X must contain the n */
106 /* element right-hand side vector b. On exit, X is overwritten */
107 /* with the solution vector x. */
108
109 /* INCX - INTEGER. */
110 /* On entry, INCX specifies the increment for the elements of */
111 /* X. INCX must not be zero. */
112 /* Unchanged on exit. */
113
114
115 /* Level 2 Blas routine. */
116
117 /* -- Written on 22-October-1986. */
118 /* Jack Dongarra, Argonne National Lab. */
119 /* Jeremy Du Croz, Nag Central Office. */
120 /* Sven Hammarling, Nag Central Office. */
121 /* Richard Hanson, Sandia National Labs. */
122
123
124 /* .. Parameters .. */
125 /* .. Local Scalars .. */
126 /* .. External Functions .. */
127 /* .. External Subroutines .. */
128 /* .. Intrinsic Functions .. */
129 /* .. */
130 /* .. Executable Statements .. */
131
132 /* Test the input parameters. */
133
134 /* Parameter adjustments */
135 a_dim1 = *lda;
136 a_offset = 1 + a_dim1;
137 a -= a_offset;
138 --x;
139
140 /* Function Body */
141 info = 0;
142 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
143 ftnlen)1, (ftnlen)1)) {
144 info = 1;
145 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
146 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
147 ftnlen)1)) {
148 info = 2;
149 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
150 "N", (ftnlen)1, (ftnlen)1)) {
151 info = 3;
152 } else if (*n < 0) {
153 info = 4;
154 } else if (*lda < max(1,*n)) {
155 info = 6;
156 } else if (*incx == 0) {
157 info = 8;
158 }
159 if (info != 0) {
160 xerbla_("CTRSV ", &info, (ftnlen)6);
161 return 0;
162 }
163
164 /* Quick return if possible. */
165
166 if (*n == 0) {
167 return 0;
168 }
169
170 noconj = lsame_(trans, "T", (ftnlen)1, (ftnlen)1);
171 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
172
173 /* Set up the start point in X if the increment is not unity. This */
174 /* will be ( N - 1 )*INCX too small for descending loops. */
175
176 if (*incx <= 0) {
177 kx = 1 - (*n - 1) * *incx;
178 } else if (*incx != 1) {
179 kx = 1;
180 }
181
182 /* Start the operations. In this version the elements of A are */
183 /* accessed sequentially with one pass through A. */
184
185 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
186
187 /* Form x := inv( A )*x. */
188
189 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
190 if (*incx == 1) {
191 for (j = *n; j >= 1; --j) {
192 i__1 = j;
193 if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
194 if (nounit) {
195 i__1 = j;
196 c_div(&q__1, &x[j], &a[j + j * a_dim1]);
197 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
198 }
199 i__1 = j;
200 temp.r = x[i__1].r, temp.i = x[i__1].i;
201 for (i__ = j - 1; i__ >= 1; --i__) {
202 i__1 = i__;
203 i__2 = i__;
204 i__3 = i__ + j * a_dim1;
205 q__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
206 q__2.i = temp.r * a[i__3].i + temp.i * a[
207 i__3].r;
208 q__1.r = x[i__2].r - q__2.r, q__1.i = x[i__2].i -
209 q__2.i;
210 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
211 /* L10: */
212 }
213 }
214 /* L20: */
215 }
216 } else {
217 jx = kx + (*n - 1) * *incx;
218 for (j = *n; j >= 1; --j) {
219 i__1 = jx;
220 if (x[i__1].r != 0.f || x[i__1].i != 0.f) {
221 if (nounit) {
222 i__1 = jx;
223 c_div(&q__1, &x[jx], &a[j + j * a_dim1]);
224 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
225 }
226 i__1 = jx;
227 temp.r = x[i__1].r, temp.i = x[i__1].i;
228 ix = jx;
229 for (i__ = j - 1; i__ >= 1; --i__) {
230 ix -= *incx;
231 i__1 = ix;
232 i__2 = ix;
233 i__3 = i__ + j * a_dim1;
234 q__2.r = temp.r * a[i__3].r - temp.i * a[i__3].i,
235 q__2.i = temp.r * a[i__3].i + temp.i * a[
236 i__3].r;
237 q__1.r = x[i__2].r - q__2.r, q__1.i = x[i__2].i -
238 q__2.i;
239 x[i__1].r = q__1.r, x[i__1].i = q__1.i;
240 /* L30: */
241 }
242 }
243 jx -= *incx;
244 /* L40: */
245 }
246 }
247 } else {
248 if (*incx == 1) {
249 i__1 = *n;
250 for (j = 1; j <= i__1; ++j) {
251 i__2 = j;
252 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
253 if (nounit) {
254 i__2 = j;
255 c_div(&q__1, &x[j], &a[j + j * a_dim1]);
256 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
257 }
258 i__2 = j;
259 temp.r = x[i__2].r, temp.i = x[i__2].i;
260 i__2 = *n;
261 for (i__ = j + 1; i__ <= i__2; ++i__) {
262 i__3 = i__;
263 i__4 = i__;
264 i__5 = i__ + j * a_dim1;
265 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
266 q__2.i = temp.r * a[i__5].i + temp.i * a[
267 i__5].r;
268 q__1.r = x[i__4].r - q__2.r, q__1.i = x[i__4].i -
269 q__2.i;
270 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
271 /* L50: */
272 }
273 }
274 /* L60: */
275 }
276 } else {
277 jx = kx;
278 i__1 = *n;
279 for (j = 1; j <= i__1; ++j) {
280 i__2 = jx;
281 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
282 if (nounit) {
283 i__2 = jx;
284 c_div(&q__1, &x[jx], &a[j + j * a_dim1]);
285 x[i__2].r = q__1.r, x[i__2].i = q__1.i;
286 }
287 i__2 = jx;
288 temp.r = x[i__2].r, temp.i = x[i__2].i;
289 ix = jx;
290 i__2 = *n;
291 for (i__ = j + 1; i__ <= i__2; ++i__) {
292 ix += *incx;
293 i__3 = ix;
294 i__4 = ix;
295 i__5 = i__ + j * a_dim1;
296 q__2.r = temp.r * a[i__5].r - temp.i * a[i__5].i,
297 q__2.i = temp.r * a[i__5].i + temp.i * a[
298 i__5].r;
299 q__1.r = x[i__4].r - q__2.r, q__1.i = x[i__4].i -
300 q__2.i;
301 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
302 /* L70: */
303 }
304 }
305 jx += *incx;
306 /* L80: */
307 }
308 }
309 }
310 } else {
311
312 /* Form x := inv( A' )*x or x := inv( conjg( A' ) )*x. */
313
314 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
315 if (*incx == 1) {
316 i__1 = *n;
317 for (j = 1; j <= i__1; ++j) {
318 i__2 = j;
319 temp.r = x[i__2].r, temp.i = x[i__2].i;
320 if (noconj) {
321 i__2 = j - 1;
322 for (i__ = 1; i__ <= i__2; ++i__) {
323 i__3 = i__ + j * a_dim1;
324 i__4 = i__;
325 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
326 i__4].i, q__2.i = a[i__3].r * x[i__4].i +
327 a[i__3].i * x[i__4].r;
328 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
329 q__2.i;
330 temp.r = q__1.r, temp.i = q__1.i;
331 /* L90: */
332 }
333 if (nounit) {
334 c_div(&q__1, &temp, &a[j + j * a_dim1]);
335 temp.r = q__1.r, temp.i = q__1.i;
336 }
337 } else {
338 i__2 = j - 1;
339 for (i__ = 1; i__ <= i__2; ++i__) {
340 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
341 i__3 = i__;
342 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
343 q__2.i = q__3.r * x[i__3].i + q__3.i * x[
344 i__3].r;
345 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
346 q__2.i;
347 temp.r = q__1.r, temp.i = q__1.i;
348 /* L100: */
349 }
350 if (nounit) {
351 r_cnjg(&q__2, &a[j + j * a_dim1]);
352 c_div(&q__1, &temp, &q__2);
353 temp.r = q__1.r, temp.i = q__1.i;
354 }
355 }
356 i__2 = j;
357 x[i__2].r = temp.r, x[i__2].i = temp.i;
358 /* L110: */
359 }
360 } else {
361 jx = kx;
362 i__1 = *n;
363 for (j = 1; j <= i__1; ++j) {
364 ix = kx;
365 i__2 = jx;
366 temp.r = x[i__2].r, temp.i = x[i__2].i;
367 if (noconj) {
368 i__2 = j - 1;
369 for (i__ = 1; i__ <= i__2; ++i__) {
370 i__3 = i__ + j * a_dim1;
371 i__4 = ix;
372 q__2.r = a[i__3].r * x[i__4].r - a[i__3].i * x[
373 i__4].i, q__2.i = a[i__3].r * x[i__4].i +
374 a[i__3].i * x[i__4].r;
375 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
376 q__2.i;
377 temp.r = q__1.r, temp.i = q__1.i;
378 ix += *incx;
379 /* L120: */
380 }
381 if (nounit) {
382 c_div(&q__1, &temp, &a[j + j * a_dim1]);
383 temp.r = q__1.r, temp.i = q__1.i;
384 }
385 } else {
386 i__2 = j - 1;
387 for (i__ = 1; i__ <= i__2; ++i__) {
388 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
389 i__3 = ix;
390 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i,
391 q__2.i = q__3.r * x[i__3].i + q__3.i * x[
392 i__3].r;
393 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
394 q__2.i;
395 temp.r = q__1.r, temp.i = q__1.i;
396 ix += *incx;
397 /* L130: */
398 }
399 if (nounit) {
400 r_cnjg(&q__2, &a[j + j * a_dim1]);
401 c_div(&q__1, &temp, &q__2);
402 temp.r = q__1.r, temp.i = q__1.i;
403 }
404 }
405 i__2 = jx;
406 x[i__2].r = temp.r, x[i__2].i = temp.i;
407 jx += *incx;
408 /* L140: */
409 }
410 }
411 } else {
412 if (*incx == 1) {
413 for (j = *n; j >= 1; --j) {
414 i__1 = j;
415 temp.r = x[i__1].r, temp.i = x[i__1].i;
416 if (noconj) {
417 i__1 = j + 1;
418 for (i__ = *n; i__ >= i__1; --i__) {
419 i__2 = i__ + j * a_dim1;
420 i__3 = i__;
421 q__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
422 i__3].i, q__2.i = a[i__2].r * x[i__3].i +
423 a[i__2].i * x[i__3].r;
424 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
425 q__2.i;
426 temp.r = q__1.r, temp.i = q__1.i;
427 /* L150: */
428 }
429 if (nounit) {
430 c_div(&q__1, &temp, &a[j + j * a_dim1]);
431 temp.r = q__1.r, temp.i = q__1.i;
432 }
433 } else {
434 i__1 = j + 1;
435 for (i__ = *n; i__ >= i__1; --i__) {
436 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
437 i__2 = i__;
438 q__2.r = q__3.r * x[i__2].r - q__3.i * x[i__2].i,
439 q__2.i = q__3.r * x[i__2].i + q__3.i * x[
440 i__2].r;
441 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
442 q__2.i;
443 temp.r = q__1.r, temp.i = q__1.i;
444 /* L160: */
445 }
446 if (nounit) {
447 r_cnjg(&q__2, &a[j + j * a_dim1]);
448 c_div(&q__1, &temp, &q__2);
449 temp.r = q__1.r, temp.i = q__1.i;
450 }
451 }
452 i__1 = j;
453 x[i__1].r = temp.r, x[i__1].i = temp.i;
454 /* L170: */
455 }
456 } else {
457 kx += (*n - 1) * *incx;
458 jx = kx;
459 for (j = *n; j >= 1; --j) {
460 ix = kx;
461 i__1 = jx;
462 temp.r = x[i__1].r, temp.i = x[i__1].i;
463 if (noconj) {
464 i__1 = j + 1;
465 for (i__ = *n; i__ >= i__1; --i__) {
466 i__2 = i__ + j * a_dim1;
467 i__3 = ix;
468 q__2.r = a[i__2].r * x[i__3].r - a[i__2].i * x[
469 i__3].i, q__2.i = a[i__2].r * x[i__3].i +
470 a[i__2].i * x[i__3].r;
471 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
472 q__2.i;
473 temp.r = q__1.r, temp.i = q__1.i;
474 ix -= *incx;
475 /* L180: */
476 }
477 if (nounit) {
478 c_div(&q__1, &temp, &a[j + j * a_dim1]);
479 temp.r = q__1.r, temp.i = q__1.i;
480 }
481 } else {
482 i__1 = j + 1;
483 for (i__ = *n; i__ >= i__1; --i__) {
484 r_cnjg(&q__3, &a[i__ + j * a_dim1]);
485 i__2 = ix;
486 q__2.r = q__3.r * x[i__2].r - q__3.i * x[i__2].i,
487 q__2.i = q__3.r * x[i__2].i + q__3.i * x[
488 i__2].r;
489 q__1.r = temp.r - q__2.r, q__1.i = temp.i -
490 q__2.i;
491 temp.r = q__1.r, temp.i = q__1.i;
492 ix -= *incx;
493 /* L190: */
494 }
495 if (nounit) {
496 r_cnjg(&q__2, &a[j + j * a_dim1]);
497 c_div(&q__1, &temp, &q__2);
498 temp.r = q__1.r, temp.i = q__1.i;
499 }
500 }
501 i__1 = jx;
502 x[i__1].r = temp.r, x[i__1].i = temp.i;
503 jx -= *incx;
504 /* L200: */
505 }
506 }
507 }
508 }
509
510 return 0;
511
512 /* End of CTRSV . */
513
514 } /* ctrsv_ */
515