Debian Codegraph @

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

raw
1 /* ./src_f77/dtbsv.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 dtbsv_(char *uplo, char *trans, char *diag, integer *n,
9 integer *k, doublereal *a, integer *lda, doublereal *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;
14
15 /* Local variables */
16 static integer i__, j, l, ix, jx, kx, info;
17 static doublereal temp;
18 extern logical lsame_(char *, char *, ftnlen, ftnlen);
19 static integer kplus1;
20 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
21 static logical nounit;
22
23 /* .. Scalar Arguments .. */
24 /* .. Array Arguments .. */
25 /* .. */
26
27 /* Purpose */
28 /* ======= */
29
30 /* DTBSV solves one of the systems of equations */
31
32 /* A*x = b, or A'*x = b, */
33
34 /* where b and x are n element vectors and A is an n by n unit, or */
35 /* non-unit, upper or lower triangular band matrix, with ( k + 1 ) */
36 /* diagonals. */
37
38 /* No test for singularity or near-singularity is included in this */
39 /* routine. Such tests must be performed before calling this routine. */
40
41 /* Parameters */
42 /* ========== */
43
44 /* UPLO - CHARACTER*1. */
45 /* On entry, UPLO specifies whether the matrix is an upper or */
46 /* lower triangular matrix as follows: */
47
48 /* UPLO = 'U' or 'u' A is an upper triangular matrix. */
49
50 /* UPLO = 'L' or 'l' A is a lower triangular matrix. */
51
52 /* Unchanged on exit. */
53
54 /* TRANS - CHARACTER*1. */
55 /* On entry, TRANS specifies the equations to be solved as */
56 /* follows: */
57
58 /* TRANS = 'N' or 'n' A*x = b. */
59
60 /* TRANS = 'T' or 't' A'*x = b. */
61
62 /* TRANS = 'C' or 'c' A'*x = b. */
63
64 /* Unchanged on exit. */
65
66 /* DIAG - CHARACTER*1. */
67 /* On entry, DIAG specifies whether or not A is unit */
68 /* triangular as follows: */
69
70 /* DIAG = 'U' or 'u' A is assumed to be unit triangular. */
71
72 /* DIAG = 'N' or 'n' A is not assumed to be unit */
73 /* triangular. */
74
75 /* Unchanged on exit. */
76
77 /* N - INTEGER. */
78 /* On entry, N specifies the order of the matrix A. */
79 /* N must be at least zero. */
80 /* Unchanged on exit. */
81
82 /* K - INTEGER. */
83 /* On entry with UPLO = 'U' or 'u', K specifies the number of */
84 /* super-diagonals of the matrix A. */
85 /* On entry with UPLO = 'L' or 'l', K specifies the number of */
86 /* sub-diagonals of the matrix A. */
87 /* K must satisfy 0 .le. K. */
88 /* Unchanged on exit. */
89
90 /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
91 /* Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) */
92 /* by n part of the array A must contain the upper triangular */
93 /* band part of the matrix of coefficients, supplied column by */
94 /* column, with the leading diagonal of the matrix in row */
95 /* ( k + 1 ) of the array, the first super-diagonal starting at */
96 /* position 2 in row k, and so on. The top left k by k triangle */
97 /* of the array A is not referenced. */
98 /* The following program segment will transfer an upper */
99 /* triangular band matrix from conventional full matrix storage */
100 /* to band storage: */
101
102 /* DO 20, J = 1, N */
103 /* M = K + 1 - J */
104 /* DO 10, I = MAX( 1, J - K ), J */
105 /* A( M + I, J ) = matrix( I, J ) */
106 /* 10 CONTINUE */
107 /* 20 CONTINUE */
108
109 /* Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) */
110 /* by n part of the array A must contain the lower triangular */
111 /* band part of the matrix of coefficients, supplied column by */
112 /* column, with the leading diagonal of the matrix in row 1 of */
113 /* the array, the first sub-diagonal starting at position 1 in */
114 /* row 2, and so on. The bottom right k by k triangle of the */
115 /* array A is not referenced. */
116 /* The following program segment will transfer a lower */
117 /* triangular band matrix from conventional full matrix storage */
118 /* to band storage: */
119
120 /* DO 20, J = 1, N */
121 /* M = 1 - J */
122 /* DO 10, I = J, MIN( N, J + K ) */
123 /* A( M + I, J ) = matrix( I, J ) */
124 /* 10 CONTINUE */
125 /* 20 CONTINUE */
126
127 /* Note that when DIAG = 'U' or 'u' the elements of the array A */
128 /* corresponding to the diagonal elements of the matrix are not */
129 /* referenced, but are assumed to be unity. */
130 /* Unchanged on exit. */
131
132 /* LDA - INTEGER. */
133 /* On entry, LDA specifies the first dimension of A as declared */
134 /* in the calling (sub) program. LDA must be at least */
135 /* ( k + 1 ). */
136 /* Unchanged on exit. */
137
138 /* X - DOUBLE PRECISION array of dimension at least */
139 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
140 /* Before entry, the incremented array X must contain the n */
141 /* element right-hand side vector b. On exit, X is overwritten */
142 /* with the solution vector x. */
143
144 /* INCX - INTEGER. */
145 /* On entry, INCX specifies the increment for the elements of */
146 /* X. INCX must not be zero. */
147 /* Unchanged on exit. */
148
149
150 /* Level 2 Blas routine. */
151
152 /* -- Written on 22-October-1986. */
153 /* Jack Dongarra, Argonne National Lab. */
154 /* Jeremy Du Croz, Nag Central Office. */
155 /* Sven Hammarling, Nag Central Office. */
156 /* Richard Hanson, Sandia National Labs. */
157
158
159 /* .. Parameters .. */
160 /* .. Local Scalars .. */
161 /* .. External Functions .. */
162 /* .. External Subroutines .. */
163 /* .. Intrinsic Functions .. */
164 /* .. */
165 /* .. Executable Statements .. */
166
167 /* Test the input parameters. */
168
169 /* Parameter adjustments */
170 a_dim1 = *lda;
171 a_offset = 1 + a_dim1;
172 a -= a_offset;
173 --x;
174
175 /* Function Body */
176 info = 0;
177 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
178 ftnlen)1, (ftnlen)1)) {
179 info = 1;
180 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
181 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
182 ftnlen)1)) {
183 info = 2;
184 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
185 "N", (ftnlen)1, (ftnlen)1)) {
186 info = 3;
187 } else if (*n < 0) {
188 info = 4;
189 } else if (*k < 0) {
190 info = 5;
191 } else if (*lda < *k + 1) {
192 info = 7;
193 } else if (*incx == 0) {
194 info = 9;
195 }
196 if (info != 0) {
197 xerbla_("DTBSV ", &info, (ftnlen)6);
198 return 0;
199 }
200
201 /* Quick return if possible. */
202
203 if (*n == 0) {
204 return 0;
205 }
206
207 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
208
209 /* Set up the start point in X if the increment is not unity. This */
210 /* will be ( N - 1 )*INCX too small for descending loops. */
211
212 if (*incx <= 0) {
213 kx = 1 - (*n - 1) * *incx;
214 } else if (*incx != 1) {
215 kx = 1;
216 }
217
218 /* Start the operations. In this version the elements of A are */
219 /* accessed by sequentially with one pass through A. */
220
221 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
222
223 /* Form x := inv( A )*x. */
224
225 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
226 kplus1 = *k + 1;
227 if (*incx == 1) {
228 for (j = *n; j >= 1; --j) {
229 if (x[j] != 0.) {
230 l = kplus1 - j;
231 if (nounit) {
232 x[j] /= a[kplus1 + j * a_dim1];
233 }
234 temp = x[j];
235 /* Computing MAX */
236 i__2 = 1, i__3 = j - *k;
237 i__1 = max(i__2,i__3);
238 for (i__ = j - 1; i__ >= i__1; --i__) {
239 x[i__] -= temp * a[l + i__ + j * a_dim1];
240 /* L10: */
241 }
242 }
243 /* L20: */
244 }
245 } else {
246 kx += (*n - 1) * *incx;
247 jx = kx;
248 for (j = *n; j >= 1; --j) {
249 kx -= *incx;
250 if (x[jx] != 0.) {
251 ix = kx;
252 l = kplus1 - j;
253 if (nounit) {
254 x[jx] /= a[kplus1 + j * a_dim1];
255 }
256 temp = x[jx];
257 /* Computing MAX */
258 i__2 = 1, i__3 = j - *k;
259 i__1 = max(i__2,i__3);
260 for (i__ = j - 1; i__ >= i__1; --i__) {
261 x[ix] -= temp * a[l + i__ + j * a_dim1];
262 ix -= *incx;
263 /* L30: */
264 }
265 }
266 jx -= *incx;
267 /* L40: */
268 }
269 }
270 } else {
271 if (*incx == 1) {
272 i__1 = *n;
273 for (j = 1; j <= i__1; ++j) {
274 if (x[j] != 0.) {
275 l = 1 - j;
276 if (nounit) {
277 x[j] /= a[j * a_dim1 + 1];
278 }
279 temp = x[j];
280 /* Computing MIN */
281 i__3 = *n, i__4 = j + *k;
282 i__2 = min(i__3,i__4);
283 for (i__ = j + 1; i__ <= i__2; ++i__) {
284 x[i__] -= temp * a[l + i__ + j * a_dim1];
285 /* L50: */
286 }
287 }
288 /* L60: */
289 }
290 } else {
291 jx = kx;
292 i__1 = *n;
293 for (j = 1; j <= i__1; ++j) {
294 kx += *incx;
295 if (x[jx] != 0.) {
296 ix = kx;
297 l = 1 - j;
298 if (nounit) {
299 x[jx] /= a[j * a_dim1 + 1];
300 }
301 temp = x[jx];
302 /* Computing MIN */
303 i__3 = *n, i__4 = j + *k;
304 i__2 = min(i__3,i__4);
305 for (i__ = j + 1; i__ <= i__2; ++i__) {
306 x[ix] -= temp * a[l + i__ + j * a_dim1];
307 ix += *incx;
308 /* L70: */
309 }
310 }
311 jx += *incx;
312 /* L80: */
313 }
314 }
315 }
316 } else {
317
318 /* Form x := inv( A')*x. */
319
320 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
321 kplus1 = *k + 1;
322 if (*incx == 1) {
323 i__1 = *n;
324 for (j = 1; j <= i__1; ++j) {
325 temp = x[j];
326 l = kplus1 - j;
327 /* Computing MAX */
328 i__2 = 1, i__3 = j - *k;
329 i__4 = j - 1;
330 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
331 temp -= a[l + i__ + j * a_dim1] * x[i__];
332 /* L90: */
333 }
334 if (nounit) {
335 temp /= a[kplus1 + j * a_dim1];
336 }
337 x[j] = temp;
338 /* L100: */
339 }
340 } else {
341 jx = kx;
342 i__1 = *n;
343 for (j = 1; j <= i__1; ++j) {
344 temp = x[jx];
345 ix = kx;
346 l = kplus1 - j;
347 /* Computing MAX */
348 i__4 = 1, i__2 = j - *k;
349 i__3 = j - 1;
350 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
351 temp -= a[l + i__ + j * a_dim1] * x[ix];
352 ix += *incx;
353 /* L110: */
354 }
355 if (nounit) {
356 temp /= a[kplus1 + j * a_dim1];
357 }
358 x[jx] = temp;
359 jx += *incx;
360 if (j > *k) {
361 kx += *incx;
362 }
363 /* L120: */
364 }
365 }
366 } else {
367 if (*incx == 1) {
368 for (j = *n; j >= 1; --j) {
369 temp = x[j];
370 l = 1 - j;
371 /* Computing MIN */
372 i__1 = *n, i__3 = j + *k;
373 i__4 = j + 1;
374 for (i__ = min(i__1,i__3); i__ >= i__4; --i__) {
375 temp -= a[l + i__ + j * a_dim1] * x[i__];
376 /* L130: */
377 }
378 if (nounit) {
379 temp /= a[j * a_dim1 + 1];
380 }
381 x[j] = temp;
382 /* L140: */
383 }
384 } else {
385 kx += (*n - 1) * *incx;
386 jx = kx;
387 for (j = *n; j >= 1; --j) {
388 temp = x[jx];
389 ix = kx;
390 l = 1 - j;
391 /* Computing MIN */
392 i__4 = *n, i__1 = j + *k;
393 i__3 = j + 1;
394 for (i__ = min(i__4,i__1); i__ >= i__3; --i__) {
395 temp -= a[l + i__ + j * a_dim1] * x[ix];
396 ix -= *incx;
397 /* L150: */
398 }
399 if (nounit) {
400 temp /= a[j * a_dim1 + 1];
401 }
402 x[jx] = temp;
403 jx -= *incx;
404 if (*n - j >= *k) {
405 kx -= *incx;
406 }
407 /* L160: */
408 }
409 }
410 }
411 }
412
413 return 0;
414
415 /* End of DTBSV . */
416
417 } /* dtbsv_ */
418