Debian Codegraph @

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

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