1 /* ./src_f77/csyr.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 
csyr_(char * uplo,integer * n,complex * alpha,complex * x,integer * incx,complex * a,integer * lda,ftnlen uplo_len)8 /* Subroutine */ int csyr_(char *uplo, integer *n, complex *alpha, complex *x,
9 	 integer *incx, complex *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     complex q__1, q__2;
14 
15     /* Local variables */
16     static integer i__, j, ix, jx, kx, info;
17     static complex temp;
18     extern logical lsame_(char *, char *, ftnlen, ftnlen);
19     extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
20 
21 
22 /*  -- LAPACK auxiliary routine (version 3.0) -- */
23 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
24 /*     Courant Institute, Argonne National Lab, and Rice University */
25 /*     October 31, 1992 */
26 
27 /*     .. Scalar Arguments .. */
28 /*     .. */
29 /*     .. Array Arguments .. */
30 /*     .. */
31 
32 /*  Purpose */
33 /*  ======= */
34 
35 /*  CSYR   performs the symmetric rank 1 operation */
36 
37 /*     A := alpha*x*( x' ) + A, */
38 
39 /*  where alpha is a complex scalar, x is an n element vector and A is an */
40 /*  n by n symmetric matrix. */
41 
42 /*  Arguments */
43 /*  ========== */
44 
45 /*  UPLO   - CHARACTER*1 */
46 /*           On entry, UPLO specifies whether the upper or lower */
47 /*           triangular part of the array A is to be referenced as */
48 /*           follows: */
49 
50 /*              UPLO = 'U' or 'u'   Only the upper triangular part of A */
51 /*                                  is to be referenced. */
52 
53 /*              UPLO = 'L' or 'l'   Only the lower triangular part of A */
54 /*                                  is to be referenced. */
55 
56 /*           Unchanged on exit. */
57 
58 /*  N      - INTEGER */
59 /*           On entry, N specifies the order of the matrix A. */
60 /*           N must be at least zero. */
61 /*           Unchanged on exit. */
62 
63 /*  ALPHA  - COMPLEX */
64 /*           On entry, ALPHA specifies the scalar alpha. */
65 /*           Unchanged on exit. */
66 
67 /*  X      - COMPLEX array, dimension at least */
68 /*           ( 1 + ( N - 1 )*abs( INCX ) ). */
69 /*           Before entry, the incremented array X must contain the N- */
70 /*           element vector x. */
71 /*           Unchanged on exit. */
72 
73 /*  INCX   - INTEGER */
74 /*           On entry, INCX specifies the increment for the elements of */
75 /*           X. INCX must not be zero. */
76 /*           Unchanged on exit. */
77 
78 /*  A      - COMPLEX array, dimension ( LDA, N ) */
79 /*           Before entry, with  UPLO = 'U' or 'u', the leading n by n */
80 /*           upper triangular part of the array A must contain the upper */
81 /*           triangular part of the symmetric matrix and the strictly */
82 /*           lower triangular part of A is not referenced. On exit, the */
83 /*           upper triangular part of the array A is overwritten by the */
84 /*           upper triangular part of the updated matrix. */
85 /*           Before entry, with UPLO = 'L' or 'l', the leading n by n */
86 /*           lower triangular part of the array A must contain the lower */
87 /*           triangular part of the symmetric matrix and the strictly */
88 /*           upper triangular part of A is not referenced. On exit, the */
89 /*           lower triangular part of the array A is overwritten by the */
90 /*           lower triangular part of the updated matrix. */
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 
100 /*     .. Parameters .. */
101 /*     .. */
102 /*     .. Local Scalars .. */
103 /*     .. */
104 /*     .. External Functions .. */
105 /*     .. */
106 /*     .. External Subroutines .. */
107 /*     .. */
108 /*     .. Intrinsic Functions .. */
109 /*     .. */
110 /*     .. Executable Statements .. */
111 
112 /*     Test the input parameters. */
113 
114     /* Parameter adjustments */
115     --x;
116     a_dim1 = *lda;
117     a_offset = 1 + a_dim1;
118     a -= a_offset;
119 
120     /* Function Body */
121     info = 0;
122     if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
123 	    ftnlen)1, (ftnlen)1)) {
124 	info = 1;
125     } else if (*n < 0) {
126 	info = 2;
127     } else if (*incx == 0) {
128 	info = 5;
129     } else if (*lda < max(1,*n)) {
130 	info = 7;
131     }
132     if (info != 0) {
133 	xerbla_("CSYR  ", &info, (ftnlen)6);
134 	return 0;
135     }
136 
137 /*     Quick return if possible. */
138 
139     if (*n == 0 || alpha->r == 0.f && alpha->i == 0.f) {
140 	return 0;
141     }
142 
143 /*     Set the start point in X if the increment is not unity. */
144 
145     if (*incx <= 0) {
146 	kx = 1 - (*n - 1) * *incx;
147     } else if (*incx != 1) {
148 	kx = 1;
149     }
150 
151 /*     Start the operations. In this version the elements of A are */
152 /*     accessed sequentially with one pass through the triangular part */
153 /*     of A. */
154 
155     if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
156 
157 /*        Form  A  when A is stored in upper triangle. */
158 
159 	if (*incx == 1) {
160 	    i__1 = *n;
161 	    for (j = 1; j <= i__1; ++j) {
162 		i__2 = j;
163 		if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
164 		    i__2 = j;
165 		    q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
166 			    q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
167 			    .r;
168 		    temp.r = q__1.r, temp.i = q__1.i;
169 		    i__2 = j;
170 		    for (i__ = 1; i__ <= i__2; ++i__) {
171 			i__3 = i__ + j * a_dim1;
172 			i__4 = i__ + j * a_dim1;
173 			i__5 = i__;
174 			q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
175 				q__2.i = x[i__5].r * temp.i + x[i__5].i *
176 				temp.r;
177 			q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
178 				q__2.i;
179 			a[i__3].r = q__1.r, a[i__3].i = q__1.i;
180 /* L10: */
181 		    }
182 		}
183 /* L20: */
184 	    }
185 	} else {
186 	    jx = kx;
187 	    i__1 = *n;
188 	    for (j = 1; j <= i__1; ++j) {
189 		i__2 = jx;
190 		if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
191 		    i__2 = jx;
192 		    q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
193 			    q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
194 			    .r;
195 		    temp.r = q__1.r, temp.i = q__1.i;
196 		    ix = kx;
197 		    i__2 = j;
198 		    for (i__ = 1; i__ <= i__2; ++i__) {
199 			i__3 = i__ + j * a_dim1;
200 			i__4 = i__ + j * a_dim1;
201 			i__5 = ix;
202 			q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
203 				q__2.i = x[i__5].r * temp.i + x[i__5].i *
204 				temp.r;
205 			q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
206 				q__2.i;
207 			a[i__3].r = q__1.r, a[i__3].i = q__1.i;
208 			ix += *incx;
209 /* L30: */
210 		    }
211 		}
212 		jx += *incx;
213 /* L40: */
214 	    }
215 	}
216     } else {
217 
218 /*        Form  A  when A is stored in lower triangle. */
219 
220 	if (*incx == 1) {
221 	    i__1 = *n;
222 	    for (j = 1; j <= i__1; ++j) {
223 		i__2 = j;
224 		if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
225 		    i__2 = j;
226 		    q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
227 			    q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
228 			    .r;
229 		    temp.r = q__1.r, temp.i = q__1.i;
230 		    i__2 = *n;
231 		    for (i__ = j; i__ <= i__2; ++i__) {
232 			i__3 = i__ + j * a_dim1;
233 			i__4 = i__ + j * a_dim1;
234 			i__5 = i__;
235 			q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
236 				q__2.i = x[i__5].r * temp.i + x[i__5].i *
237 				temp.r;
238 			q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
239 				q__2.i;
240 			a[i__3].r = q__1.r, a[i__3].i = q__1.i;
241 /* L50: */
242 		    }
243 		}
244 /* L60: */
245 	    }
246 	} else {
247 	    jx = kx;
248 	    i__1 = *n;
249 	    for (j = 1; j <= i__1; ++j) {
250 		i__2 = jx;
251 		if (x[i__2].r != 0.f || x[i__2].i != 0.f) {
252 		    i__2 = jx;
253 		    q__1.r = alpha->r * x[i__2].r - alpha->i * x[i__2].i,
254 			    q__1.i = alpha->r * x[i__2].i + alpha->i * x[i__2]
255 			    .r;
256 		    temp.r = q__1.r, temp.i = q__1.i;
257 		    ix = jx;
258 		    i__2 = *n;
259 		    for (i__ = j; i__ <= i__2; ++i__) {
260 			i__3 = i__ + j * a_dim1;
261 			i__4 = i__ + j * a_dim1;
262 			i__5 = ix;
263 			q__2.r = x[i__5].r * temp.r - x[i__5].i * temp.i,
264 				q__2.i = x[i__5].r * temp.i + x[i__5].i *
265 				temp.r;
266 			q__1.r = a[i__4].r + q__2.r, q__1.i = a[i__4].i +
267 				q__2.i;
268 			a[i__3].r = q__1.r, a[i__3].i = q__1.i;
269 			ix += *incx;
270 /* L70: */
271 		    }
272 		}
273 		jx += *incx;
274 /* L80: */
275 	    }
276 	}
277     }
278 
279     return 0;
280 
281 /*     End of CSYR */
282 
283 } /* csyr_ */
284 
285