Debian Codegraph @

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

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