00001 /* dgbmv.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Subroutine */ int dgbmv_(char *trans, integer *m, integer *n, integer *kl, 00017 integer *ku, doublereal *alpha, doublereal *a, integer *lda, 00018 doublereal *x, integer *incx, doublereal *beta, doublereal *y, 00019 integer *incy) 00020 { 00021 /* System generated locals */ 00022 integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6; 00023 00024 /* Local variables */ 00025 integer i__, j, k, ix, iy, jx, jy, kx, ky, kup1, info; 00026 doublereal temp; 00027 integer lenx, leny; 00028 extern logical lsame_(char *, char *); 00029 extern /* Subroutine */ int xerbla_(char *, integer *); 00030 00031 /* .. Scalar Arguments .. */ 00032 /* .. */ 00033 /* .. Array Arguments .. */ 00034 /* .. */ 00035 00036 /* Purpose */ 00037 /* ======= */ 00038 00039 /* DGBMV performs one of the matrix-vector operations */ 00040 00041 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */ 00042 00043 /* where alpha and beta are scalars, x and y are vectors and A is an */ 00044 /* m by n band matrix, with kl sub-diagonals and ku super-diagonals. */ 00045 00046 /* Arguments */ 00047 /* ========== */ 00048 00049 /* TRANS - CHARACTER*1. */ 00050 /* On entry, TRANS specifies the operation to be performed as */ 00051 /* follows: */ 00052 00053 /* TRANS = 'N' or 'n' y := alpha*A*x + beta*y. */ 00054 00055 /* TRANS = 'T' or 't' y := alpha*A'*x + beta*y. */ 00056 00057 /* TRANS = 'C' or 'c' y := alpha*A'*x + beta*y. */ 00058 00059 /* Unchanged on exit. */ 00060 00061 /* M - INTEGER. */ 00062 /* On entry, M specifies the number of rows of the matrix A. */ 00063 /* M must be at least zero. */ 00064 /* Unchanged on exit. */ 00065 00066 /* N - INTEGER. */ 00067 /* On entry, N specifies the number of columns of the matrix A. */ 00068 /* N must be at least zero. */ 00069 /* Unchanged on exit. */ 00070 00071 /* KL - INTEGER. */ 00072 /* On entry, KL specifies the number of sub-diagonals of the */ 00073 /* matrix A. KL must satisfy 0 .le. KL. */ 00074 /* Unchanged on exit. */ 00075 00076 /* KU - INTEGER. */ 00077 /* On entry, KU specifies the number of super-diagonals of the */ 00078 /* matrix A. KU must satisfy 0 .le. KU. */ 00079 /* Unchanged on exit. */ 00080 00081 /* ALPHA - DOUBLE PRECISION. */ 00082 /* On entry, ALPHA specifies the scalar alpha. */ 00083 /* Unchanged on exit. */ 00084 00085 /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */ 00086 /* Before entry, the leading ( kl + ku + 1 ) by n part of the */ 00087 /* array A must contain the matrix of coefficients, supplied */ 00088 /* column by column, with the leading diagonal of the matrix in */ 00089 /* row ( ku + 1 ) of the array, the first super-diagonal */ 00090 /* starting at position 2 in row ku, the first sub-diagonal */ 00091 /* starting at position 1 in row ( ku + 2 ), and so on. */ 00092 /* Elements in the array A that do not correspond to elements */ 00093 /* in the band matrix (such as the top left ku by ku triangle) */ 00094 /* are not referenced. */ 00095 /* The following program segment will transfer a band matrix */ 00096 /* from conventional full matrix storage to band storage: */ 00097 00098 /* DO 20, J = 1, N */ 00099 /* K = KU + 1 - J */ 00100 /* DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL ) */ 00101 /* A( K + I, J ) = matrix( I, J ) */ 00102 /* 10 CONTINUE */ 00103 /* 20 CONTINUE */ 00104 00105 /* Unchanged on exit. */ 00106 00107 /* LDA - INTEGER. */ 00108 /* On entry, LDA specifies the first dimension of A as declared */ 00109 /* in the calling (sub) program. LDA must be at least */ 00110 /* ( kl + ku + 1 ). */ 00111 /* Unchanged on exit. */ 00112 00113 /* X - DOUBLE PRECISION array of DIMENSION at least */ 00114 /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */ 00115 /* and at least */ 00116 /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */ 00117 /* Before entry, the incremented array X must contain the */ 00118 /* vector x. */ 00119 /* Unchanged on exit. */ 00120 00121 /* INCX - INTEGER. */ 00122 /* On entry, INCX specifies the increment for the elements of */ 00123 /* X. INCX must not be zero. */ 00124 /* Unchanged on exit. */ 00125 00126 /* BETA - DOUBLE PRECISION. */ 00127 /* On entry, BETA specifies the scalar beta. When BETA is */ 00128 /* supplied as zero then Y need not be set on input. */ 00129 /* Unchanged on exit. */ 00130 00131 /* Y - DOUBLE PRECISION array of DIMENSION at least */ 00132 /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */ 00133 /* and at least */ 00134 /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */ 00135 /* Before entry, the incremented array Y must contain the */ 00136 /* vector y. On exit, Y is overwritten by the updated vector y. */ 00137 00138 /* INCY - INTEGER. */ 00139 /* On entry, INCY specifies the increment for the elements of */ 00140 /* Y. INCY must not be zero. */ 00141 /* Unchanged on exit. */ 00142 00143 00144 /* Level 2 Blas routine. */ 00145 00146 /* -- Written on 22-October-1986. */ 00147 /* Jack Dongarra, Argonne National Lab. */ 00148 /* Jeremy Du Croz, Nag Central Office. */ 00149 /* Sven Hammarling, Nag Central Office. */ 00150 /* Richard Hanson, Sandia National Labs. */ 00151 00152 /* .. Parameters .. */ 00153 /* .. */ 00154 /* .. Local Scalars .. */ 00155 /* .. */ 00156 /* .. External Functions .. */ 00157 /* .. */ 00158 /* .. External Subroutines .. */ 00159 /* .. */ 00160 /* .. Intrinsic Functions .. */ 00161 /* .. */ 00162 00163 /* Test the input parameters. */ 00164 00165 /* Parameter adjustments */ 00166 a_dim1 = *lda; 00167 a_offset = 1 + a_dim1; 00168 a -= a_offset; 00169 --x; 00170 --y; 00171 00172 /* Function Body */ 00173 info = 0; 00174 if (! lsame_(trans, "N") && ! lsame_(trans, "T") && ! lsame_(trans, "C") 00175 ) { 00176 info = 1; 00177 } else if (*m < 0) { 00178 info = 2; 00179 } else if (*n < 0) { 00180 info = 3; 00181 } else if (*kl < 0) { 00182 info = 4; 00183 } else if (*ku < 0) { 00184 info = 5; 00185 } else if (*lda < *kl + *ku + 1) { 00186 info = 8; 00187 } else if (*incx == 0) { 00188 info = 10; 00189 } else if (*incy == 0) { 00190 info = 13; 00191 } 00192 if (info != 0) { 00193 xerbla_("DGBMV ", &info); 00194 return 0; 00195 } 00196 00197 /* Quick return if possible. */ 00198 00199 if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) { 00200 return 0; 00201 } 00202 00203 /* Set LENX and LENY, the lengths of the vectors x and y, and set */ 00204 /* up the start points in X and Y. */ 00205 00206 if (lsame_(trans, "N")) { 00207 lenx = *n; 00208 leny = *m; 00209 } else { 00210 lenx = *m; 00211 leny = *n; 00212 } 00213 if (*incx > 0) { 00214 kx = 1; 00215 } else { 00216 kx = 1 - (lenx - 1) * *incx; 00217 } 00218 if (*incy > 0) { 00219 ky = 1; 00220 } else { 00221 ky = 1 - (leny - 1) * *incy; 00222 } 00223 00224 /* Start the operations. In this version the elements of A are */ 00225 /* accessed sequentially with one pass through the band part of A. */ 00226 00227 /* First form y := beta*y. */ 00228 00229 if (*beta != 1.) { 00230 if (*incy == 1) { 00231 if (*beta == 0.) { 00232 i__1 = leny; 00233 for (i__ = 1; i__ <= i__1; ++i__) { 00234 y[i__] = 0.; 00235 /* L10: */ 00236 } 00237 } else { 00238 i__1 = leny; 00239 for (i__ = 1; i__ <= i__1; ++i__) { 00240 y[i__] = *beta * y[i__]; 00241 /* L20: */ 00242 } 00243 } 00244 } else { 00245 iy = ky; 00246 if (*beta == 0.) { 00247 i__1 = leny; 00248 for (i__ = 1; i__ <= i__1; ++i__) { 00249 y[iy] = 0.; 00250 iy += *incy; 00251 /* L30: */ 00252 } 00253 } else { 00254 i__1 = leny; 00255 for (i__ = 1; i__ <= i__1; ++i__) { 00256 y[iy] = *beta * y[iy]; 00257 iy += *incy; 00258 /* L40: */ 00259 } 00260 } 00261 } 00262 } 00263 if (*alpha == 0.) { 00264 return 0; 00265 } 00266 kup1 = *ku + 1; 00267 if (lsame_(trans, "N")) { 00268 00269 /* Form y := alpha*A*x + y. */ 00270 00271 jx = kx; 00272 if (*incy == 1) { 00273 i__1 = *n; 00274 for (j = 1; j <= i__1; ++j) { 00275 if (x[jx] != 0.) { 00276 temp = *alpha * x[jx]; 00277 k = kup1 - j; 00278 /* Computing MAX */ 00279 i__2 = 1, i__3 = j - *ku; 00280 /* Computing MIN */ 00281 i__5 = *m, i__6 = j + *kl; 00282 i__4 = min(i__5,i__6); 00283 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) { 00284 y[i__] += temp * a[k + i__ + j * a_dim1]; 00285 /* L50: */ 00286 } 00287 } 00288 jx += *incx; 00289 /* L60: */ 00290 } 00291 } else { 00292 i__1 = *n; 00293 for (j = 1; j <= i__1; ++j) { 00294 if (x[jx] != 0.) { 00295 temp = *alpha * x[jx]; 00296 iy = ky; 00297 k = kup1 - j; 00298 /* Computing MAX */ 00299 i__4 = 1, i__2 = j - *ku; 00300 /* Computing MIN */ 00301 i__5 = *m, i__6 = j + *kl; 00302 i__3 = min(i__5,i__6); 00303 for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) { 00304 y[iy] += temp * a[k + i__ + j * a_dim1]; 00305 iy += *incy; 00306 /* L70: */ 00307 } 00308 } 00309 jx += *incx; 00310 if (j > *ku) { 00311 ky += *incy; 00312 } 00313 /* L80: */ 00314 } 00315 } 00316 } else { 00317 00318 /* Form y := alpha*A'*x + y. */ 00319 00320 jy = ky; 00321 if (*incx == 1) { 00322 i__1 = *n; 00323 for (j = 1; j <= i__1; ++j) { 00324 temp = 0.; 00325 k = kup1 - j; 00326 /* Computing MAX */ 00327 i__3 = 1, i__4 = j - *ku; 00328 /* Computing MIN */ 00329 i__5 = *m, i__6 = j + *kl; 00330 i__2 = min(i__5,i__6); 00331 for (i__ = max(i__3,i__4); i__ <= i__2; ++i__) { 00332 temp += a[k + i__ + j * a_dim1] * x[i__]; 00333 /* L90: */ 00334 } 00335 y[jy] += *alpha * temp; 00336 jy += *incy; 00337 /* L100: */ 00338 } 00339 } else { 00340 i__1 = *n; 00341 for (j = 1; j <= i__1; ++j) { 00342 temp = 0.; 00343 ix = kx; 00344 k = kup1 - j; 00345 /* Computing MAX */ 00346 i__2 = 1, i__3 = j - *ku; 00347 /* Computing MIN */ 00348 i__5 = *m, i__6 = j + *kl; 00349 i__4 = min(i__5,i__6); 00350 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) { 00351 temp += a[k + i__ + j * a_dim1] * x[ix]; 00352 ix += *incx; 00353 /* L110: */ 00354 } 00355 y[jy] += *alpha * temp; 00356 jy += *incy; 00357 if (j > *ku) { 00358 kx += *incx; 00359 } 00360 /* L120: */ 00361 } 00362 } 00363 } 00364 00365 return 0; 00366 00367 /* End of DGBMV . */ 00368 00369 } /* dgbmv_ */