Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dgemv.c

Go to the documentation of this file.
00001 /* DGEMV.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 #include "cblasimpexp.h"
00008 
00009 
00010 /* *********************************************************************** */
00011 
00012 /*     File of the DOUBLE PRECISION  Level-2 BLAS. */
00013 /*     =========================================== */
00014 
00015 /*     SUBROUTINE DGEMV ( TRANS, M, N, ALPHA, A, LDA, X, INCX, */
00016 /*    $                   BETA, Y, INCY ) */
00017 
00018 /*     SUBROUTINE DGBMV ( TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX, */
00019 /*    $                   BETA, Y, INCY ) */
00020 
00021 /*     SUBROUTINE DSYMV ( UPLO, N, ALPHA, A, LDA, X, INCX, */
00022 /*    $                   BETA, Y, INCY ) */
00023 
00024 /*     SUBROUTINE DSBMV ( UPLO, N, K, ALPHA, A, LDA, X, INCX, */
00025 /*    $                   BETA, Y, INCY ) */
00026 
00027 /*     SUBROUTINE DSPMV ( UPLO, N, ALPHA, AP, X, INCX, BETA, Y, INCY ) */
00028 
00029 /*     SUBROUTINE DTRMV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX ) */
00030 
00031 /*     SUBROUTINE DTBMV ( UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX ) */
00032 
00033 /*     SUBROUTINE DTPMV ( UPLO, TRANS, DIAG, N, AP, X, INCX ) */
00034 
00035 /*     SUBROUTINE DTRSV ( UPLO, TRANS, DIAG, N, A, LDA, X, INCX ) */
00036 
00037 /*     SUBROUTINE DTBSV ( UPLO, TRANS, DIAG, N, K, A, LDA, X, INCX ) */
00038 
00039 /*     SUBROUTINE DTPSV ( UPLO, TRANS, DIAG, N, AP, X, INCX ) */
00040 
00041 /*     SUBROUTINE DGER  ( M, N, ALPHA, X, INCX, Y, INCY, A, LDA ) */
00042 
00043 /*     SUBROUTINE DSYR  ( UPLO, N, ALPHA, X, INCX, A, LDA ) */
00044 
00045 /*     SUBROUTINE DSPR  ( UPLO, N, ALPHA, X, INCX, AP ) */
00046 
00047 /*     SUBROUTINE DSYR2 ( UPLO, N, ALPHA, X, INCX, Y, INCY, A, LDA ) */
00048 
00049 /*     SUBROUTINE DSPR2 ( UPLO, N, ALPHA, X, INCX, Y, INCY, AP ) */
00050 
00051 /*     See: */
00052 
00053 /*        Dongarra J. J., Du Croz J. J., Hammarling S.  and Hanson R. J.. */
00054 /*        An  extended  set of Fortran  Basic Linear Algebra Subprograms. */
00055 
00056 /*        Technical  Memoranda  Nos. 41 (revision 3) and 81,  Mathematics */
00057 /*        and  Computer Science  Division,  Argonne  National Laboratory, */
00058 /*        9700 South Cass Avenue, Argonne, Illinois 60439, US. */
00059 
00060 /*        Or */
00061 
00062 /*        NAG  Technical Reports TR3/87 and TR4/87,  Numerical Algorithms */
00063 /*        Group  Ltd.,  NAG  Central  Office,  256  Banbury  Road, Oxford */
00064 /*        OX2 7DE, UK,  and  Numerical Algorithms Group Inc.,  1101  31st */
00065 /*        Street,  Suite 100,  Downers Grove,  Illinois 60515-1263,  USA. */
00066 
00067 /* *********************************************************************** */
00068 
00069 /* Subroutine */ int __IMPEXP__ dgemv_(trans, m, n, alpha, a, lda, x, incx, beta, y, 
00070         incy, trans_len)
00071 char *trans;
00072 integer *m, *n;
00073 doublereal *alpha, *a;
00074 integer *lda;
00075 doublereal *x;
00076 integer *incx;
00077 doublereal *beta, *y;
00078 integer *incy;
00079 ftnlen trans_len;
00080 {
00081     /* System generated locals */
00082     integer a_dim1, a_offset, i__1, i__2;
00083 
00084     /* Local variables */
00085     static integer info;
00086     static doublereal temp;
00087     static integer lenx, leny, i, j;
00088     extern logical lsame_();
00089     static integer ix, iy, jx, jy, kx, ky;
00090     extern /* Subroutine */ int xerbla_();
00091 
00092 /*     .. Scalar Arguments .. */
00093 /*     .. Array Arguments .. */
00094 /*     .. */
00095 
00096 /*  Purpose */
00097 /*  ======= */
00098 
00099 /*  DGEMV  performs one of the matrix-vector operations */
00100 
00101 /*     y := alpha*A*x + beta*y,   or   y := alpha*A'*x + beta*y, */
00102 
00103 /*  where alpha and beta are scalars, x and y are vectors and A is an */
00104 /*  m by n matrix. */
00105 
00106 /*  Parameters */
00107 /*  ========== */
00108 
00109 /*  TRANS  - CHARACTER*1. */
00110 /*           On entry, TRANS specifies the operation to be performed as */
00111 /*           follows: */
00112 
00113 /*              TRANS = 'N' or 'n'   y := alpha*A*x + beta*y. */
00114 
00115 /*              TRANS = 'T' or 't'   y := alpha*A'*x + beta*y. */
00116 
00117 /*              TRANS = 'C' or 'c'   y := alpha*A'*x + beta*y. */
00118 
00119 /*           Unchanged on exit. */
00120 
00121 /*  M      - INTEGER. */
00122 /*           On entry, M specifies the number of rows of the matrix A. */
00123 /*           M must be at least zero. */
00124 /*           Unchanged on exit. */
00125 
00126 /*  N      - INTEGER. */
00127 /*           On entry, N specifies the number of columns of the matrix A. 
00128 */
00129 /*           N must be at least zero. */
00130 /*           Unchanged on exit. */
00131 
00132 /*  ALPHA  - DOUBLE PRECISION. */
00133 /*           On entry, ALPHA specifies the scalar alpha. */
00134 /*           Unchanged on exit. */
00135 
00136 /*  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
00137 /*           Before entry, the leading m by n part of the array A must */
00138 /*           contain the matrix of coefficients. */
00139 /*           Unchanged on exit. */
00140 
00141 /*  LDA    - INTEGER. */
00142 /*           On entry, LDA specifies the first dimension of A as declared 
00143 */
00144 /*           in the calling (sub) program. LDA must be at least */
00145 /*           max( 1, m ). */
00146 /*           Unchanged on exit. */
00147 
00148 /*  X      - DOUBLE PRECISION array of DIMENSION at least */
00149 /*           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
00150 /*           and at least */
00151 /*           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
00152 /*           Before entry, the incremented array X must contain the */
00153 /*           vector x. */
00154 /*           Unchanged on exit. */
00155 
00156 /*  INCX   - INTEGER. */
00157 /*           On entry, INCX specifies the increment for the elements of */
00158 /*           X. INCX must not be zero. */
00159 /*           Unchanged on exit. */
00160 
00161 /*  BETA   - DOUBLE PRECISION. */
00162 /*           On entry, BETA specifies the scalar beta. When BETA is */
00163 /*           supplied as zero then Y need not be set on input. */
00164 /*           Unchanged on exit. */
00165 
00166 /*  Y      - DOUBLE PRECISION array of DIMENSION at least */
00167 /*           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
00168 /*           and at least */
00169 /*           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
00170 /*           Before entry with BETA non-zero, the incremented array Y */
00171 /*           must contain the vector y. On exit, Y is overwritten by the 
00172 */
00173 /*           updated vector y. */
00174 
00175 /*  INCY   - INTEGER. */
00176 /*           On entry, INCY specifies the increment for the elements of */
00177 /*           Y. INCY must not be zero. */
00178 /*           Unchanged on exit. */
00179 
00180 
00181 /*  Level 2 Blas routine. */
00182 
00183 /*  -- Written on 22-October-1986. */
00184 /*     Jack Dongarra, Argonne National Lab. */
00185 /*     Jeremy Du Croz, Nag Central Office. */
00186 /*     Sven Hammarling, Nag Central Office. */
00187 /*     Richard Hanson, Sandia National Labs. */
00188 
00189 
00190 /*     .. Parameters .. */
00191 /*     .. Local Scalars .. */
00192 /*     .. External Functions .. */
00193 /*     .. External Subroutines .. */
00194 /*     .. Intrinsic Functions .. */
00195 /*     .. */
00196 /*     .. Executable Statements .. */
00197 
00198 /*     Test the input parameters. */
00199 
00200     /* Parameter adjustments */
00201     a_dim1 = *lda;
00202     a_offset = a_dim1 + 1;
00203     a -= a_offset;
00204     --x;
00205     --y;
00206 
00207     /* Function Body */
00208     info = 0;
00209     if (! lsame_(trans, "N", 1L, 1L) && ! lsame_(trans, "T", 1L, 1L) && ! 
00210             lsame_(trans, "C", 1L, 1L)) {
00211         info = 1;
00212     } else if (*m < 0) {
00213         info = 2;
00214     } else if (*n < 0) {
00215         info = 3;
00216     } else if (*lda < max(1,*m)) {
00217         info = 6;
00218     } else if (*incx == 0) {
00219         info = 8;
00220     } else if (*incy == 0) {
00221         info = 11;
00222     }
00223     if (info != 0) {
00224         xerbla_("DGEMV ", &info, 6L);
00225         return 0;
00226     }
00227 
00228 /*     Quick return if possible. */
00229 
00230     if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
00231         return 0;
00232     }
00233 
00234 /*     Set  LENX  and  LENY, the lengths of the vectors x and y, and set 
00235 */
00236 /*     up the start points in  X  and  Y. */
00237 
00238     if (lsame_(trans, "N", 1L, 1L)) {
00239         lenx = *n;
00240         leny = *m;
00241     } else {
00242         lenx = *m;
00243         leny = *n;
00244     }
00245     if (*incx > 0) {
00246         kx = 1;
00247     } else {
00248         kx = 1 - (lenx - 1) * *incx;
00249     }
00250     if (*incy > 0) {
00251         ky = 1;
00252     } else {
00253         ky = 1 - (leny - 1) * *incy;
00254     }
00255 
00256 /*     Start the operations. In this version the elements of A are */
00257 /*     accessed sequentially with one pass through A. */
00258 
00259 /*     First form  y := beta*y. */
00260 
00261     if (*beta != 1.) {
00262         if (*incy == 1) {
00263             if (*beta == 0.) {
00264                 i__1 = leny;
00265                 for (i = 1; i <= i__1; ++i) {
00266                     y[i] = 0.;
00267 /* L10: */
00268                 }
00269             } else {
00270                 i__1 = leny;
00271                 for (i = 1; i <= i__1; ++i) {
00272                     y[i] = *beta * y[i];
00273 /* L20: */
00274                 }
00275             }
00276         } else {
00277             iy = ky;
00278             if (*beta == 0.) {
00279                 i__1 = leny;
00280                 for (i = 1; i <= i__1; ++i) {
00281                     y[iy] = 0.;
00282                     iy += *incy;
00283 /* L30: */
00284                 }
00285             } else {
00286                 i__1 = leny;
00287                 for (i = 1; i <= i__1; ++i) {
00288                     y[iy] = *beta * y[iy];
00289                     iy += *incy;
00290 /* L40: */
00291                 }
00292             }
00293         }
00294     }
00295     if (*alpha == 0.) {
00296         return 0;
00297     }
00298     if (lsame_(trans, "N", 1L, 1L)) {
00299 
00300 /*        Form  y := alpha*A*x + y. */
00301 
00302         jx = kx;
00303         if (*incy == 1) {
00304             i__1 = *n;
00305             for (j = 1; j <= i__1; ++j) {
00306                 if (x[jx] != 0.) {
00307                     temp = *alpha * x[jx];
00308                     i__2 = *m;
00309                     for (i = 1; i <= i__2; ++i) {
00310                         y[i] += temp * a[i + j * a_dim1];
00311 /* L50: */
00312                     }
00313                 }
00314                 jx += *incx;
00315 /* L60: */
00316             }
00317         } else {
00318             i__1 = *n;
00319             for (j = 1; j <= i__1; ++j) {
00320                 if (x[jx] != 0.) {
00321                     temp = *alpha * x[jx];
00322                     iy = ky;
00323                     i__2 = *m;
00324                     for (i = 1; i <= i__2; ++i) {
00325                         y[iy] += temp * a[i + j * a_dim1];
00326                         iy += *incy;
00327 /* L70: */
00328                     }
00329                 }
00330                 jx += *incx;
00331 /* L80: */
00332             }
00333         }
00334     } else {
00335 
00336 /*        Form  y := alpha*A'*x + y. */
00337 
00338         jy = ky;
00339         if (*incx == 1) {
00340             i__1 = *n;
00341             for (j = 1; j <= i__1; ++j) {
00342                 temp = 0.;
00343                 i__2 = *m;
00344                 for (i = 1; i <= i__2; ++i) {
00345                     temp += a[i + j * a_dim1] * x[i];
00346 /* L90: */
00347                 }
00348                 y[jy] += *alpha * temp;
00349                 jy += *incy;
00350 /* L100: */
00351             }
00352         } else {
00353             i__1 = *n;
00354             for (j = 1; j <= i__1; ++j) {
00355                 temp = 0.;
00356                 ix = kx;
00357                 i__2 = *m;
00358                 for (i = 1; i <= i__2; ++i) {
00359                     temp += a[i + j * a_dim1] * x[ix];
00360                     ix += *incx;
00361 /* L110: */
00362                 }
00363                 y[jy] += *alpha * temp;
00364                 jy += *incy;
00365 /* L120: */
00366             }
00367         }
00368     }
00369 
00370     return 0;
00371 
00372 /*     End of DGEMV . */
00373 
00374 } /* dgemv_ */
00375 

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1