Debian Codegraph @

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

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