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