Debian Codegraph @

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

raw
1 /* ./src_f77/zhpr.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 zhpr_(char *uplo, integer *n, doublereal *alpha,
9 doublecomplex *x, integer *incx, doublecomplex *ap, ftnlen uplo_len)
10 {
11 /* System generated locals */
12 integer i__1, i__2, i__3, i__4, i__5;
13 doublereal d__1;
14 doublecomplex z__1, z__2;
15
16 /* Builtin functions */
17 void d_cnjg(doublecomplex *, doublecomplex *);
18
19 /* Local variables */
20 static integer i__, j, k, kk, ix, jx, kx, info;
21 static doublecomplex temp;
22 extern logical lsame_(char *, char *, ftnlen, ftnlen);
23 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
24
25 /* .. Scalar Arguments .. */
26 /* .. Array Arguments .. */
27 /* .. */
28
29 /* Purpose */
30 /* ======= */
31
32 /* ZHPR performs the hermitian rank 1 operation */
33
34 /* A := alpha*x*conjg( x' ) + A, */
35
36 /* where alpha is a real scalar, x is an n element vector and A is an */
37 /* n by n hermitian matrix, supplied in packed form. */
38
39 /* Parameters */
40 /* ========== */
41
42 /* UPLO - CHARACTER*1. */
43 /* On entry, UPLO specifies whether the upper or lower */
44 /* triangular part of the matrix A is supplied in the packed */
45 /* array AP as follows: */
46
47 /* UPLO = 'U' or 'u' The upper triangular part of A is */
48 /* supplied in AP. */
49
50 /* UPLO = 'L' or 'l' The lower triangular part of A is */
51 /* supplied in AP. */
52
53 /* Unchanged on exit. */
54
55 /* N - INTEGER. */
56 /* On entry, N specifies the order of the matrix A. */
57 /* N must be at least zero. */
58 /* Unchanged on exit. */
59
60 /* ALPHA - DOUBLE PRECISION. */
61 /* On entry, ALPHA specifies the scalar alpha. */
62 /* Unchanged on exit. */
63
64 /* X - COMPLEX*16 array of dimension at least */
65 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
66 /* Before entry, the incremented array X must contain the n */
67 /* element vector x. */
68 /* Unchanged on exit. */
69
70 /* INCX - INTEGER. */
71 /* On entry, INCX specifies the increment for the elements of */
72 /* X. INCX must not be zero. */
73 /* Unchanged on exit. */
74
75 /* AP - COMPLEX*16 array of DIMENSION at least */
76 /* ( ( n*( n + 1 ) )/2 ). */
77 /* Before entry with UPLO = 'U' or 'u', the array AP must */
78 /* contain the upper triangular part of the hermitian matrix */
79 /* packed sequentially, column by column, so that AP( 1 ) */
80 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
81 /* and a( 2, 2 ) respectively, and so on. On exit, the array */
82 /* AP is overwritten by the upper triangular part of the */
83 /* updated matrix. */
84 /* Before entry with UPLO = 'L' or 'l', the array AP must */
85 /* contain the lower triangular part of the hermitian matrix */
86 /* packed sequentially, column by column, so that AP( 1 ) */
87 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
88 /* and a( 3, 1 ) respectively, and so on. On exit, the array */
89 /* AP is overwritten by the lower triangular part of the */
90 /* updated matrix. */
91 /* Note that the imaginary parts of the diagonal elements need */
92 /* not be set, they are assumed to be zero, and on exit they */
93 /* are set to zero. */
94
95
96 /* Level 2 Blas routine. */
97
98 /* -- Written on 22-October-1986. */
99 /* Jack Dongarra, Argonne National Lab. */
100 /* Jeremy Du Croz, Nag Central Office. */
101 /* Sven Hammarling, Nag Central Office. */
102 /* Richard Hanson, Sandia National Labs. */
103
104
105 /* .. Parameters .. */
106 /* .. Local Scalars .. */
107 /* .. External Functions .. */
108 /* .. External Subroutines .. */
109 /* .. Intrinsic Functions .. */
110 /* .. */
111 /* .. Executable Statements .. */
112
113 /* Test the input parameters. */
114
115 /* Parameter adjustments */
116 --ap;
117 --x;
118
119 /* Function Body */
120 info = 0;
121 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
122 ftnlen)1, (ftnlen)1)) {
123 info = 1;
124 } else if (*n < 0) {
125 info = 2;
126 } else if (*incx == 0) {
127 info = 5;
128 }
129 if (info != 0) {
130 xerbla_("ZHPR ", &info, (ftnlen)6);
131 return 0;
132 }
133
134 /* Quick return if possible. */
135
136 if (*n == 0 || *alpha == 0.) {
137 return 0;
138 }
139
140 /* Set the start point in X if the increment is not unity. */
141
142 if (*incx <= 0) {
143 kx = 1 - (*n - 1) * *incx;
144 } else if (*incx != 1) {
145 kx = 1;
146 }
147
148 /* Start the operations. In this version the elements of the array AP */
149 /* are accessed sequentially with one pass through AP. */
150
151 kk = 1;
152 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
153
154 /* Form A when upper triangle is stored in AP. */
155
156 if (*incx == 1) {
157 i__1 = *n;
158 for (j = 1; j <= i__1; ++j) {
159 i__2 = j;
160 if (x[i__2].r != 0. || x[i__2].i != 0.) {
161 d_cnjg(&z__2, &x[j]);
162 z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
163 temp.r = z__1.r, temp.i = z__1.i;
164 k = kk;
165 i__2 = j - 1;
166 for (i__ = 1; i__ <= i__2; ++i__) {
167 i__3 = k;
168 i__4 = k;
169 i__5 = i__;
170 z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
171 z__2.i = x[i__5].r * temp.i + x[i__5].i *
172 temp.r;
173 z__1.r = ap[i__4].r + z__2.r, z__1.i = ap[i__4].i +
174 z__2.i;
175 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
176 ++k;
177 /* L10: */
178 }
179 i__2 = kk + j - 1;
180 i__3 = kk + j - 1;
181 i__4 = j;
182 z__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, z__1.i =
183 x[i__4].r * temp.i + x[i__4].i * temp.r;
184 d__1 = ap[i__3].r + z__1.r;
185 ap[i__2].r = d__1, ap[i__2].i = 0.;
186 } else {
187 i__2 = kk + j - 1;
188 i__3 = kk + j - 1;
189 d__1 = ap[i__3].r;
190 ap[i__2].r = d__1, ap[i__2].i = 0.;
191 }
192 kk += j;
193 /* L20: */
194 }
195 } else {
196 jx = kx;
197 i__1 = *n;
198 for (j = 1; j <= i__1; ++j) {
199 i__2 = jx;
200 if (x[i__2].r != 0. || x[i__2].i != 0.) {
201 d_cnjg(&z__2, &x[jx]);
202 z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
203 temp.r = z__1.r, temp.i = z__1.i;
204 ix = kx;
205 i__2 = kk + j - 2;
206 for (k = kk; k <= i__2; ++k) {
207 i__3 = k;
208 i__4 = k;
209 i__5 = ix;
210 z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
211 z__2.i = x[i__5].r * temp.i + x[i__5].i *
212 temp.r;
213 z__1.r = ap[i__4].r + z__2.r, z__1.i = ap[i__4].i +
214 z__2.i;
215 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
216 ix += *incx;
217 /* L30: */
218 }
219 i__2 = kk + j - 1;
220 i__3 = kk + j - 1;
221 i__4 = jx;
222 z__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, z__1.i =
223 x[i__4].r * temp.i + x[i__4].i * temp.r;
224 d__1 = ap[i__3].r + z__1.r;
225 ap[i__2].r = d__1, ap[i__2].i = 0.;
226 } else {
227 i__2 = kk + j - 1;
228 i__3 = kk + j - 1;
229 d__1 = ap[i__3].r;
230 ap[i__2].r = d__1, ap[i__2].i = 0.;
231 }
232 jx += *incx;
233 kk += j;
234 /* L40: */
235 }
236 }
237 } else {
238
239 /* Form A when lower triangle is stored in AP. */
240
241 if (*incx == 1) {
242 i__1 = *n;
243 for (j = 1; j <= i__1; ++j) {
244 i__2 = j;
245 if (x[i__2].r != 0. || x[i__2].i != 0.) {
246 d_cnjg(&z__2, &x[j]);
247 z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
248 temp.r = z__1.r, temp.i = z__1.i;
249 i__2 = kk;
250 i__3 = kk;
251 i__4 = j;
252 z__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, z__1.i =
253 temp.r * x[i__4].i + temp.i * x[i__4].r;
254 d__1 = ap[i__3].r + z__1.r;
255 ap[i__2].r = d__1, ap[i__2].i = 0.;
256 k = kk + 1;
257 i__2 = *n;
258 for (i__ = j + 1; i__ <= i__2; ++i__) {
259 i__3 = k;
260 i__4 = k;
261 i__5 = i__;
262 z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
263 z__2.i = x[i__5].r * temp.i + x[i__5].i *
264 temp.r;
265 z__1.r = ap[i__4].r + z__2.r, z__1.i = ap[i__4].i +
266 z__2.i;
267 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
268 ++k;
269 /* L50: */
270 }
271 } else {
272 i__2 = kk;
273 i__3 = kk;
274 d__1 = ap[i__3].r;
275 ap[i__2].r = d__1, ap[i__2].i = 0.;
276 }
277 kk = kk + *n - j + 1;
278 /* L60: */
279 }
280 } else {
281 jx = kx;
282 i__1 = *n;
283 for (j = 1; j <= i__1; ++j) {
284 i__2 = jx;
285 if (x[i__2].r != 0. || x[i__2].i != 0.) {
286 d_cnjg(&z__2, &x[jx]);
287 z__1.r = *alpha * z__2.r, z__1.i = *alpha * z__2.i;
288 temp.r = z__1.r, temp.i = z__1.i;
289 i__2 = kk;
290 i__3 = kk;
291 i__4 = jx;
292 z__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, z__1.i =
293 temp.r * x[i__4].i + temp.i * x[i__4].r;
294 d__1 = ap[i__3].r + z__1.r;
295 ap[i__2].r = d__1, ap[i__2].i = 0.;
296 ix = jx;
297 i__2 = kk + *n - j;
298 for (k = kk + 1; k <= i__2; ++k) {
299 ix += *incx;
300 i__3 = k;
301 i__4 = k;
302 i__5 = ix;
303 z__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
304 z__2.i = x[i__5].r * temp.i + x[i__5].i *
305 temp.r;
306 z__1.r = ap[i__4].r + z__2.r, z__1.i = ap[i__4].i +
307 z__2.i;
308 ap[i__3].r = z__1.r, ap[i__3].i = z__1.i;
309 /* L70: */
310 }
311 } else {
312 i__2 = kk;
313 i__3 = kk;
314 d__1 = ap[i__3].r;
315 ap[i__2].r = d__1, ap[i__2].i = 0.;
316 }
317 jx += *incx;
318 kk = kk + *n - j + 1;
319 /* L80: */
320 }
321 }
322 }
323
324 return 0;
325
326 /* End of ZHPR . */
327
328 } /* zhpr_ */
329