Debian Codegraph @

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

raw
1 /* ./src_f77/dspmv.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 dspmv_(char *uplo, integer *n, doublereal *alpha,
9 doublereal *ap, doublereal *x, integer *incx, doublereal *beta,
10 doublereal *y, integer *incy, 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 /* DSPMV performs the matrix-vector operation */
29
30 /* y := alpha*A*x + beta*y, */
31
32 /* where alpha and beta are scalars, x and y are n element vectors and */
33 /* A is an 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 /* AP - DOUBLE PRECISION array of DIMENSION at least */
61 /* ( ( n*( n + 1 ) )/2 ). */
62 /* Before entry with UPLO = 'U' or 'u', the array AP must */
63 /* contain the upper triangular part of the symmetric matrix */
64 /* packed sequentially, column by column, so that AP( 1 ) */
65 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
66 /* and a( 2, 2 ) respectively, and so on. */
67 /* Before entry with UPLO = 'L' or 'l', the array AP must */
68 /* contain the lower triangular part of the symmetric matrix */
69 /* packed sequentially, column by column, so that AP( 1 ) */
70 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
71 /* and a( 3, 1 ) respectively, and so on. */
72 /* Unchanged on exit. */
73
74 /* X - DOUBLE PRECISION array of dimension at least */
75 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
76 /* Before entry, the incremented array X must contain the n */
77 /* element vector x. */
78 /* Unchanged on exit. */
79
80 /* INCX - INTEGER. */
81 /* On entry, INCX specifies the increment for the elements of */
82 /* X. INCX must not be zero. */
83 /* Unchanged on exit. */
84
85 /* BETA - DOUBLE PRECISION. */
86 /* On entry, BETA specifies the scalar beta. When BETA is */
87 /* supplied as zero then Y need not be set on input. */
88 /* Unchanged on exit. */
89
90 /* Y - DOUBLE PRECISION array of dimension at least */
91 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
92 /* Before entry, the incremented array Y must contain the n */
93 /* element vector y. On exit, Y is overwritten by the updated */
94 /* vector y. */
95
96 /* INCY - INTEGER. */
97 /* On entry, INCY specifies the increment for the elements of */
98 /* Y. INCY must not be zero. */
99 /* Unchanged on exit. */
100
101
102 /* Level 2 Blas routine. */
103
104 /* -- Written on 22-October-1986. */
105 /* Jack Dongarra, Argonne National Lab. */
106 /* Jeremy Du Croz, Nag Central Office. */
107 /* Sven Hammarling, Nag Central Office. */
108 /* Richard Hanson, Sandia National Labs. */
109
110
111 /* .. Parameters .. */
112 /* .. Local Scalars .. */
113 /* .. External Functions .. */
114 /* .. External Subroutines .. */
115 /* .. */
116 /* .. Executable Statements .. */
117
118 /* Test the input parameters. */
119
120 /* Parameter adjustments */
121 --y;
122 --x;
123 --ap;
124
125 /* Function Body */
126 info = 0;
127 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
128 ftnlen)1, (ftnlen)1)) {
129 info = 1;
130 } else if (*n < 0) {
131 info = 2;
132 } else if (*incx == 0) {
133 info = 6;
134 } else if (*incy == 0) {
135 info = 9;
136 }
137 if (info != 0) {
138 xerbla_("DSPMV ", &info, (ftnlen)6);
139 return 0;
140 }
141
142 /* Quick return if possible. */
143
144 if (*n == 0 || *alpha == 0. && *beta == 1.) {
145 return 0;
146 }
147
148 /* Set up the start points in X and Y. */
149
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
161 /* Start the operations. In this version the elements of the array AP */
162 /* are accessed sequentially with one pass through AP. */
163
164 /* First form y := beta*y. */
165
166 if (*beta != 1.) {
167 if (*incy == 1) {
168 if (*beta == 0.) {
169 i__1 = *n;
170 for (i__ = 1; i__ <= i__1; ++i__) {
171 y[i__] = 0.;
172 /* L10: */
173 }
174 } else {
175 i__1 = *n;
176 for (i__ = 1; i__ <= i__1; ++i__) {
177 y[i__] = *beta * y[i__];
178 /* L20: */
179 }
180 }
181 } else {
182 iy = ky;
183 if (*beta == 0.) {
184 i__1 = *n;
185 for (i__ = 1; i__ <= i__1; ++i__) {
186 y[iy] = 0.;
187 iy += *incy;
188 /* L30: */
189 }
190 } else {
191 i__1 = *n;
192 for (i__ = 1; i__ <= i__1; ++i__) {
193 y[iy] = *beta * y[iy];
194 iy += *incy;
195 /* L40: */
196 }
197 }
198 }
199 }
200 if (*alpha == 0.) {
201 return 0;
202 }
203 kk = 1;
204 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
205
206 /* Form y when AP contains the upper triangle. */
207
208 if (*incx == 1 && *incy == 1) {
209 i__1 = *n;
210 for (j = 1; j <= i__1; ++j) {
211 temp1 = *alpha * x[j];
212 temp2 = 0.;
213 k = kk;
214 i__2 = j - 1;
215 for (i__ = 1; i__ <= i__2; ++i__) {
216 y[i__] += temp1 * ap[k];
217 temp2 += ap[k] * x[i__];
218 ++k;
219 /* L50: */
220 }
221 y[j] = y[j] + temp1 * ap[kk + j - 1] + *alpha * temp2;
222 kk += j;
223 /* L60: */
224 }
225 } else {
226 jx = kx;
227 jy = ky;
228 i__1 = *n;
229 for (j = 1; j <= i__1; ++j) {
230 temp1 = *alpha * x[jx];
231 temp2 = 0.;
232 ix = kx;
233 iy = ky;
234 i__2 = kk + j - 2;
235 for (k = kk; k <= i__2; ++k) {
236 y[iy] += temp1 * ap[k];
237 temp2 += ap[k] * x[ix];
238 ix += *incx;
239 iy += *incy;
240 /* L70: */
241 }
242 y[jy] = y[jy] + temp1 * ap[kk + j - 1] + *alpha * temp2;
243 jx += *incx;
244 jy += *incy;
245 kk += j;
246 /* L80: */
247 }
248 }
249 } else {
250
251 /* Form y when AP contains the lower triangle. */
252
253 if (*incx == 1 && *incy == 1) {
254 i__1 = *n;
255 for (j = 1; j <= i__1; ++j) {
256 temp1 = *alpha * x[j];
257 temp2 = 0.;
258 y[j] += temp1 * ap[kk];
259 k = kk + 1;
260 i__2 = *n;
261 for (i__ = j + 1; i__ <= i__2; ++i__) {
262 y[i__] += temp1 * ap[k];
263 temp2 += ap[k] * x[i__];
264 ++k;
265 /* L90: */
266 }
267 y[j] += *alpha * temp2;
268 kk += *n - j + 1;
269 /* L100: */
270 }
271 } else {
272 jx = kx;
273 jy = ky;
274 i__1 = *n;
275 for (j = 1; j <= i__1; ++j) {
276 temp1 = *alpha * x[jx];
277 temp2 = 0.;
278 y[jy] += temp1 * ap[kk];
279 ix = jx;
280 iy = jy;
281 i__2 = kk + *n - j;
282 for (k = kk + 1; k <= i__2; ++k) {
283 ix += *incx;
284 iy += *incy;
285 y[iy] += temp1 * ap[k];
286 temp2 += ap[k] * x[ix];
287 /* L110: */
288 }
289 y[jy] += *alpha * temp2;
290 jx += *incx;
291 jy += *incy;
292 kk += *n - j + 1;
293 /* L120: */
294 }
295 }
296 }
297
298 return 0;
299
300 /* End of DSPMV . */
301
302 } /* dspmv_ */
303