1 SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
2 ! .. Scalar Arguments ..
3 DOUBLE PRECISION ALPHA,BETA
4 INTEGER INCX,INCY,LDA,M,N
7 ! .. Array Arguments ..
8 DOUBLE PRECISION A(LDA,*),X(*),Y(*)
14 ! DGEMV performs one of the matrix-vector operations
16 ! y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
18 ! where alpha and beta are scalars, x and y are vectors and A is an
24 ! TRANS - CHARACTER*1.
25 ! On entry, TRANS specifies the operation to be performed as
28 ! TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
30 ! TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
32 ! TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
37 ! On entry, M specifies the number of rows of the matrix A.
38 ! M must be at least zero.
42 ! On entry, N specifies the number of columns of the matrix A.
43 ! N must be at least zero.
46 ! ALPHA - DOUBLE PRECISION.
47 ! On entry, ALPHA specifies the scalar alpha.
50 ! A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
51 ! Before entry, the leading m by n part of the array A must
52 ! contain the matrix of coefficients.
56 ! On entry, LDA specifies the first dimension of A as declared
57 ! in the calling (sub) program. LDA must be at least
61 ! X - DOUBLE PRECISION array of DIMENSION at least
62 ! ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
64 ! ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
65 ! Before entry, the incremented array X must contain the
70 ! On entry, INCX specifies the increment for the elements of
71 ! X. INCX must not be zero.
74 ! BETA - DOUBLE PRECISION.
75 ! On entry, BETA specifies the scalar beta. When BETA is
76 ! supplied as zero then Y need not be set on input.
79 ! Y - DOUBLE PRECISION array of DIMENSION at least
80 ! ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
82 ! ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
83 ! Before entry with BETA non-zero, the incremented array Y
84 ! must contain the vector y. On exit, Y is overwritten by the
88 ! On entry, INCY specifies the increment for the elements of
89 ! Y. INCY must not be zero.
93 ! Level 2 Blas routine.
95 ! -- Written on 22-October-1986.
96 ! Jack Dongarra, Argonne National Lab.
97 ! Jeremy Du Croz, Nag Central Office.
98 ! Sven Hammarling, Nag Central Office.
99 ! Richard Hanson, Sandia National Labs.
103 DOUBLE PRECISION ONE,ZERO
104 PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
106 ! .. Local Scalars ..
107 DOUBLE PRECISION TEMP
108 INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY,LENX,LENY
110 ! .. External Functions ..
114 ! .. External Subroutines ..
117 ! .. Intrinsic Functions ..
121 ! Test the input parameters.
124 IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND. &
125 .NOT.LSAME(TRANS,'C')) THEN
127 ELSE IF (M.LT.0) THEN
129 ELSE IF (N.LT.0) THEN
131 ELSE IF (LDA.LT.MAX(1,M)) THEN
133 ELSE IF (INCX.EQ.0) THEN
135 ELSE IF (INCY.EQ.0) THEN
139 CALL XERBLA('DGEMV ',INFO)
143 ! Quick return if possible.
145 IF ((M.EQ.0) .OR. (N.EQ.0) .OR. &
146 ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
148 ! Set LENX and LENY, the lengths of the vectors x and y, and set
149 ! up the start points in X and Y.
151 IF (LSAME(TRANS,'N')) THEN
161 KX = 1 - (LENX-1)*INCX
166 KY = 1 - (LENY-1)*INCY
169 ! Start the operations. In this version the elements of A are
170 ! accessed sequentially with one pass through A.
172 ! First form y := beta*y.
174 IF (BETA.NE.ONE) THEN
176 IF (BETA.EQ.ZERO) THEN
187 IF (BETA.EQ.ZERO) THEN
200 IF (ALPHA.EQ.ZERO) RETURN
201 IF (LSAME(TRANS,'N')) THEN
203 ! Form y := alpha*A*x + y.
208 IF (X(JX).NE.ZERO) THEN
211 Y(I) = Y(I) + TEMP*A(I,J)
218 IF (X(JX).NE.ZERO) THEN
222 Y(IY) = Y(IY) + TEMP*A(I,J)
231 ! Form y := alpha*A'*x + y.
238 TEMP = TEMP + A(I,J)*X(I)
240 Y(JY) = Y(JY) + ALPHA*TEMP
248 TEMP = TEMP + A(I,J)*X(IX)
251 Y(JY) = Y(JY) + ALPHA*TEMP