2
SUBROUTINE CHER (UPLO, N, ALPHA, X, INCX, A, LDA)
3
C***BEGIN PROLOGUE CHER
4
C***PURPOSE Perform Hermitian rank 1 update of a complex Hermitian
6
C***LIBRARY SLATEC (BLAS)
8
C***TYPE COMPLEX (SHER-S, DHER-D, CHER-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 CHER performs the hermitian rank 1 operation
18
C A := alpha*x*conjg( x') + A,
20
C where alpha is a real scalar, x is an n element vector and A is an
21
C n by n hermitian matrix.
27
C On entry, UPLO specifies whether the upper or lower
28
C triangular part of the array A is to be referenced as
31
C UPLO = 'U' or 'u' Only the upper triangular part of A
32
C is to be referenced.
34
C UPLO = 'L' or 'l' Only the lower triangular part of A
35
C is to be referenced.
40
C On entry, N specifies the order of the matrix A.
41
C N must be at least zero.
45
C On entry, ALPHA specifies the scalar alpha.
48
C X - COMPLEX array of dimension at least
49
C ( 1 + ( n - 1 )*abs( INCX ) ).
50
C Before entry, the incremented array X must contain the n
55
C On entry, INCX specifies the increment for the elements of
56
C X. INCX must not be zero.
59
C A - COMPLEX array of DIMENSION ( LDA, n ).
60
C Before entry with UPLO = 'U' or 'u', the leading n by n
61
C upper triangular part of the array A must contain the upper
62
C triangular part of the hermitian matrix and the strictly
63
C lower triangular part of A is not referenced. On exit, the
64
C upper triangular part of the array A is overwritten by the
65
C upper triangular part of the updated matrix.
66
C Before entry with UPLO = 'L' or 'l', the leading n by n
67
C lower triangular part of the array A must contain the lower
68
C triangular part of the hermitian matrix and the strictly
69
C upper triangular part of A is not referenced. On exit, the
70
C lower triangular part of the array A is overwritten by the
71
C lower triangular part of the updated matrix.
72
C Note that the imaginary parts of the diagonal elements need
73
C not be set, they are assumed to be zero, and on exit they
77
C On entry, LDA specifies the first dimension of A as declared
78
C in the calling (sub) program. LDA must be at least
82
C***REFERENCES Dongarra, J. J., Du Croz, J., Hammarling, S., and
83
C Hanson, R. J. An extended set of Fortran basic linear
84
C algebra subprograms. ACM TOMS, Vol. 14, No. 1,
85
C pp. 1-17, March 1988.
86
C***ROUTINES CALLED LSAME, XERBLA
87
C***REVISION HISTORY (YYMMDD)
89
C 910605 Modified to meet SLATEC prologue standards. Only comment
90
C lines were modified. (BKS)
92
C .. Scalar Arguments ..
96
C .. Array Arguments ..
97
COMPLEX A( LDA, * ), X( * )
100
PARAMETER ( ZERO = ( 0.0E+0, 0.0E+0 ) )
101
C .. Local Scalars ..
103
INTEGER I, INFO, IX, J, JX, KX
104
C .. External Functions ..
107
C .. External Subroutines ..
109
C .. Intrinsic Functions ..
110
INTRINSIC CONJG, MAX, REAL
111
C***FIRST EXECUTABLE STATEMENT CHER
113
C Test the input parameters.
116
IF ( .NOT.LSAME( UPLO, 'U' ).AND.
117
$ .NOT.LSAME( UPLO, 'L' ) )THEN
119
ELSE IF( N.LT.0 )THEN
121
ELSE IF( INCX.EQ.0 )THEN
123
ELSE IF( LDA.LT.MAX( 1, N ) )THEN
127
CALL XERBLA( 'CHER ', INFO )
131
C Quick return if possible.
133
IF( ( N.EQ.0 ).OR.( ALPHA.EQ.REAL( ZERO ) ) )
136
C Set the start point in X if the increment is not unity.
139
KX = 1 - ( N - 1 )*INCX
140
ELSE IF( INCX.NE.1 )THEN
144
C Start the operations. In this version the elements of A are
145
C accessed sequentially with one pass through the triangular part
148
IF( LSAME( UPLO, 'U' ) )THEN
150
C Form A when A is stored in upper triangle.
154
IF( X( J ).NE.ZERO )THEN
155
TEMP = ALPHA*CONJG( X( J ) )
157
A( I, J ) = A( I, J ) + X( I )*TEMP
159
A( J, J ) = REAL( A( J, J ) ) + REAL( X( J )*TEMP )
161
A( J, J ) = REAL( A( J, J ) )
167
IF( X( JX ).NE.ZERO )THEN
168
TEMP = ALPHA*CONJG( X( JX ) )
171
A( I, J ) = A( I, J ) + X( IX )*TEMP
174
A( J, J ) = REAL( A( J, J ) ) + REAL( X( JX )*TEMP )
176
A( J, J ) = REAL( A( J, J ) )
183
C Form A when A is stored in lower triangle.
187
IF( X( J ).NE.ZERO )THEN
188
TEMP = ALPHA*CONJG( X( J ) )
189
A( J, J ) = REAL( A( J, J ) ) + REAL( TEMP*X( J ) )
191
A( I, J ) = A( I, J ) + X( I )*TEMP
194
A( J, J ) = REAL( A( J, J ) )
200
IF( X( JX ).NE.ZERO )THEN
201
TEMP = ALPHA*CONJG( X( JX ) )
202
A( J, J ) = REAL( A( J, J ) ) + REAL( TEMP*X( JX ) )
206
A( I, J ) = A( I, J ) + X( IX )*TEMP
209
A( J, J ) = REAL( A( J, J ) )