LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dgemv.f
Go to the documentation of this file.
00001 *> \brief \b DGEMV
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       DOUBLE PRECISION ALPHA,BETA
00015 *       INTEGER INCX,INCY,LDA,M,N
00016 *       CHARACTER TRANS
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       DOUBLE PRECISION A(LDA,*),X(*),Y(*)
00020 *       ..
00021 *  
00022 *
00023 *> \par Purpose:
00024 *  =============
00025 *>
00026 *> \verbatim
00027 *>
00028 *> DGEMV  performs one of the matrix-vector operations
00029 *>
00030 *>    y := alpha*A*x + beta*y,   or   y := alpha*A**T*x + beta*y,
00031 *>
00032 *> where alpha and beta are scalars, x and y are vectors and A is an
00033 *> m by n matrix.
00034 *> \endverbatim
00035 *
00036 *  Arguments:
00037 *  ==========
00038 *
00039 *> \param[in] TRANS
00040 *> \verbatim
00041 *>          TRANS is CHARACTER*1
00042 *>           On entry, TRANS specifies the operation to be performed as
00043 *>           follows:
00044 *>
00045 *>              TRANS = 'N' or 'n'   y := alpha*A*x + beta*y.
00046 *>
00047 *>              TRANS = 'T' or 't'   y := alpha*A**T*x + beta*y.
00048 *>
00049 *>              TRANS = 'C' or 'c'   y := alpha*A**T*x + beta*y.
00050 *> \endverbatim
00051 *>
00052 *> \param[in] M
00053 *> \verbatim
00054 *>          M is INTEGER
00055 *>           On entry, M specifies the number of rows of the matrix A.
00056 *>           M must be at least zero.
00057 *> \endverbatim
00058 *>
00059 *> \param[in] N
00060 *> \verbatim
00061 *>          N is INTEGER
00062 *>           On entry, N specifies the number of columns of the matrix A.
00063 *>           N must be at least zero.
00064 *> \endverbatim
00065 *>
00066 *> \param[in] ALPHA
00067 *> \verbatim
00068 *>          ALPHA is DOUBLE PRECISION.
00069 *>           On entry, ALPHA specifies the scalar alpha.
00070 *> \endverbatim
00071 *>
00072 *> \param[in] A
00073 *> \verbatim
00074 *>          A is DOUBLE PRECISION array of DIMENSION ( LDA, n ).
00075 *>           Before entry, the leading m by n part of the array A must
00076 *>           contain the matrix of coefficients.
00077 *> \endverbatim
00078 *>
00079 *> \param[in] LDA
00080 *> \verbatim
00081 *>          LDA is INTEGER
00082 *>           On entry, LDA specifies the first dimension of A as declared
00083 *>           in the calling (sub) program. LDA must be at least
00084 *>           max( 1, m ).
00085 *> \endverbatim
00086 *>
00087 *> \param[in] X
00088 *> \verbatim
00089 *>          X is DOUBLE PRECISION array of DIMENSION at least
00090 *>           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
00091 *>           and at least
00092 *>           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
00093 *>           Before entry, the incremented array X must contain the
00094 *>           vector x.
00095 *> \endverbatim
00096 *>
00097 *> \param[in] INCX
00098 *> \verbatim
00099 *>          INCX is INTEGER
00100 *>           On entry, INCX specifies the increment for the elements of
00101 *>           X. INCX must not be zero.
00102 *> \endverbatim
00103 *>
00104 *> \param[in] BETA
00105 *> \verbatim
00106 *>          BETA is DOUBLE PRECISION.
00107 *>           On entry, BETA specifies the scalar beta. When BETA is
00108 *>           supplied as zero then Y need not be set on input.
00109 *> \endverbatim
00110 *>
00111 *> \param[in,out] Y
00112 *> \verbatim
00113 *>          Y is DOUBLE PRECISION array of DIMENSION at least
00114 *>           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
00115 *>           and at least
00116 *>           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
00117 *>           Before entry with BETA non-zero, the incremented array Y
00118 *>           must contain the vector y. On exit, Y is overwritten by the
00119 *>           updated vector y.
00120 *> \endverbatim
00121 *>
00122 *> \param[in] INCY
00123 *> \verbatim
00124 *>          INCY is INTEGER
00125 *>           On entry, INCY specifies the increment for the elements of
00126 *>           Y. INCY must not be zero.
00127 *> \endverbatim
00128 *
00129 *  Authors:
00130 *  ========
00131 *
00132 *> \author Univ. of Tennessee 
00133 *> \author Univ. of California Berkeley 
00134 *> \author Univ. of Colorado Denver 
00135 *> \author NAG Ltd. 
00136 *
00137 *> \date November 2011
00138 *
00139 *> \ingroup double_blas_level2
00140 *
00141 *> \par Further Details:
00142 *  =====================
00143 *>
00144 *> \verbatim
00145 *>
00146 *>  Level 2 Blas routine.
00147 *>  The vector and matrix arguments are not referenced when N = 0, or M = 0
00148 *>
00149 *>  -- Written on 22-October-1986.
00150 *>     Jack Dongarra, Argonne National Lab.
00151 *>     Jeremy Du Croz, Nag Central Office.
00152 *>     Sven Hammarling, Nag Central Office.
00153 *>     Richard Hanson, Sandia National Labs.
00154 *> \endverbatim
00155 *>
00156 *  =====================================================================
00157       SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
00158 *
00159 *  -- Reference BLAS level2 routine (version 3.4.0) --
00160 *  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
00161 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00162 *     November 2011
00163 *
00164 *     .. Scalar Arguments ..
00165       DOUBLE PRECISION ALPHA,BETA
00166       INTEGER INCX,INCY,LDA,M,N
00167       CHARACTER TRANS
00168 *     ..
00169 *     .. Array Arguments ..
00170       DOUBLE PRECISION A(LDA,*),X(*),Y(*)
00171 *     ..
00172 *
00173 *  =====================================================================
00174 *
00175 *     .. Parameters ..
00176       DOUBLE PRECISION ONE,ZERO
00177       PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
00178 *     ..
00179 *     .. Local Scalars ..
00180       DOUBLE PRECISION TEMP
00181       INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY,LENX,LENY
00182 *     ..
00183 *     .. External Functions ..
00184       LOGICAL LSAME
00185       EXTERNAL LSAME
00186 *     ..
00187 *     .. External Subroutines ..
00188       EXTERNAL XERBLA
00189 *     ..
00190 *     .. Intrinsic Functions ..
00191       INTRINSIC MAX
00192 *     ..
00193 *
00194 *     Test the input parameters.
00195 *
00196       INFO = 0
00197       IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
00198      +    .NOT.LSAME(TRANS,'C')) THEN
00199           INFO = 1
00200       ELSE IF (M.LT.0) THEN
00201           INFO = 2
00202       ELSE IF (N.LT.0) THEN
00203           INFO = 3
00204       ELSE IF (LDA.LT.MAX(1,M)) THEN
00205           INFO = 6
00206       ELSE IF (INCX.EQ.0) THEN
00207           INFO = 8
00208       ELSE IF (INCY.EQ.0) THEN
00209           INFO = 11
00210       END IF
00211       IF (INFO.NE.0) THEN
00212           CALL XERBLA('DGEMV ',INFO)
00213           RETURN
00214       END IF
00215 *
00216 *     Quick return if possible.
00217 *
00218       IF ((M.EQ.0) .OR. (N.EQ.0) .OR.
00219      +    ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
00220 *
00221 *     Set  LENX  and  LENY, the lengths of the vectors x and y, and set
00222 *     up the start points in  X  and  Y.
00223 *
00224       IF (LSAME(TRANS,'N')) THEN
00225           LENX = N
00226           LENY = M
00227       ELSE
00228           LENX = M
00229           LENY = N
00230       END IF
00231       IF (INCX.GT.0) THEN
00232           KX = 1
00233       ELSE
00234           KX = 1 - (LENX-1)*INCX
00235       END IF
00236       IF (INCY.GT.0) THEN
00237           KY = 1
00238       ELSE
00239           KY = 1 - (LENY-1)*INCY
00240       END IF
00241 *
00242 *     Start the operations. In this version the elements of A are
00243 *     accessed sequentially with one pass through A.
00244 *
00245 *     First form  y := beta*y.
00246 *
00247       IF (BETA.NE.ONE) THEN
00248           IF (INCY.EQ.1) THEN
00249               IF (BETA.EQ.ZERO) THEN
00250                   DO 10 I = 1,LENY
00251                       Y(I) = ZERO
00252    10             CONTINUE
00253               ELSE
00254                   DO 20 I = 1,LENY
00255                       Y(I) = BETA*Y(I)
00256    20             CONTINUE
00257               END IF
00258           ELSE
00259               IY = KY
00260               IF (BETA.EQ.ZERO) THEN
00261                   DO 30 I = 1,LENY
00262                       Y(IY) = ZERO
00263                       IY = IY + INCY
00264    30             CONTINUE
00265               ELSE
00266                   DO 40 I = 1,LENY
00267                       Y(IY) = BETA*Y(IY)
00268                       IY = IY + INCY
00269    40             CONTINUE
00270               END IF
00271           END IF
00272       END IF
00273       IF (ALPHA.EQ.ZERO) RETURN
00274       IF (LSAME(TRANS,'N')) THEN
00275 *
00276 *        Form  y := alpha*A*x + y.
00277 *
00278           JX = KX
00279           IF (INCY.EQ.1) THEN
00280               DO 60 J = 1,N
00281                   IF (X(JX).NE.ZERO) THEN
00282                       TEMP = ALPHA*X(JX)
00283                       DO 50 I = 1,M
00284                           Y(I) = Y(I) + TEMP*A(I,J)
00285    50                 CONTINUE
00286                   END IF
00287                   JX = JX + INCX
00288    60         CONTINUE
00289           ELSE
00290               DO 80 J = 1,N
00291                   IF (X(JX).NE.ZERO) THEN
00292                       TEMP = ALPHA*X(JX)
00293                       IY = KY
00294                       DO 70 I = 1,M
00295                           Y(IY) = Y(IY) + TEMP*A(I,J)
00296                           IY = IY + INCY
00297    70                 CONTINUE
00298                   END IF
00299                   JX = JX + INCX
00300    80         CONTINUE
00301           END IF
00302       ELSE
00303 *
00304 *        Form  y := alpha*A**T*x + y.
00305 *
00306           JY = KY
00307           IF (INCX.EQ.1) THEN
00308               DO 100 J = 1,N
00309                   TEMP = ZERO
00310                   DO 90 I = 1,M
00311                       TEMP = TEMP + A(I,J)*X(I)
00312    90             CONTINUE
00313                   Y(JY) = Y(JY) + ALPHA*TEMP
00314                   JY = JY + INCY
00315   100         CONTINUE
00316           ELSE
00317               DO 120 J = 1,N
00318                   TEMP = ZERO
00319                   IX = KX
00320                   DO 110 I = 1,M
00321                       TEMP = TEMP + A(I,J)*X(IX)
00322                       IX = IX + INCX
00323   110             CONTINUE
00324                   Y(JY) = Y(JY) + ALPHA*TEMP
00325                   JY = JY + INCY
00326   120         CONTINUE
00327           END IF
00328       END IF
00329 *
00330       RETURN
00331 *
00332 *     End of DGEMV .
00333 *
00334       END
 All Files Functions