Debian Codegraph @

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

raw
1 /* ./src_f77/ssyr2.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 ssyr2_(char *uplo, integer *n, real *alpha, real *x,
9 integer *incx, real *y, integer *incy, real *a, integer *lda, ftnlen
10 uplo_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2;
14
15 /* Local variables */
16 static integer i__, j, ix, iy, jx, jy, kx, ky, info;
17 static real temp1, temp2;
18 extern logical lsame_(char *, char *, ftnlen, ftnlen);
19 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
20
21 /* .. Scalar Arguments .. */
22 /* .. Array Arguments .. */
23 /* .. */
24
25 /* Purpose */
26 /* ======= */
27
28 /* SSYR2 performs the symmetric rank 2 operation */
29
30 /* A := alpha*x*y' + alpha*y*x' + A, */
31
32 /* where alpha is a scalar, x and y are n element vectors and A is an n */
33 /* by n symmetric matrix. */
34
35 /* Parameters */
36 /* ========== */
37
38 /* UPLO - CHARACTER*1. */
39 /* On entry, UPLO specifies whether the upper or lower */
40 /* triangular part of the array A is to be referenced as */
41 /* follows: */
42
43 /* UPLO = 'U' or 'u' Only the upper triangular part of A */
44 /* is to be referenced. */
45
46 /* UPLO = 'L' or 'l' Only the lower triangular part of A */
47 /* is to be referenced. */
48
49 /* Unchanged on exit. */
50
51 /* N - INTEGER. */
52 /* On entry, N specifies the order of the matrix A. */
53 /* N must be at least zero. */
54 /* Unchanged on exit. */
55
56 /* ALPHA - REAL . */
57 /* On entry, ALPHA specifies the scalar alpha. */
58 /* Unchanged on exit. */
59
60 /* X - REAL array of dimension at least */
61 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
62 /* Before entry, the incremented array X must contain the n */
63 /* element vector x. */
64 /* Unchanged on exit. */
65
66 /* INCX - INTEGER. */
67 /* On entry, INCX specifies the increment for the elements of */
68 /* X. INCX must not be zero. */
69 /* Unchanged on exit. */
70
71 /* Y - REAL array of dimension at least */
72 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
73 /* Before entry, the incremented array Y must contain the n */
74 /* element vector y. */
75 /* Unchanged on exit. */
76
77 /* INCY - INTEGER. */
78 /* On entry, INCY specifies the increment for the elements of */
79 /* Y. INCY must not be zero. */
80 /* Unchanged on exit. */
81
82 /* A - REAL array of DIMENSION ( LDA, n ). */
83 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
84 /* upper triangular part of the array A must contain the upper */
85 /* triangular part of the symmetric matrix and the strictly */
86 /* lower triangular part of A is not referenced. On exit, the */
87 /* upper triangular part of the array A is overwritten by the */
88 /* upper triangular part of the updated matrix. */
89 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
90 /* lower triangular part of the array A must contain the lower */
91 /* triangular part of the symmetric matrix and the strictly */
92 /* upper triangular part of A is not referenced. On exit, the */
93 /* lower triangular part of the array A is overwritten by the */
94 /* lower triangular part of the updated matrix. */
95
96 /* LDA - INTEGER. */
97 /* On entry, LDA specifies the first dimension of A as declared */
98 /* in the calling (sub) program. LDA must be at least */
99 /* max( 1, n ). */
100 /* Unchanged on exit. */
101
102
103 /* Level 2 Blas routine. */
104
105 /* -- Written on 22-October-1986. */
106 /* Jack Dongarra, Argonne National Lab. */
107 /* Jeremy Du Croz, Nag Central Office. */
108 /* Sven Hammarling, Nag Central Office. */
109 /* Richard Hanson, Sandia National Labs. */
110
111
112 /* .. Parameters .. */
113 /* .. Local Scalars .. */
114 /* .. External Functions .. */
115 /* .. External Subroutines .. */
116 /* .. Intrinsic Functions .. */
117 /* .. */
118 /* .. Executable Statements .. */
119
120 /* Test the input parameters. */
121
122 /* Parameter adjustments */
123 --x;
124 --y;
125 a_dim1 = *lda;
126 a_offset = 1 + a_dim1;
127 a -= a_offset;
128
129 /* Function Body */
130 info = 0;
131 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
132 ftnlen)1, (ftnlen)1)) {
133 info = 1;
134 } else if (*n < 0) {
135 info = 2;
136 } else if (*incx == 0) {
137 info = 5;
138 } else if (*incy == 0) {
139 info = 7;
140 } else if (*lda < max(1,*n)) {
141 info = 9;
142 }
143 if (info != 0) {
144 xerbla_("SSYR2 ", &info, (ftnlen)6);
145 return 0;
146 }
147
148 /* Quick return if possible. */
149
150 if (*n == 0 || *alpha == 0.f) {
151 return 0;
152 }
153
154 /* Set up the start points in X and Y if the increments are not both */
155 /* unity. */
156
157 if (*incx != 1 || *incy != 1) {
158 if (*incx > 0) {
159 kx = 1;
160 } else {
161 kx = 1 - (*n - 1) * *incx;
162 }
163 if (*incy > 0) {
164 ky = 1;
165 } else {
166 ky = 1 - (*n - 1) * *incy;
167 }
168 jx = kx;
169 jy = ky;
170 }
171
172 /* Start the operations. In this version the elements of A are */
173 /* accessed sequentially with one pass through the triangular part */
174 /* of A. */
175
176 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
177
178 /* Form A when A is stored in the upper triangle. */
179
180 if (*incx == 1 && *incy == 1) {
181 i__1 = *n;
182 for (j = 1; j <= i__1; ++j) {
183 if (x[j] != 0.f || y[j] != 0.f) {
184 temp1 = *alpha * y[j];
185 temp2 = *alpha * x[j];
186 i__2 = j;
187 for (i__ = 1; i__ <= i__2; ++i__) {
188 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
189 temp1 + y[i__] * temp2;
190 /* L10: */
191 }
192 }
193 /* L20: */
194 }
195 } else {
196 i__1 = *n;
197 for (j = 1; j <= i__1; ++j) {
198 if (x[jx] != 0.f || y[jy] != 0.f) {
199 temp1 = *alpha * y[jy];
200 temp2 = *alpha * x[jx];
201 ix = kx;
202 iy = ky;
203 i__2 = j;
204 for (i__ = 1; i__ <= i__2; ++i__) {
205 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
206 temp1 + y[iy] * temp2;
207 ix += *incx;
208 iy += *incy;
209 /* L30: */
210 }
211 }
212 jx += *incx;
213 jy += *incy;
214 /* L40: */
215 }
216 }
217 } else {
218
219 /* Form A when A is stored in the lower triangle. */
220
221 if (*incx == 1 && *incy == 1) {
222 i__1 = *n;
223 for (j = 1; j <= i__1; ++j) {
224 if (x[j] != 0.f || y[j] != 0.f) {
225 temp1 = *alpha * y[j];
226 temp2 = *alpha * x[j];
227 i__2 = *n;
228 for (i__ = j; i__ <= i__2; ++i__) {
229 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
230 temp1 + y[i__] * temp2;
231 /* L50: */
232 }
233 }
234 /* L60: */
235 }
236 } else {
237 i__1 = *n;
238 for (j = 1; j <= i__1; ++j) {
239 if (x[jx] != 0.f || y[jy] != 0.f) {
240 temp1 = *alpha * y[jy];
241 temp2 = *alpha * x[jx];
242 ix = jx;
243 iy = jy;
244 i__2 = *n;
245 for (i__ = j; i__ <= i__2; ++i__) {
246 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
247 temp1 + y[iy] * temp2;
248 ix += *incx;
249 iy += *incy;
250 /* L70: */
251 }
252 }
253 jx += *incx;
254 jy += *incy;
255 /* L80: */
256 }
257 }
258 }
259
260 return 0;
261
262 /* End of SSYR2 . */
263
264 } /* ssyr2_ */
265