Debian Codegraph @

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

raw
1 /* ./src_f77/dspr2.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 dspr2_(char *uplo, integer *n, doublereal *alpha,
9 doublereal *x, integer *incx, doublereal *y, integer *incy,
10 doublereal *ap, ftnlen uplo_len)
11 {
12 /* System generated locals */
13 integer i__1, i__2;
14
15 /* Local variables */
16 static integer i__, j, k, kk, ix, iy, jx, jy, kx, ky, info;
17 static doublereal 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 /* DSPR2 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 */
33 /* n by n symmetric matrix, supplied in packed form. */
34
35 /* Parameters */
36 /* ========== */
37
38 /* UPLO - CHARACTER*1. */
39 /* On entry, UPLO specifies whether the upper or lower */
40 /* triangular part of the matrix A is supplied in the packed */
41 /* array AP as follows: */
42
43 /* UPLO = 'U' or 'u' The upper triangular part of A is */
44 /* supplied in AP. */
45
46 /* UPLO = 'L' or 'l' The lower triangular part of A is */
47 /* supplied in AP. */
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 - DOUBLE PRECISION. */
57 /* On entry, ALPHA specifies the scalar alpha. */
58 /* Unchanged on exit. */
59
60 /* X - DOUBLE PRECISION 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 - DOUBLE PRECISION 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 /* AP - DOUBLE PRECISION array of DIMENSION at least */
83 /* ( ( n*( n + 1 ) )/2 ). */
84 /* Before entry with UPLO = 'U' or 'u', the array AP must */
85 /* contain the upper triangular part of the symmetric matrix */
86 /* packed sequentially, column by column, so that AP( 1 ) */
87 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
88 /* and a( 2, 2 ) respectively, and so on. On exit, the array */
89 /* AP is overwritten by the upper triangular part of the */
90 /* updated matrix. */
91 /* Before entry with UPLO = 'L' or 'l', the array AP must */
92 /* contain the lower triangular part of the symmetric matrix */
93 /* packed sequentially, column by column, so that AP( 1 ) */
94 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
95 /* and a( 3, 1 ) respectively, and so on. On exit, the array */
96 /* AP is overwritten by the lower triangular part of the */
97 /* updated matrix. */
98
99
100 /* Level 2 Blas routine. */
101
102 /* -- Written on 22-October-1986. */
103 /* Jack Dongarra, Argonne National Lab. */
104 /* Jeremy Du Croz, Nag Central Office. */
105 /* Sven Hammarling, Nag Central Office. */
106 /* Richard Hanson, Sandia National Labs. */
107
108
109 /* .. Parameters .. */
110 /* .. Local Scalars .. */
111 /* .. External Functions .. */
112 /* .. External Subroutines .. */
113 /* .. */
114 /* .. Executable Statements .. */
115
116 /* Test the input parameters. */
117
118 /* Parameter adjustments */
119 --ap;
120 --y;
121 --x;
122
123 /* Function Body */
124 info = 0;
125 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
126 ftnlen)1, (ftnlen)1)) {
127 info = 1;
128 } else if (*n < 0) {
129 info = 2;
130 } else if (*incx == 0) {
131 info = 5;
132 } else if (*incy == 0) {
133 info = 7;
134 }
135 if (info != 0) {
136 xerbla_("DSPR2 ", &info, (ftnlen)6);
137 return 0;
138 }
139
140 /* Quick return if possible. */
141
142 if (*n == 0 || *alpha == 0.) {
143 return 0;
144 }
145
146 /* Set up the start points in X and Y if the increments are not both */
147 /* unity. */
148
149 if (*incx != 1 || *incy != 1) {
150 if (*incx > 0) {
151 kx = 1;
152 } else {
153 kx = 1 - (*n - 1) * *incx;
154 }
155 if (*incy > 0) {
156 ky = 1;
157 } else {
158 ky = 1 - (*n - 1) * *incy;
159 }
160 jx = kx;
161 jy = ky;
162 }
163
164 /* Start the operations. In this version the elements of the array AP */
165 /* are accessed sequentially with one pass through AP. */
166
167 kk = 1;
168 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
169
170 /* Form A when upper triangle is stored in AP. */
171
172 if (*incx == 1 && *incy == 1) {
173 i__1 = *n;
174 for (j = 1; j <= i__1; ++j) {
175 if (x[j] != 0. || y[j] != 0.) {
176 temp1 = *alpha * y[j];
177 temp2 = *alpha * x[j];
178 k = kk;
179 i__2 = j;
180 for (i__ = 1; i__ <= i__2; ++i__) {
181 ap[k] = ap[k] + x[i__] * temp1 + y[i__] * temp2;
182 ++k;
183 /* L10: */
184 }
185 }
186 kk += j;
187 /* L20: */
188 }
189 } else {
190 i__1 = *n;
191 for (j = 1; j <= i__1; ++j) {
192 if (x[jx] != 0. || y[jy] != 0.) {
193 temp1 = *alpha * y[jy];
194 temp2 = *alpha * x[jx];
195 ix = kx;
196 iy = ky;
197 i__2 = kk + j - 1;
198 for (k = kk; k <= i__2; ++k) {
199 ap[k] = ap[k] + x[ix] * temp1 + y[iy] * temp2;
200 ix += *incx;
201 iy += *incy;
202 /* L30: */
203 }
204 }
205 jx += *incx;
206 jy += *incy;
207 kk += j;
208 /* L40: */
209 }
210 }
211 } else {
212
213 /* Form A when lower triangle is stored in AP. */
214
215 if (*incx == 1 && *incy == 1) {
216 i__1 = *n;
217 for (j = 1; j <= i__1; ++j) {
218 if (x[j] != 0. || y[j] != 0.) {
219 temp1 = *alpha * y[j];
220 temp2 = *alpha * x[j];
221 k = kk;
222 i__2 = *n;
223 for (i__ = j; i__ <= i__2; ++i__) {
224 ap[k] = ap[k] + x[i__] * temp1 + y[i__] * temp2;
225 ++k;
226 /* L50: */
227 }
228 }
229 kk = kk + *n - j + 1;
230 /* L60: */
231 }
232 } else {
233 i__1 = *n;
234 for (j = 1; j <= i__1; ++j) {
235 if (x[jx] != 0. || y[jy] != 0.) {
236 temp1 = *alpha * y[jy];
237 temp2 = *alpha * x[jx];
238 ix = jx;
239 iy = jy;
240 i__2 = kk + *n - j;
241 for (k = kk; k <= i__2; ++k) {
242 ap[k] = ap[k] + x[ix] * temp1 + y[iy] * temp2;
243 ix += *incx;
244 iy += *incy;
245 /* L70: */
246 }
247 }
248 jx += *incx;
249 jy += *incy;
250 kk = kk + *n - j + 1;
251 /* L80: */
252 }
253 }
254 }
255
256 return 0;
257
258 /* End of DSPR2 . */
259
260 } /* dspr2_ */
261