Debian Codegraph @

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

raw
1 /* ./src_f77/dtpsv.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 dtpsv_(char *uplo, char *trans, char *diag, integer *n,
9 doublereal *ap, doublereal *x, integer *incx, ftnlen uplo_len, ftnlen
10 trans_len, ftnlen diag_len)
11 {
12 /* System generated locals */
13 integer i__1, i__2;
14
15 /* Local variables */
16 static integer i__, j, k, kk, 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 /* DTPSV 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, supplied in packed form. */
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 /* AP - DOUBLE PRECISION array of DIMENSION at least */
81 /* ( ( n*( n + 1 ) )/2 ). */
82 /* Before entry with UPLO = 'U' or 'u', the array AP must */
83 /* contain the upper triangular matrix packed sequentially, */
84 /* column by column, so that AP( 1 ) contains a( 1, 1 ), */
85 /* AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 ) */
86 /* respectively, and so on. */
87 /* Before entry with UPLO = 'L' or 'l', the array AP must */
88 /* contain the lower triangular matrix packed sequentially, */
89 /* column by column, so that AP( 1 ) contains a( 1, 1 ), */
90 /* AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 ) */
91 /* respectively, and so on. */
92 /* Note that when DIAG = 'U' or 'u', the diagonal elements of */
93 /* A are not referenced, but are assumed to be unity. */
94 /* Unchanged on exit. */
95
96 /* X - DOUBLE PRECISION array of dimension at least */
97 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
98 /* Before entry, the incremented array X must contain the n */
99 /* element right-hand side vector b. On exit, X is overwritten */
100 /* with the solution vector x. */
101
102 /* INCX - INTEGER. */
103 /* On entry, INCX specifies the increment for the elements of */
104 /* X. INCX must not be zero. */
105 /* Unchanged on exit. */
106
107
108 /* Level 2 Blas routine. */
109
110 /* -- Written on 22-October-1986. */
111 /* Jack Dongarra, Argonne National Lab. */
112 /* Jeremy Du Croz, Nag Central Office. */
113 /* Sven Hammarling, Nag Central Office. */
114 /* Richard Hanson, Sandia National Labs. */
115
116
117 /* .. Parameters .. */
118 /* .. Local Scalars .. */
119 /* .. External Functions .. */
120 /* .. External Subroutines .. */
121 /* .. */
122 /* .. Executable Statements .. */
123
124 /* Test the input parameters. */
125
126 /* Parameter adjustments */
127 --x;
128 --ap;
129
130 /* Function Body */
131 info = 0;
132 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
133 ftnlen)1, (ftnlen)1)) {
134 info = 1;
135 } else if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans,
136 "T", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (
137 ftnlen)1)) {
138 info = 2;
139 } else if (! lsame_(diag, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(diag,
140 "N", (ftnlen)1, (ftnlen)1)) {
141 info = 3;
142 } else if (*n < 0) {
143 info = 4;
144 } else if (*incx == 0) {
145 info = 7;
146 }
147 if (info != 0) {
148 xerbla_("DTPSV ", &info, (ftnlen)6);
149 return 0;
150 }
151
152 /* Quick return if possible. */
153
154 if (*n == 0) {
155 return 0;
156 }
157
158 nounit = lsame_(diag, "N", (ftnlen)1, (ftnlen)1);
159
160 /* Set up the start point in X if the increment is not unity. This */
161 /* will be ( N - 1 )*INCX too small for descending loops. */
162
163 if (*incx <= 0) {
164 kx = 1 - (*n - 1) * *incx;
165 } else if (*incx != 1) {
166 kx = 1;
167 }
168
169 /* Start the operations. In this version the elements of AP are */
170 /* accessed sequentially with one pass through AP. */
171
172 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
173
174 /* Form x := inv( A )*x. */
175
176 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
177 kk = *n * (*n + 1) / 2;
178 if (*incx == 1) {
179 for (j = *n; j >= 1; --j) {
180 if (x[j] != 0.) {
181 if (nounit) {
182 x[j] /= ap[kk];
183 }
184 temp = x[j];
185 k = kk - 1;
186 for (i__ = j - 1; i__ >= 1; --i__) {
187 x[i__] -= temp * ap[k];
188 --k;
189 /* L10: */
190 }
191 }
192 kk -= j;
193 /* L20: */
194 }
195 } else {
196 jx = kx + (*n - 1) * *incx;
197 for (j = *n; j >= 1; --j) {
198 if (x[jx] != 0.) {
199 if (nounit) {
200 x[jx] /= ap[kk];
201 }
202 temp = x[jx];
203 ix = jx;
204 i__1 = kk - j + 1;
205 for (k = kk - 1; k >= i__1; --k) {
206 ix -= *incx;
207 x[ix] -= temp * ap[k];
208 /* L30: */
209 }
210 }
211 jx -= *incx;
212 kk -= j;
213 /* L40: */
214 }
215 }
216 } else {
217 kk = 1;
218 if (*incx == 1) {
219 i__1 = *n;
220 for (j = 1; j <= i__1; ++j) {
221 if (x[j] != 0.) {
222 if (nounit) {
223 x[j] /= ap[kk];
224 }
225 temp = x[j];
226 k = kk + 1;
227 i__2 = *n;
228 for (i__ = j + 1; i__ <= i__2; ++i__) {
229 x[i__] -= temp * ap[k];
230 ++k;
231 /* L50: */
232 }
233 }
234 kk += *n - j + 1;
235 /* L60: */
236 }
237 } else {
238 jx = kx;
239 i__1 = *n;
240 for (j = 1; j <= i__1; ++j) {
241 if (x[jx] != 0.) {
242 if (nounit) {
243 x[jx] /= ap[kk];
244 }
245 temp = x[jx];
246 ix = jx;
247 i__2 = kk + *n - j;
248 for (k = kk + 1; k <= i__2; ++k) {
249 ix += *incx;
250 x[ix] -= temp * ap[k];
251 /* L70: */
252 }
253 }
254 jx += *incx;
255 kk += *n - j + 1;
256 /* L80: */
257 }
258 }
259 }
260 } else {
261
262 /* Form x := inv( A' )*x. */
263
264 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
265 kk = 1;
266 if (*incx == 1) {
267 i__1 = *n;
268 for (j = 1; j <= i__1; ++j) {
269 temp = x[j];
270 k = kk;
271 i__2 = j - 1;
272 for (i__ = 1; i__ <= i__2; ++i__) {
273 temp -= ap[k] * x[i__];
274 ++k;
275 /* L90: */
276 }
277 if (nounit) {
278 temp /= ap[kk + j - 1];
279 }
280 x[j] = temp;
281 kk += j;
282 /* L100: */
283 }
284 } else {
285 jx = kx;
286 i__1 = *n;
287 for (j = 1; j <= i__1; ++j) {
288 temp = x[jx];
289 ix = kx;
290 i__2 = kk + j - 2;
291 for (k = kk; k <= i__2; ++k) {
292 temp -= ap[k] * x[ix];
293 ix += *incx;
294 /* L110: */
295 }
296 if (nounit) {
297 temp /= ap[kk + j - 1];
298 }
299 x[jx] = temp;
300 jx += *incx;
301 kk += j;
302 /* L120: */
303 }
304 }
305 } else {
306 kk = *n * (*n + 1) / 2;
307 if (*incx == 1) {
308 for (j = *n; j >= 1; --j) {
309 temp = x[j];
310 k = kk;
311 i__1 = j + 1;
312 for (i__ = *n; i__ >= i__1; --i__) {
313 temp -= ap[k] * x[i__];
314 --k;
315 /* L130: */
316 }
317 if (nounit) {
318 temp /= ap[kk - *n + j];
319 }
320 x[j] = temp;
321 kk -= *n - j + 1;
322 /* L140: */
323 }
324 } else {
325 kx += (*n - 1) * *incx;
326 jx = kx;
327 for (j = *n; j >= 1; --j) {
328 temp = x[jx];
329 ix = kx;
330 i__1 = kk - (*n - (j + 1));
331 for (k = kk; k >= i__1; --k) {
332 temp -= ap[k] * x[ix];
333 ix -= *incx;
334 /* L150: */
335 }
336 if (nounit) {
337 temp /= ap[kk - *n + j];
338 }
339 x[jx] = temp;
340 jx -= *incx;
341 kk -= *n - j + 1;
342 /* L160: */
343 }
344 }
345 }
346 }
347
348 return 0;
349
350 /* End of DTPSV . */
351
352 } /* dtpsv_ */
353