Debian Codegraph @

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

raw
1 /* ./src_f77/chpr.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 chpr_(char *uplo, integer *n, real *alpha, realcomplex *x,
9 integer *incx, realcomplex *ap, ftnlen uplo_len)
10 {
11 /* System generated locals */
12 integer i__1, i__2, i__3, i__4, i__5;
13 real r__1;
14 realcomplex q__1, q__2;
15
16 /* Builtin functions */
17 void r_cnjg(realcomplex *, realcomplex *);
18
19 /* Local variables */
20 static integer i__, j, k, kk, ix, jx, kx, info;
21 static realcomplex 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 /* CHPR 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 - REAL . */
61 /* On entry, ALPHA specifies the scalar alpha. */
62 /* Unchanged on exit. */
63
64 /* X - COMPLEX 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 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_("CHPR ", &info, (ftnlen)6);
131 return 0;
132 }
133
134 /* Quick return if possible. */
135
136 if (*n == 0 || *alpha == 0.f) {
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.f || x[i__2].i != 0.f) {
161 r_cnjg(&q__2, &x[j]);
162 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
163 temp.r = q__1.r, temp.i = q__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 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
171 q__2.i = x[i__5].r * temp.i + x[i__5].i *
172 temp.r;
173 q__1.r = ap[i__4].r + q__2.r, q__1.i = ap[i__4].i +
174 q__2.i;
175 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
176 ++k;
177 /* L10: */
178 }
179 i__2 = kk + j - 1;
180 i__3 = kk + j - 1;
181 i__4 = j;
182 q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
183 x[i__4].r * temp.i + x[i__4].i * temp.r;
184 r__1 = ap[i__3].r + q__1.r;
185 ap[i__2].r = r__1, ap[i__2].i = 0.f;
186 } else {
187 i__2 = kk + j - 1;
188 i__3 = kk + j - 1;
189 r__1 = ap[i__3].r;
190 ap[i__2].r = r__1, ap[i__2].i = 0.f;
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.f || x[i__2].i != 0.f) {
201 r_cnjg(&q__2, &x[jx]);
202 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
203 temp.r = q__1.r, temp.i = q__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 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
211 q__2.i = x[i__5].r * temp.i + x[i__5].i *
212 temp.r;
213 q__1.r = ap[i__4].r + q__2.r, q__1.i = ap[i__4].i +
214 q__2.i;
215 ap[i__3].r = q__1.r, ap[i__3].i = q__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 q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
223 x[i__4].r * temp.i + x[i__4].i * temp.r;
224 r__1 = ap[i__3].r + q__1.r;
225 ap[i__2].r = r__1, ap[i__2].i = 0.f;
226 } else {
227 i__2 = kk + j - 1;
228 i__3 = kk + j - 1;
229 r__1 = ap[i__3].r;
230 ap[i__2].r = r__1, ap[i__2].i = 0.f;
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.f || x[i__2].i != 0.f) {
246 r_cnjg(&q__2, &x[j]);
247 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
248 temp.r = q__1.r, temp.i = q__1.i;
249 i__2 = kk;
250 i__3 = kk;
251 i__4 = j;
252 q__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, q__1.i =
253 temp.r * x[i__4].i + temp.i * x[i__4].r;
254 r__1 = ap[i__3].r + q__1.r;
255 ap[i__2].r = r__1, ap[i__2].i = 0.f;
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 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
263 q__2.i = x[i__5].r * temp.i + x[i__5].i *
264 temp.r;
265 q__1.r = ap[i__4].r + q__2.r, q__1.i = ap[i__4].i +
266 q__2.i;
267 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
268 ++k;
269 /* L50: */
270 }
271 } else {
272 i__2 = kk;
273 i__3 = kk;
274 r__1 = ap[i__3].r;
275 ap[i__2].r = r__1, ap[i__2].i = 0.f;
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.f || x[i__2].i != 0.f) {
286 r_cnjg(&q__2, &x[jx]);
287 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
288 temp.r = q__1.r, temp.i = q__1.i;
289 i__2 = kk;
290 i__3 = kk;
291 i__4 = jx;
292 q__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, q__1.i =
293 temp.r * x[i__4].i + temp.i * x[i__4].r;
294 r__1 = ap[i__3].r + q__1.r;
295 ap[i__2].r = r__1, ap[i__2].i = 0.f;
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 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
304 q__2.i = x[i__5].r * temp.i + x[i__5].i *
305 temp.r;
306 q__1.r = ap[i__4].r + q__2.r, q__1.i = ap[i__4].i +
307 q__2.i;
308 ap[i__3].r = q__1.r, ap[i__3].i = q__1.i;
309 /* L70: */
310 }
311 } else {
312 i__2 = kk;
313 i__3 = kk;
314 r__1 = ap[i__3].r;
315 ap[i__2].r = r__1, ap[i__2].i = 0.f;
316 }
317 jx += *incx;
318 kk = kk + *n - j + 1;
319 /* L80: */
320 }
321 }
322 }
323
324 return 0;
325
326 /* End of CHPR . */
327
328 } /* chpr_ */
329