2
SUBROUTINE DGEMV (TRANS, M, N, ALPHA, A, LDA, X, INCX, BETA, Y,
4
C***BEGIN PROLOGUE DGEMV
5
C***PURPOSE Perform one of the matrix-vector operations.
6
C***LIBRARY SLATEC (BLAS)
8
C***TYPE DOUBLE PRECISION (SGEMV-S, DGEMV-D, CGEMV-C)
9
C***KEYWORDS LEVEL 2 BLAS, LINEAR ALGEBRA
10
C***AUTHOR Dongarra, J. J., (ANL)
12
C Hammarling, S., (NAG)
13
C Hanson, R. J., (SNLA)
16
C DGEMV performs one of the matrix-vector operations
18
C y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y,
20
C where alpha and beta are scalars, x and y are vectors and A is an
26
C TRANS - CHARACTER*1.
27
C On entry, TRANS specifies the operation to be performed as
30
C TRANS = 'N' or 'n' y := alpha*A*x + beta*y.
32
C TRANS = 'T' or 't' y := alpha*A'*x + beta*y.
34
C TRANS = 'C' or 'c' y := alpha*A'*x + beta*y.
39
C On entry, M specifies the number of rows of the matrix A.
40
C M must be at least zero.
44
C On entry, N specifies the number of columns of the matrix A.
45
C N must be at least zero.
48
C ALPHA - DOUBLE PRECISION.
49
C On entry, ALPHA specifies the scalar alpha.
52
C A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
53
C Before entry, the leading m by n part of the array A must
54
C contain the matrix of coefficients.
58
C On entry, LDA specifies the first dimension of A as declared
59
C in the calling (sub) program. LDA must be at least
63
C X - DOUBLE PRECISION array of DIMENSION at least
64
C ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
66
C ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
67
C Before entry, the incremented array X must contain the
72
C On entry, INCX specifies the increment for the elements of
73
C X. INCX must not be zero.
76
C BETA - DOUBLE PRECISION.
77
C On entry, BETA specifies the scalar beta. When BETA is
78
C supplied as zero then Y need not be set on input.
81
C Y - DOUBLE PRECISION array of DIMENSION at least
82
C ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
84
C ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
85
C Before entry with BETA non-zero, the incremented array Y
86
C must contain the vector y. On exit, Y is overwritten by the
90
C On entry, INCY specifies the increment for the elements of
91
C Y. INCY must not be zero.
94
C***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
95
C Hanson, R. J. An extended set of Fortran basic linear
96
C algebra subprograms. ACM TOMS, Vol. 14, No. 1,
97
C pp. 1-17, March 1988.
98
C***ROUTINES CALLED LSAME, XERBLA
99
C***REVISION HISTORY (YYMMDD)
100
C 861022 DATE WRITTEN
101
C 910605 Modified to meet SLATEC prologue standards. Only comment
102
C lines were modified. (BKS)
103
C***END PROLOGUE DGEMV
104
C .. Scalar Arguments ..
105
DOUBLE PRECISION ALPHA, BETA
106
INTEGER INCX, INCY, LDA, M, N
108
C .. Array Arguments ..
109
DOUBLE PRECISION A( LDA, * ), X( * ), Y( * )
111
DOUBLE PRECISION ONE , ZERO
112
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
113
C .. Local Scalars ..
114
DOUBLE PRECISION TEMP
115
INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY, LENX, LENY
116
C .. External Functions ..
119
C .. External Subroutines ..
121
C .. Intrinsic Functions ..
123
C***FIRST EXECUTABLE STATEMENT DGEMV
125
C Test the input parameters.
128
IF ( .NOT.LSAME( TRANS, 'N' ).AND.
129
$ .NOT.LSAME( TRANS, 'T' ).AND.
130
$ .NOT.LSAME( TRANS, 'C' ) )THEN
132
ELSE IF( M.LT.0 )THEN
134
ELSE IF( N.LT.0 )THEN
136
ELSE IF( LDA.LT.MAX( 1, M ) )THEN
138
ELSE IF( INCX.EQ.0 )THEN
140
ELSE IF( INCY.EQ.0 )THEN
144
CALL XERBLA( 'DGEMV ', INFO )
148
C Quick return if possible.
150
IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
151
$ ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
154
C Set LENX and LENY, the lengths of the vectors x and y, and set
155
C up the start points in X and Y.
157
IF( LSAME( TRANS, 'N' ) )THEN
167
KX = 1 - ( LENX - 1 )*INCX
172
KY = 1 - ( LENY - 1 )*INCY
175
C Start the operations. In this version the elements of A are
176
C accessed sequentially with one pass through A.
178
C First form y := beta*y.
180
IF( BETA.NE.ONE )THEN
182
IF( BETA.EQ.ZERO )THEN
193
IF( BETA.EQ.ZERO )THEN
200
Y( IY ) = BETA*Y( IY )
208
IF( LSAME( TRANS, 'N' ) )THEN
210
C Form y := alpha*A*x + y.
215
IF( X( JX ).NE.ZERO )THEN
218
Y( I ) = Y( I ) + TEMP*A( I, J )
225
IF( X( JX ).NE.ZERO )THEN
229
Y( IY ) = Y( IY ) + TEMP*A( I, J )
238
C Form y := alpha*A'*x + y.
245
TEMP = TEMP + A( I, J )*X( I )
247
Y( JY ) = Y( JY ) + ALPHA*TEMP
255
TEMP = TEMP + A( I, J )*X( IX )
258
Y( JY ) = Y( JY ) + ALPHA*TEMP