Debian Codegraph @

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

raw
1 /* ./src_f77/chpmv.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 chpmv_(char *uplo, integer *n, realcomplex *alpha, realcomplex *
9 ap, realcomplex *x, integer *incx, realcomplex *beta, realcomplex *y, integer *
10 incy, ftnlen uplo_len)
11 {
12 /* System generated locals */
13 integer i__1, i__2, i__3, i__4, i__5;
14 real r__1;
15 realcomplex q__1, q__2, q__3, q__4;
16
17 /* Builtin functions */
18 void r_cnjg(realcomplex *, realcomplex *);
19
20 /* Local variables */
21 static integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
22 static realcomplex temp1, temp2;
23 extern logical lsame_(char *, char *, ftnlen, ftnlen);
24 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
25
26 /* .. Scalar Arguments .. */
27 /* .. Array Arguments .. */
28 /* .. */
29
30 /* Purpose */
31 /* ======= */
32
33 /* CHPMV performs the matrix-vector operation */
34
35 /* y := alpha*A*x + beta*y, */
36
37 /* where alpha and beta are scalars, x and y are n element vectors and */
38 /* A is an n by n hermitian matrix, supplied in packed form. */
39
40 /* Parameters */
41 /* ========== */
42
43 /* UPLO - CHARACTER*1. */
44 /* On entry, UPLO specifies whether the upper or lower */
45 /* triangular part of the matrix A is supplied in the packed */
46 /* array AP as follows: */
47
48 /* UPLO = 'U' or 'u' The upper triangular part of A is */
49 /* supplied in AP. */
50
51 /* UPLO = 'L' or 'l' The lower triangular part of A is */
52 /* supplied in AP. */
53
54 /* Unchanged on exit. */
55
56 /* N - INTEGER. */
57 /* On entry, N specifies the order of the matrix A. */
58 /* N must be at least zero. */
59 /* Unchanged on exit. */
60
61 /* ALPHA - COMPLEX . */
62 /* On entry, ALPHA specifies the scalar alpha. */
63 /* Unchanged on exit. */
64
65 /* AP - COMPLEX array of DIMENSION at least */
66 /* ( ( n*( n + 1 ) )/2 ). */
67 /* Before entry with UPLO = 'U' or 'u', the array AP must */
68 /* contain the upper triangular part of the hermitian matrix */
69 /* packed sequentially, column by column, so that AP( 1 ) */
70 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
71 /* and a( 2, 2 ) respectively, and so on. */
72 /* Before entry with UPLO = 'L' or 'l', the array AP must */
73 /* contain the lower triangular part of the hermitian matrix */
74 /* packed sequentially, column by column, so that AP( 1 ) */
75 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
76 /* and a( 3, 1 ) respectively, and so on. */
77 /* Note that the imaginary parts of the diagonal elements need */
78 /* not be set and are assumed to be zero. */
79 /* Unchanged on exit. */
80
81 /* X - COMPLEX array of dimension at least */
82 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
83 /* Before entry, the incremented array X must contain the n */
84 /* element vector x. */
85 /* Unchanged on exit. */
86
87 /* INCX - INTEGER. */
88 /* On entry, INCX specifies the increment for the elements of */
89 /* X. INCX must not be zero. */
90 /* Unchanged on exit. */
91
92 /* BETA - COMPLEX . */
93 /* On entry, BETA specifies the scalar beta. When BETA is */
94 /* supplied as zero then Y need not be set on input. */
95 /* Unchanged on exit. */
96
97 /* Y - COMPLEX array of dimension at least */
98 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
99 /* Before entry, the incremented array Y must contain the n */
100 /* element vector y. On exit, Y is overwritten by the updated */
101 /* vector y. */
102
103 /* INCY - INTEGER. */
104 /* On entry, INCY specifies the increment for the elements of */
105 /* Y. INCY must not be zero. */
106 /* Unchanged on exit. */
107
108
109 /* Level 2 Blas routine. */
110
111 /* -- Written on 22-October-1986. */
112 /* Jack Dongarra, Argonne National Lab. */
113 /* Jeremy Du Croz, Nag Central Office. */
114 /* Sven Hammarling, Nag Central Office. */
115 /* Richard Hanson, Sandia National Labs. */
116
117
118 /* .. Parameters .. */
119 /* .. Local Scalars .. */
120 /* .. External Functions .. */
121 /* .. External Subroutines .. */
122 /* .. Intrinsic Functions .. */
123 /* .. */
124 /* .. Executable Statements .. */
125
126 /* Test the input parameters. */
127
128 /* Parameter adjustments */
129 --y;
130 --x;
131 --ap;
132
133 /* Function Body */
134 info = 0;
135 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
136 ftnlen)1, (ftnlen)1)) {
137 info = 1;
138 } else if (*n < 0) {
139 info = 2;
140 } else if (*incx == 0) {
141 info = 6;
142 } else if (*incy == 0) {
143 info = 9;
144 }
145 if (info != 0) {
146 xerbla_("CHPMV ", &info, (ftnlen)6);
147 return 0;
148 }
149
150 /* Quick return if possible. */
151
152 if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f && (beta->r == 1.f &&
153 beta->i == 0.f)) {
154 return 0;
155 }
156
157 /* Set up the start points in X and Y. */
158
159 if (*incx > 0) {
160 kx = 1;
161 } else {
162 kx = 1 - (*n - 1) * *incx;
163 }
164 if (*incy > 0) {
165 ky = 1;
166 } else {
167 ky = 1 - (*n - 1) * *incy;
168 }
169
170 /* Start the operations. In this version the elements of the array AP */
171 /* are accessed sequentially with one pass through AP. */
172
173 /* First form y := beta*y. */
174
175 if (beta->r != 1.f || beta->i != 0.f) {
176 if (*incy == 1) {
177 if (beta->r == 0.f && beta->i == 0.f) {
178 i__1 = *n;
179 for (i__ = 1; i__ <= i__1; ++i__) {
180 i__2 = i__;
181 y[i__2].r = 0.f, y[i__2].i = 0.f;
182 /* L10: */
183 }
184 } else {
185 i__1 = *n;
186 for (i__ = 1; i__ <= i__1; ++i__) {
187 i__2 = i__;
188 i__3 = i__;
189 q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
190 q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
191 .r;
192 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
193 /* L20: */
194 }
195 }
196 } else {
197 iy = ky;
198 if (beta->r == 0.f && beta->i == 0.f) {
199 i__1 = *n;
200 for (i__ = 1; i__ <= i__1; ++i__) {
201 i__2 = iy;
202 y[i__2].r = 0.f, y[i__2].i = 0.f;
203 iy += *incy;
204 /* L30: */
205 }
206 } else {
207 i__1 = *n;
208 for (i__ = 1; i__ <= i__1; ++i__) {
209 i__2 = iy;
210 i__3 = iy;
211 q__1.r = beta->r * y[i__3].r - beta->i * y[i__3].i,
212 q__1.i = beta->r * y[i__3].i + beta->i * y[i__3]
213 .r;
214 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
215 iy += *incy;
216 /* L40: */
217 }
218 }
219 }
220 }
221 if (alpha->r == 0.f && alpha->i == 0.f) {
222 return 0;
223 }
224 kk = 1;
225 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
226
227 /* Form y when AP contains the upper triangle. */
228
229 if (*incx == 1 && *incy == 1) {
230 i__1 = *n;
231 for (j = 1; j <= i__1; ++j) {
232 i__2 = j;
233 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
234 alpha->r * x[i__2].i + alpha->i * x[i__2].r;
235 temp1.r = q__1.r, temp1.i = q__1.i;
236 temp2.r = 0.f, temp2.i = 0.f;
237 k = kk;
238 i__2 = j - 1;
239 for (i__ = 1; i__ <= i__2; ++i__) {
240 i__3 = i__;
241 i__4 = i__;
242 i__5 = k;
243 q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i,
244 q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
245 .r;
246 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
247 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
248 r_cnjg(&q__3, &ap[k]);
249 i__3 = i__;
250 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
251 q__3.r * x[i__3].i + q__3.i * x[i__3].r;
252 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
253 temp2.r = q__1.r, temp2.i = q__1.i;
254 ++k;
255 /* L50: */
256 }
257 i__2 = j;
258 i__3 = j;
259 i__4 = kk + j - 1;
260 r__1 = ap[i__4].r;
261 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
262 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
263 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
264 alpha->r * temp2.i + alpha->i * temp2.r;
265 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
266 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
267 kk += j;
268 /* L60: */
269 }
270 } else {
271 jx = kx;
272 jy = ky;
273 i__1 = *n;
274 for (j = 1; j <= i__1; ++j) {
275 i__2 = jx;
276 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
277 alpha->r * x[i__2].i + alpha->i * x[i__2].r;
278 temp1.r = q__1.r, temp1.i = q__1.i;
279 temp2.r = 0.f, temp2.i = 0.f;
280 ix = kx;
281 iy = ky;
282 i__2 = kk + j - 2;
283 for (k = kk; k <= i__2; ++k) {
284 i__3 = iy;
285 i__4 = iy;
286 i__5 = k;
287 q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i,
288 q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
289 .r;
290 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
291 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
292 r_cnjg(&q__3, &ap[k]);
293 i__3 = ix;
294 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
295 q__3.r * x[i__3].i + q__3.i * x[i__3].r;
296 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
297 temp2.r = q__1.r, temp2.i = q__1.i;
298 ix += *incx;
299 iy += *incy;
300 /* L70: */
301 }
302 i__2 = jy;
303 i__3 = jy;
304 i__4 = kk + j - 1;
305 r__1 = ap[i__4].r;
306 q__3.r = r__1 * temp1.r, q__3.i = r__1 * temp1.i;
307 q__2.r = y[i__3].r + q__3.r, q__2.i = y[i__3].i + q__3.i;
308 q__4.r = alpha->r * temp2.r - alpha->i * temp2.i, q__4.i =
309 alpha->r * temp2.i + alpha->i * temp2.r;
310 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
311 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
312 jx += *incx;
313 jy += *incy;
314 kk += j;
315 /* L80: */
316 }
317 }
318 } else {
319
320 /* Form y when AP contains the lower triangle. */
321
322 if (*incx == 1 && *incy == 1) {
323 i__1 = *n;
324 for (j = 1; j <= i__1; ++j) {
325 i__2 = j;
326 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
327 alpha->r * x[i__2].i + alpha->i * x[i__2].r;
328 temp1.r = q__1.r, temp1.i = q__1.i;
329 temp2.r = 0.f, temp2.i = 0.f;
330 i__2 = j;
331 i__3 = j;
332 i__4 = kk;
333 r__1 = ap[i__4].r;
334 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
335 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
336 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
337 k = kk + 1;
338 i__2 = *n;
339 for (i__ = j + 1; i__ <= i__2; ++i__) {
340 i__3 = i__;
341 i__4 = i__;
342 i__5 = k;
343 q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i,
344 q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
345 .r;
346 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
347 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
348 r_cnjg(&q__3, &ap[k]);
349 i__3 = i__;
350 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
351 q__3.r * x[i__3].i + q__3.i * x[i__3].r;
352 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
353 temp2.r = q__1.r, temp2.i = q__1.i;
354 ++k;
355 /* L90: */
356 }
357 i__2 = j;
358 i__3 = j;
359 q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
360 alpha->r * temp2.i + alpha->i * temp2.r;
361 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
362 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
363 kk += *n - j + 1;
364 /* L100: */
365 }
366 } else {
367 jx = kx;
368 jy = ky;
369 i__1 = *n;
370 for (j = 1; j <= i__1; ++j) {
371 i__2 = jx;
372 q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i, q__1.i =
373 alpha->r * x[i__2].i + alpha->i * x[i__2].r;
374 temp1.r = q__1.r, temp1.i = q__1.i;
375 temp2.r = 0.f, temp2.i = 0.f;
376 i__2 = jy;
377 i__3 = jy;
378 i__4 = kk;
379 r__1 = ap[i__4].r;
380 q__2.r = r__1 * temp1.r, q__2.i = r__1 * temp1.i;
381 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
382 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
383 ix = jx;
384 iy = jy;
385 i__2 = kk + *n - j;
386 for (k = kk + 1; k <= i__2; ++k) {
387 ix += *incx;
388 iy += *incy;
389 i__3 = iy;
390 i__4 = iy;
391 i__5 = k;
392 q__2.r = temp1.r * ap[i__5].r - temp1.i * ap[i__5].i,
393 q__2.i = temp1.r * ap[i__5].i + temp1.i * ap[i__5]
394 .r;
395 q__1.r = y[i__4].r + q__2.r, q__1.i = y[i__4].i + q__2.i;
396 y[i__3].r = q__1.r, y[i__3].i = q__1.i;
397 r_cnjg(&q__3, &ap[k]);
398 i__3 = ix;
399 q__2.r = q__3.r * x[i__3].r - q__3.i * x[i__3].i, q__2.i =
400 q__3.r * x[i__3].i + q__3.i * x[i__3].r;
401 q__1.r = temp2.r + q__2.r, q__1.i = temp2.i + q__2.i;
402 temp2.r = q__1.r, temp2.i = q__1.i;
403 /* L110: */
404 }
405 i__2 = jy;
406 i__3 = jy;
407 q__2.r = alpha->r * temp2.r - alpha->i * temp2.i, q__2.i =
408 alpha->r * temp2.i + alpha->i * temp2.r;
409 q__1.r = y[i__3].r + q__2.r, q__1.i = y[i__3].i + q__2.i;
410 y[i__2].r = q__1.r, y[i__2].i = q__1.i;
411 jx += *incx;
412 jy += *incy;
413 kk += *n - j + 1;
414 /* L120: */
415 }
416 }
417 }
418
419 return 0;
420
421 /* End of CHPMV . */
422
423 } /* chpmv_ */
424