Debian Codegraph @

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

raw
1 /* ./src_f77/ssbmv.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 ssbmv_(char *uplo, integer *n, integer *k, real *alpha,
9 real *a, integer *lda, real *x, integer *incx, real *beta, real *y,
10 integer *incy, ftnlen uplo_len)
11 {
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
14
15 /* Local variables */
16 static integer i__, j, l, ix, iy, jx, jy, kx, ky, info;
17 static real temp1, temp2;
18 extern logical lsame_(char *, char *, ftnlen, ftnlen);
19 static integer kplus1;
20 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
21
22 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
24 /* .. */
25
26 /* Purpose */
27 /* ======= */
28
29 /* SSBMV performs the matrix-vector operation */
30
31 /* y := alpha*A*x + beta*y, */
32
33 /* where alpha and beta are scalars, x and y are n element vectors and */
34 /* A is an n by n symmetric band matrix, with k super-diagonals. */
35
36 /* Parameters */
37 /* ========== */
38
39 /* UPLO - CHARACTER*1. */
40 /* On entry, UPLO specifies whether the upper or lower */
41 /* triangular part of the band matrix A is being supplied as */
42 /* follows: */
43
44 /* UPLO = 'U' or 'u' The upper triangular part of A is */
45 /* being supplied. */
46
47 /* UPLO = 'L' or 'l' The lower triangular part of A is */
48 /* being supplied. */
49
50 /* Unchanged on exit. */
51
52 /* N - INTEGER. */
53 /* On entry, N specifies the order of the matrix A. */
54 /* N must be at least zero. */
55 /* Unchanged on exit. */
56
57 /* K - INTEGER. */
58 /* On entry, K specifies the number of super-diagonals of the */
59 /* matrix A. K must satisfy 0 .le. K. */
60 /* Unchanged on exit. */
61
62 /* ALPHA - REAL . */
63 /* On entry, ALPHA specifies the scalar alpha. */
64 /* Unchanged on exit. */
65
66 /* A - REAL array of DIMENSION ( LDA, n ). */
67 /* Before entry with UPLO = 'U' or 'u', the leading ( k + 1 ) */
68 /* by n part of the array A must contain the upper triangular */
69 /* band part of the symmetric matrix, supplied column by */
70 /* column, with the leading diagonal of the matrix in row */
71 /* ( k + 1 ) of the array, the first super-diagonal starting at */
72 /* position 2 in row k, and so on. The top left k by k triangle */
73 /* of the array A is not referenced. */
74 /* The following program segment will transfer the upper */
75 /* triangular part of a symmetric band matrix from conventional */
76 /* full matrix storage to band storage: */
77
78 /* DO 20, J = 1, N */
79 /* M = K + 1 - J */
80 /* DO 10, I = MAX( 1, J - K ), J */
81 /* A( M + I, J ) = matrix( I, J ) */
82 /* 10 CONTINUE */
83 /* 20 CONTINUE */
84
85 /* Before entry with UPLO = 'L' or 'l', the leading ( k + 1 ) */
86 /* by n part of the array A must contain the lower triangular */
87 /* band part of the symmetric matrix, supplied column by */
88 /* column, with the leading diagonal of the matrix in row 1 of */
89 /* the array, the first sub-diagonal starting at position 1 in */
90 /* row 2, and so on. The bottom right k by k triangle of the */
91 /* array A is not referenced. */
92 /* The following program segment will transfer the lower */
93 /* triangular part of a symmetric band matrix from conventional */
94 /* full matrix storage to band storage: */
95
96 /* DO 20, J = 1, N */
97 /* M = 1 - J */
98 /* DO 10, I = J, MIN( N, J + K ) */
99 /* A( M + I, J ) = matrix( I, J ) */
100 /* 10 CONTINUE */
101 /* 20 CONTINUE */
102
103 /* Unchanged on exit. */
104
105 /* LDA - INTEGER. */
106 /* On entry, LDA specifies the first dimension of A as declared */
107 /* in the calling (sub) program. LDA must be at least */
108 /* ( k + 1 ). */
109 /* Unchanged on exit. */
110
111 /* X - REAL array of DIMENSION at least */
112 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
113 /* Before entry, the incremented array X must contain the */
114 /* vector x. */
115 /* Unchanged on exit. */
116
117 /* INCX - INTEGER. */
118 /* On entry, INCX specifies the increment for the elements of */
119 /* X. INCX must not be zero. */
120 /* Unchanged on exit. */
121
122 /* BETA - REAL . */
123 /* On entry, BETA specifies the scalar beta. */
124 /* Unchanged on exit. */
125
126 /* Y - REAL array of DIMENSION at least */
127 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
128 /* Before entry, the incremented array Y must contain the */
129 /* vector y. On exit, Y is overwritten by the updated vector y. */
130
131 /* INCY - INTEGER. */
132 /* On entry, INCY specifies the increment for the elements of */
133 /* Y. INCY must not be zero. */
134 /* Unchanged on exit. */
135
136
137 /* Level 2 Blas routine. */
138
139 /* -- Written on 22-October-1986. */
140 /* Jack Dongarra, Argonne National Lab. */
141 /* Jeremy Du Croz, Nag Central Office. */
142 /* Sven Hammarling, Nag Central Office. */
143 /* Richard Hanson, Sandia National Labs. */
144
145
146 /* .. Parameters .. */
147 /* .. Local Scalars .. */
148 /* .. External Functions .. */
149 /* .. External Subroutines .. */
150 /* .. Intrinsic Functions .. */
151 /* .. */
152 /* .. Executable Statements .. */
153
154 /* Test the input parameters. */
155
156 /* Parameter adjustments */
157 a_dim1 = *lda;
158 a_offset = 1 + a_dim1;
159 a -= a_offset;
160 --x;
161 --y;
162
163 /* Function Body */
164 info = 0;
165 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
166 ftnlen)1, (ftnlen)1)) {
167 info = 1;
168 } else if (*n < 0) {
169 info = 2;
170 } else if (*k < 0) {
171 info = 3;
172 } else if (*lda < *k + 1) {
173 info = 6;
174 } else if (*incx == 0) {
175 info = 8;
176 } else if (*incy == 0) {
177 info = 11;
178 }
179 if (info != 0) {
180 xerbla_("SSBMV ", &info, (ftnlen)6);
181 return 0;
182 }
183
184 /* Quick return if possible. */
185
186 if (*n == 0 || *alpha == 0.f && *beta == 1.f) {
187 return 0;
188 }
189
190 /* Set up the start points in X and Y. */
191
192 if (*incx > 0) {
193 kx = 1;
194 } else {
195 kx = 1 - (*n - 1) * *incx;
196 }
197 if (*incy > 0) {
198 ky = 1;
199 } else {
200 ky = 1 - (*n - 1) * *incy;
201 }
202
203 /* Start the operations. In this version the elements of the array A */
204 /* are accessed sequentially with one pass through A. */
205
206 /* First form y := beta*y. */
207
208 if (*beta != 1.f) {
209 if (*incy == 1) {
210 if (*beta == 0.f) {
211 i__1 = *n;
212 for (i__ = 1; i__ <= i__1; ++i__) {
213 y[i__] = 0.f;
214 /* L10: */
215 }
216 } else {
217 i__1 = *n;
218 for (i__ = 1; i__ <= i__1; ++i__) {
219 y[i__] = *beta * y[i__];
220 /* L20: */
221 }
222 }
223 } else {
224 iy = ky;
225 if (*beta == 0.f) {
226 i__1 = *n;
227 for (i__ = 1; i__ <= i__1; ++i__) {
228 y[iy] = 0.f;
229 iy += *incy;
230 /* L30: */
231 }
232 } else {
233 i__1 = *n;
234 for (i__ = 1; i__ <= i__1; ++i__) {
235 y[iy] = *beta * y[iy];
236 iy += *incy;
237 /* L40: */
238 }
239 }
240 }
241 }
242 if (*alpha == 0.f) {
243 return 0;
244 }
245 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
246
247 /* Form y when upper triangle of A is stored. */
248
249 kplus1 = *k + 1;
250 if (*incx == 1 && *incy == 1) {
251 i__1 = *n;
252 for (j = 1; j <= i__1; ++j) {
253 temp1 = *alpha * x[j];
254 temp2 = 0.f;
255 l = kplus1 - j;
256 /* Computing MAX */
257 i__2 = 1, i__3 = j - *k;
258 i__4 = j - 1;
259 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
260 y[i__] += temp1 * a[l + i__ + j * a_dim1];
261 temp2 += a[l + i__ + j * a_dim1] * x[i__];
262 /* L50: */
263 }
264 y[j] = y[j] + temp1 * a[kplus1 + j * a_dim1] + *alpha * temp2;
265 /* L60: */
266 }
267 } else {
268 jx = kx;
269 jy = ky;
270 i__1 = *n;
271 for (j = 1; j <= i__1; ++j) {
272 temp1 = *alpha * x[jx];
273 temp2 = 0.f;
274 ix = kx;
275 iy = ky;
276 l = kplus1 - j;
277 /* Computing MAX */
278 i__4 = 1, i__2 = j - *k;
279 i__3 = j - 1;
280 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
281 y[iy] += temp1 * a[l + i__ + j * a_dim1];
282 temp2 += a[l + i__ + j * a_dim1] * x[ix];
283 ix += *incx;
284 iy += *incy;
285 /* L70: */
286 }
287 y[jy] = y[jy] + temp1 * a[kplus1 + j * a_dim1] + *alpha *
288 temp2;
289 jx += *incx;
290 jy += *incy;
291 if (j > *k) {
292 kx += *incx;
293 ky += *incy;
294 }
295 /* L80: */
296 }
297 }
298 } else {
299
300 /* Form y when lower triangle of A is stored. */
301
302 if (*incx == 1 && *incy == 1) {
303 i__1 = *n;
304 for (j = 1; j <= i__1; ++j) {
305 temp1 = *alpha * x[j];
306 temp2 = 0.f;
307 y[j] += temp1 * a[j * a_dim1 + 1];
308 l = 1 - j;
309 /* Computing MIN */
310 i__4 = *n, i__2 = j + *k;
311 i__3 = min(i__4,i__2);
312 for (i__ = j + 1; i__ <= i__3; ++i__) {
313 y[i__] += temp1 * a[l + i__ + j * a_dim1];
314 temp2 += a[l + i__ + j * a_dim1] * x[i__];
315 /* L90: */
316 }
317 y[j] += *alpha * temp2;
318 /* L100: */
319 }
320 } else {
321 jx = kx;
322 jy = ky;
323 i__1 = *n;
324 for (j = 1; j <= i__1; ++j) {
325 temp1 = *alpha * x[jx];
326 temp2 = 0.f;
327 y[jy] += temp1 * a[j * a_dim1 + 1];
328 l = 1 - j;
329 ix = jx;
330 iy = jy;
331 /* Computing MIN */
332 i__4 = *n, i__2 = j + *k;
333 i__3 = min(i__4,i__2);
334 for (i__ = j + 1; i__ <= i__3; ++i__) {
335 ix += *incx;
336 iy += *incy;
337 y[iy] += temp1 * a[l + i__ + j * a_dim1];
338 temp2 += a[l + i__ + j * a_dim1] * x[ix];
339 /* L110: */
340 }
341 y[jy] += *alpha * temp2;
342 jx += *incx;
343 jy += *incy;
344 /* L120: */
345 }
346 }
347 }
348
349 return 0;
350
351 /* End of SSBMV . */
352
353 } /* ssbmv_ */
354