Debian Codegraph @

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

raw
1 /* ./src_f77/cher.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 cher_(char *uplo, integer *n, real *alpha, realcomplex *x,
9 integer *incx, realcomplex *a, integer *lda, ftnlen uplo_len)
10 {
11 /* System generated locals */
12 integer a_dim1, a_offset, 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, 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 /* CHER 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. */
38
39 /* Parameters */
40 /* ========== */
41
42 /* UPLO - CHARACTER*1. */
43 /* On entry, UPLO specifies whether the upper or lower */
44 /* triangular part of the array A is to be referenced as */
45 /* follows: */
46
47 /* UPLO = 'U' or 'u' Only the upper triangular part of A */
48 /* is to be referenced. */
49
50 /* UPLO = 'L' or 'l' Only the lower triangular part of A */
51 /* is to be referenced. */
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 /* A - COMPLEX array of DIMENSION ( LDA, n ). */
76 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
77 /* upper triangular part of the array A must contain the upper */
78 /* triangular part of the hermitian matrix and the strictly */
79 /* lower triangular part of A is not referenced. On exit, the */
80 /* upper triangular part of the array A is overwritten by the */
81 /* upper triangular part of the updated matrix. */
82 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
83 /* lower triangular part of the array A must contain the lower */
84 /* triangular part of the hermitian matrix and the strictly */
85 /* upper triangular part of A is not referenced. On exit, the */
86 /* lower triangular part of the array A is overwritten by the */
87 /* lower triangular part of the updated matrix. */
88 /* Note that the imaginary parts of the diagonal elements need */
89 /* not be set, they are assumed to be zero, and on exit they */
90 /* are set to zero. */
91
92 /* LDA - INTEGER. */
93 /* On entry, LDA specifies the first dimension of A as declared */
94 /* in the calling (sub) program. LDA must be at least */
95 /* max( 1, n ). */
96 /* Unchanged on exit. */
97
98
99 /* Level 2 Blas routine. */
100
101 /* -- Written on 22-October-1986. */
102 /* Jack Dongarra, Argonne National Lab. */
103 /* Jeremy Du Croz, Nag Central Office. */
104 /* Sven Hammarling, Nag Central Office. */
105 /* Richard Hanson, Sandia National Labs. */
106
107
108 /* .. Parameters .. */
109 /* .. Local Scalars .. */
110 /* .. External Functions .. */
111 /* .. External Subroutines .. */
112 /* .. Intrinsic Functions .. */
113 /* .. */
114 /* .. Executable Statements .. */
115
116 /* Test the input parameters. */
117
118 /* Parameter adjustments */
119 --x;
120 a_dim1 = *lda;
121 a_offset = 1 + a_dim1;
122 a -= a_offset;
123
124 /* Function Body */
125 info = 0;
126 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
127 ftnlen)1, (ftnlen)1)) {
128 info = 1;
129 } else if (*n < 0) {
130 info = 2;
131 } else if (*incx == 0) {
132 info = 5;
133 } else if (*lda < max(1,*n)) {
134 info = 7;
135 }
136 if (info != 0) {
137 xerbla_("CHER ", &info, (ftnlen)6);
138 return 0;
139 }
140
141 /* Quick return if possible. */
142
143 if (*n == 0 || *alpha == 0.f) {
144 return 0;
145 }
146
147 /* Set the start point in X if the increment is not unity. */
148
149 if (*incx <= 0) {
150 kx = 1 - (*n - 1) * *incx;
151 } else if (*incx != 1) {
152 kx = 1;
153 }
154
155 /* Start the operations. In this version the elements of A are */
156 /* accessed sequentially with one pass through the triangular part */
157 /* of A. */
158
159 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
160
161 /* Form A when A is stored in upper triangle. */
162
163 if (*incx == 1) {
164 i__1 = *n;
165 for (j = 1; j <= i__1; ++j) {
166 i__2 = j;
167 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
168 r_cnjg(&q__2, &x[j]);
169 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
170 temp.r = q__1.r, temp.i = q__1.i;
171 i__2 = j - 1;
172 for (i__ = 1; i__ <= i__2; ++i__) {
173 i__3 = i__ + j * a_dim1;
174 i__4 = i__ + j * a_dim1;
175 i__5 = i__;
176 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
177 q__2.i = x[i__5].r * temp.i + x[i__5].i *
178 temp.r;
179 q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
180 q__2.i;
181 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
182 /* L10: */
183 }
184 i__2 = j + j * a_dim1;
185 i__3 = j + j * a_dim1;
186 i__4 = j;
187 q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
188 x[i__4].r * temp.i + x[i__4].i * temp.r;
189 r__1 = a[i__3].r + q__1.r;
190 a[i__2].r = r__1, a[i__2].i = 0.f;
191 } else {
192 i__2 = j + j * a_dim1;
193 i__3 = j + j * a_dim1;
194 r__1 = a[i__3].r;
195 a[i__2].r = r__1, a[i__2].i = 0.f;
196 }
197 /* L20: */
198 }
199 } else {
200 jx = kx;
201 i__1 = *n;
202 for (j = 1; j <= i__1; ++j) {
203 i__2 = jx;
204 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
205 r_cnjg(&q__2, &x[jx]);
206 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
207 temp.r = q__1.r, temp.i = q__1.i;
208 ix = kx;
209 i__2 = j - 1;
210 for (i__ = 1; i__ <= i__2; ++i__) {
211 i__3 = i__ + j * a_dim1;
212 i__4 = i__ + j * a_dim1;
213 i__5 = ix;
214 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
215 q__2.i = x[i__5].r * temp.i + x[i__5].i *
216 temp.r;
217 q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
218 q__2.i;
219 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
220 ix += *incx;
221 /* L30: */
222 }
223 i__2 = j + j * a_dim1;
224 i__3 = j + j * a_dim1;
225 i__4 = jx;
226 q__1.r = x[i__4].r * temp.r - x[i__4].i * temp.i, q__1.i =
227 x[i__4].r * temp.i + x[i__4].i * temp.r;
228 r__1 = a[i__3].r + q__1.r;
229 a[i__2].r = r__1, a[i__2].i = 0.f;
230 } else {
231 i__2 = j + j * a_dim1;
232 i__3 = j + j * a_dim1;
233 r__1 = a[i__3].r;
234 a[i__2].r = r__1, a[i__2].i = 0.f;
235 }
236 jx += *incx;
237 /* L40: */
238 }
239 }
240 } else {
241
242 /* Form A when A is stored in lower triangle. */
243
244 if (*incx == 1) {
245 i__1 = *n;
246 for (j = 1; j <= i__1; ++j) {
247 i__2 = j;
248 if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
249 r_cnjg(&q__2, &x[j]);
250 q__1.r = *alpha * q__2.r, q__1.i = *alpha * q__2.i;
251 temp.r = q__1.r, temp.i = q__1.i;
252 i__2 = j + j * a_dim1;
253 i__3 = j + j * a_dim1;
254 i__4 = j;
255 q__1.r = temp.r * x[i__4].r - temp.i * x[i__4].i, q__1.i =
256 temp.r * x[i__4].i + temp.i * x[i__4].r;
257 r__1 = a[i__3].r + q__1.r;
258 a[i__2].r = r__1, a[i__2].i = 0.f;
259 i__2 = *n;
260 for (i__ = j + 1; i__ <= i__2; ++i__) {
261 i__3 = i__ + j * a_dim1;
262 i__4 = i__ + j * a_dim1;
263 i__5 = i__;
264 q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
265 q__2.i = x[i__5].r * temp.i + x[i__5].i *
266 temp.r;
267 q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
268 q__2.i;
269 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
270 /* L50: */
271 }
272 } else {
273 i__2 = j + j * a_dim1;
274 i__3 = j + j * a_dim1;
275 r__1 = a[i__3].r;
276 a[i__2].r = r__1, a[i__2].i = 0.f;
277 }
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 = j + j * a_dim1;
290 i__3 = j + j * a_dim1;
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 = a[i__3].r + q__1.r;
295 a[i__2].r = r__1, a[i__2].i = 0.f;
296 ix = jx;
297 i__2 = *n;
298 for (i__ = j + 1; i__ <= i__2; ++i__) {
299 ix += *incx;
300 i__3 = i__ + j * a_dim1;
301 i__4 = i__ + j * a_dim1;
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 = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
307 q__2.i;
308 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
309 /* L70: */
310 }
311 } else {
312 i__2 = j + j * a_dim1;
313 i__3 = j + j * a_dim1;
314 r__1 = a[i__3].r;
315 a[i__2].r = r__1, a[i__2].i = 0.f;
316 }
317 jx += *incx;
318 /* L80: */
319 }
320 }
321 }
322
323 return 0;
324
325 /* End of CHER . */
326
327 } /* cher_ */
328