Debian Codegraph @

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

raw
1 /* ./src_f77/sgemv.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 sgemv_(char *trans, integer *m, integer *n, real *alpha,
9 real *a, integer *lda, real *x, integer *incx, real *beta, real *y,
10 integer *incy, ftnlen trans_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 temp;
18 static integer lenx, leny;
19 extern logical lsame_(char *, char *, ftnlen, ftnlen);
20 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
21
22 /* .. Scalar Arguments .. */
23 /* .. Array Arguments .. */
24 /* .. */
25
26 /* Purpose */
27 /* ======= */
28
29 /* SGEMV performs one of the matrix-vector operations */
30
31 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */
32
33 /* where alpha and beta are scalars, x and y are vectors and A is an */
34 /* m by n matrix. */
35
36 /* Parameters */
37 /* ========== */
38
39 /* TRANS - CHARACTER*1. */
40 /* On entry, TRANS specifies the operation to be performed as */
41 /* follows: */
42
43 /* TRANS = 'N' or 'n' y := alpha*A*x + beta*y. */
44
45 /* TRANS = 'T' or 't' y := alpha*A'*x + beta*y. */
46
47 /* TRANS = 'C' or 'c' y := alpha*A'*x + beta*y. */
48
49 /* Unchanged on exit. */
50
51 /* M - INTEGER. */
52 /* On entry, M specifies the number of rows of the matrix A. */
53 /* M must be at least zero. */
54 /* Unchanged on exit. */
55
56 /* N - INTEGER. */
57 /* On entry, N specifies the number of columns of the matrix A. */
58 /* N must be at least zero. */
59 /* Unchanged on exit. */
60
61 /* ALPHA - REAL . */
62 /* On entry, ALPHA specifies the scalar alpha. */
63 /* Unchanged on exit. */
64
65 /* A - REAL array of DIMENSION ( LDA, n ). */
66 /* Before entry, the leading m by n part of the array A must */
67 /* contain the matrix of coefficients. */
68 /* Unchanged on exit. */
69
70 /* LDA - INTEGER. */
71 /* On entry, LDA specifies the first dimension of A as declared */
72 /* in the calling (sub) program. LDA must be at least */
73 /* max( 1, m ). */
74 /* Unchanged on exit. */
75
76 /* X - REAL array of DIMENSION at least */
77 /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
78 /* and at least */
79 /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
80 /* Before entry, the incremented array X must contain the */
81 /* vector x. */
82 /* Unchanged on exit. */
83
84 /* INCX - INTEGER. */
85 /* On entry, INCX specifies the increment for the elements of */
86 /* X. INCX must not be zero. */
87 /* Unchanged on exit. */
88
89 /* BETA - REAL . */
90 /* On entry, BETA specifies the scalar beta. When BETA is */
91 /* supplied as zero then Y need not be set on input. */
92 /* Unchanged on exit. */
93
94 /* Y - REAL array of DIMENSION at least */
95 /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
96 /* and at least */
97 /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
98 /* Before entry with BETA non-zero, the incremented array Y */
99 /* must contain the vector y. On exit, Y is overwritten by the */
100 /* updated vector y. */
101
102 /* INCY - INTEGER. */
103 /* On entry, INCY specifies the increment for the elements of */
104 /* Y. INCY must not be zero. */
105 /* Unchanged on exit. */
106
107
108 /* Level 2 Blas routine. */
109
110 /* -- Written on 22-October-1986. */
111 /* Jack Dongarra, Argonne National Lab. */
112 /* Jeremy Du Croz, Nag Central Office. */
113 /* Sven Hammarling, Nag Central Office. */
114 /* Richard Hanson, Sandia National Labs. */
115
116
117 /* .. Parameters .. */
118 /* .. Local Scalars .. */
119 /* .. External Functions .. */
120 /* .. External Subroutines .. */
121 /* .. Intrinsic Functions .. */
122 /* .. */
123 /* .. Executable Statements .. */
124
125 /* Test the input parameters. */
126
127 /* Parameter adjustments */
128 a_dim1 = *lda;
129 a_offset = 1 + a_dim1;
130 a -= a_offset;
131 --x;
132 --y;
133
134 /* Function Body */
135 info = 0;
136 if (! lsame_(trans, "N", (ftnlen)1, (ftnlen)1) && ! lsame_(trans, "T", (
137 ftnlen)1, (ftnlen)1) && ! lsame_(trans, "C", (ftnlen)1, (ftnlen)1)
138 ) {
139 info = 1;
140 } else if (*m < 0) {
141 info = 2;
142 } else if (*n < 0) {
143 info = 3;
144 } else if (*lda < max(1,*m)) {
145 info = 6;
146 } else if (*incx == 0) {
147 info = 8;
148 } else if (*incy == 0) {
149 info = 11;
150 }
151 if (info != 0) {
152 xerbla_("SGEMV ", &info, (ftnlen)6);
153 return 0;
154 }
155
156 /* Quick return if possible. */
157
158 if (*m == 0 || *n == 0 || *alpha == 0.f && *beta == 1.f) {
159 return 0;
160 }
161
162 /* Set LENX and LENY, the lengths of the vectors x and y, and set */
163 /* up the start points in X and Y. */
164
165 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
166 lenx = *n;
167 leny = *m;
168 } else {
169 lenx = *m;
170 leny = *n;
171 }
172 if (*incx > 0) {
173 kx = 1;
174 } else {
175 kx = 1 - (lenx - 1) * *incx;
176 }
177 if (*incy > 0) {
178 ky = 1;
179 } else {
180 ky = 1 - (leny - 1) * *incy;
181 }
182
183 /* Start the operations. In this version the elements of A are */
184 /* accessed sequentially with one pass through A. */
185
186 /* First form y := beta*y. */
187
188 if (*beta != 1.f) {
189 if (*incy == 1) {
190 if (*beta == 0.f) {
191 i__1 = leny;
192 for (i__ = 1; i__ <= i__1; ++i__) {
193 y[i__] = 0.f;
194 /* L10: */
195 }
196 } else {
197 i__1 = leny;
198 for (i__ = 1; i__ <= i__1; ++i__) {
199 y[i__] = *beta * y[i__];
200 /* L20: */
201 }
202 }
203 } else {
204 iy = ky;
205 if (*beta == 0.f) {
206 i__1 = leny;
207 for (i__ = 1; i__ <= i__1; ++i__) {
208 y[iy] = 0.f;
209 iy += *incy;
210 /* L30: */
211 }
212 } else {
213 i__1 = leny;
214 for (i__ = 1; i__ <= i__1; ++i__) {
215 y[iy] = *beta * y[iy];
216 iy += *incy;
217 /* L40: */
218 }
219 }
220 }
221 }
222 if (*alpha == 0.f) {
223 return 0;
224 }
225 if (lsame_(trans, "N", (ftnlen)1, (ftnlen)1)) {
226
227 /* Form y := alpha*A*x + y. */
228
229 jx = kx;
230 if (*incy == 1) {
231 i__1 = *n;
232 for (j = 1; j <= i__1; ++j) {
233 if (x[jx] != 0.f) {
234 temp = *alpha * x[jx];
235 i__2 = *m;
236 for (i__ = 1; i__ <= i__2; ++i__) {
237 y[i__] += temp * a[i__ + j * a_dim1];
238 /* L50: */
239 }
240 }
241 jx += *incx;
242 /* L60: */
243 }
244 } else {
245 i__1 = *n;
246 for (j = 1; j <= i__1; ++j) {
247 if (x[jx] != 0.f) {
248 temp = *alpha * x[jx];
249 iy = ky;
250 i__2 = *m;
251 for (i__ = 1; i__ <= i__2; ++i__) {
252 y[iy] += temp * a[i__ + j * a_dim1];
253 iy += *incy;
254 /* L70: */
255 }
256 }
257 jx += *incx;
258 /* L80: */
259 }
260 }
261 } else {
262
263 /* Form y := alpha*A'*x + y. */
264
265 jy = ky;
266 if (*incx == 1) {
267 i__1 = *n;
268 for (j = 1; j <= i__1; ++j) {
269 temp = 0.f;
270 i__2 = *m;
271 for (i__ = 1; i__ <= i__2; ++i__) {
272 temp += a[i__ + j * a_dim1] * x[i__];
273 /* L90: */
274 }
275 y[jy] += *alpha * temp;
276 jy += *incy;
277 /* L100: */
278 }
279 } else {
280 i__1 = *n;
281 for (j = 1; j <= i__1; ++j) {
282 temp = 0.f;
283 ix = kx;
284 i__2 = *m;
285 for (i__ = 1; i__ <= i__2; ++i__) {
286 temp += a[i__ + j * a_dim1] * x[ix];
287 ix += *incx;
288 /* L110: */
289 }
290 y[jy] += *alpha * temp;
291 jy += *incy;
292 /* L120: */
293 }
294 }
295 }
296
297 return 0;
298
299 /* End of SGEMV . */
300
301 } /* sgemv_ */
302