Debian Codegraph @

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

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