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