2
SUBROUTINE CHEMV (UPLO, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
3
C***BEGIN PROLOGUE CHEMV
4
C***PURPOSE Multiply a complex vector by a complex Hermitian matrix.
5
C***LIBRARY SLATEC (BLAS)
7
C***TYPE COMPLEX (SHEMV-S, DHEMV-D, CHEMV-C)
8
C***KEYWORDS LEVEL 2 BLAS, LINEAR ALGEBRA
9
C***AUTHOR Dongarra, J. J., (ANL)
11
C Hammarling, S., (NAG)
12
C Hanson, R. J., (SNLA)
15
C CHEMV performs the matrix-vector operation
17
C y := alpha*A*x + beta*y,
19
C where alpha and beta are scalars, x and y are n element vectors and
20
C A is an n by n hermitian matrix.
26
C On entry, UPLO specifies whether the upper or lower
27
C triangular part of the array A is to be referenced as
30
C UPLO = 'U' or 'u' Only the upper triangular part of A
31
C is to be referenced.
33
C UPLO = 'L' or 'l' Only the lower triangular part of A
34
C is to be referenced.
39
C On entry, N specifies the order of the matrix A.
40
C N must be at least zero.
44
C On entry, ALPHA specifies the scalar alpha.
47
C A - COMPLEX array of DIMENSION ( LDA, n ).
48
C Before entry with UPLO = 'U' or 'u', the leading n by n
49
C upper triangular part of the array A must contain the upper
50
C triangular part of the hermitian matrix and the strictly
51
C lower triangular part of A is not referenced.
52
C Before entry with UPLO = 'L' or 'l', the leading n by n
53
C lower triangular part of the array A must contain the lower
54
C triangular part of the hermitian matrix and the strictly
55
C upper triangular part of A is not referenced.
56
C Note that the imaginary parts of the diagonal elements need
57
C not be set and are assumed to be zero.
61
C On entry, LDA specifies the first dimension of A as declared
62
C in the calling (sub) program. LDA must be at least
66
C X - COMPLEX array of dimension at least
67
C ( 1 + ( n - 1 )*abs( INCX ) ).
68
C Before entry, the incremented array X must contain the n
73
C On entry, INCX specifies the increment for the elements of
74
C X. INCX must not be zero.
78
C On entry, BETA specifies the scalar beta. When BETA is
79
C supplied as zero then Y need not be set on input.
82
C Y - COMPLEX array of dimension at least
83
C ( 1 + ( n - 1 )*abs( INCY ) ).
84
C Before entry, the incremented array Y must contain the n
85
C element vector y. On exit, Y is overwritten by the updated
89
C On entry, INCY specifies the increment for the elements of
90
C Y. INCY must not be zero.
93
C***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
94
C Hanson, R. J. An extended set of Fortran basic linear
95
C algebra subprograms. ACM TOMS, Vol. 14, No. 1,
96
C pp. 1-17, March 1988.
97
C***ROUTINES CALLED LSAME, XERBLA
98
C***REVISION HISTORY (YYMMDD)
100
C 910605 Modified to meet SLATEC prologue standards. Only comment
101
C lines were modified. (BKS)
102
C***END PROLOGUE CHEMV
103
C .. Scalar Arguments ..
105
INTEGER INCX, INCY, LDA, N
107
C .. Array Arguments ..
108
COMPLEX A( LDA, * ), X( * ), Y( * )
111
PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ) )
113
PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
114
C .. Local Scalars ..
116
INTEGER I, INFO, IX, IY, J, JX, JY, KX, KY
117
C .. External Functions ..
120
C .. External Subroutines ..
122
C .. Intrinsic Functions ..
123
INTRINSIC CONJG, MAX, REAL
124
C***FIRST EXECUTABLE STATEMENT CHEMV
126
C Test the input parameters.
129
IF ( .NOT.LSAME( UPLO, 'U' ).AND.
130
$ .NOT.LSAME( UPLO, 'L' ) )THEN
132
ELSE IF( N.LT.0 )THEN
134
ELSE IF( LDA.LT.MAX( 1, N ) )THEN
136
ELSE IF( INCX.EQ.0 )THEN
138
ELSE IF( INCY.EQ.0 )THEN
142
CALL XERBLA( 'CHEMV ', INFO )
146
C Quick return if possible.
148
IF( ( N.EQ.0 ).OR.( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
151
C Set up the start points in X and Y.
156
KX = 1 - ( N - 1 )*INCX
161
KY = 1 - ( N - 1 )*INCY
164
C Start the operations. In this version the elements of A are
165
C accessed sequentially with one pass through the triangular part
168
C First form y := beta*y.
170
IF( BETA.NE.ONE )THEN
172
IF( BETA.EQ.ZERO )THEN
183
IF( BETA.EQ.ZERO )THEN
190
Y( IY ) = BETA*Y( IY )
198
IF( LSAME( UPLO, 'U' ) )THEN
200
C Form y when A is stored in upper triangle.
202
IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
207
Y( I ) = Y( I ) + TEMP1*A( I, J )
208
TEMP2 = TEMP2 + CONJG( A( I, J ) )*X( I )
210
Y( J ) = Y( J ) + TEMP1*REAL( A( J, J ) ) + ALPHA*TEMP2
216
TEMP1 = ALPHA*X( JX )
221
Y( IY ) = Y( IY ) + TEMP1*A( I, J )
222
TEMP2 = TEMP2 + CONJG( A( I, J ) )*X( IX )
226
Y( JY ) = Y( JY ) + TEMP1*REAL( A( J, J ) ) + ALPHA*TEMP2
233
C Form y when A is stored in lower triangle.
235
IF( ( INCX.EQ.1 ).AND.( INCY.EQ.1 ) )THEN
239
Y( J ) = Y( J ) + TEMP1*REAL( A( J, J ) )
241
Y( I ) = Y( I ) + TEMP1*A( I, J )
242
TEMP2 = TEMP2 + CONJG( A( I, J ) )*X( I )
244
Y( J ) = Y( J ) + ALPHA*TEMP2
250
TEMP1 = ALPHA*X( JX )
252
Y( JY ) = Y( JY ) + TEMP1*REAL( A( J, J ) )
258
Y( IY ) = Y( IY ) + TEMP1*A( I, J )
259
TEMP2 = TEMP2 + CONJG( A( I, J ) )*X( IX )
261
Y( JY ) = Y( JY ) + ALPHA*TEMP2