1
SUBROUTINE CHER2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
2
* .. Scalar Arguments ..
4
INTEGER INCX,INCY,LDA,N
7
* .. Array Arguments ..
8
COMPLEX A(LDA,*),X(*),Y(*)
14
* CHER2 performs the hermitian rank 2 operation
16
* A := alpha*x*conjg( y' ) + conjg( alpha )*y*conjg( x' ) + A,
18
* where alpha is a scalar, x and y are n element vectors and A is an n
19
* by n hermitian matrix.
25
* On entry, UPLO specifies whether the upper or lower
26
* triangular part of the array A is to be referenced as
29
* UPLO = 'U' or 'u' Only the upper triangular part of A
30
* is to be referenced.
32
* UPLO = 'L' or 'l' Only the lower triangular part of A
33
* is to be referenced.
38
* On entry, N specifies the order of the matrix A.
39
* N must be at least zero.
43
* On entry, ALPHA specifies the scalar alpha.
46
* X - COMPLEX array of dimension at least
47
* ( 1 + ( n - 1 )*abs( INCX ) ).
48
* Before entry, the incremented array X must contain the n
53
* On entry, INCX specifies the increment for the elements of
54
* X. INCX must not be zero.
57
* Y - COMPLEX array of dimension at least
58
* ( 1 + ( n - 1 )*abs( INCY ) ).
59
* Before entry, the incremented array Y must contain the n
64
* On entry, INCY specifies the increment for the elements of
65
* Y. INCY must not be zero.
68
* A - COMPLEX array of DIMENSION ( LDA, n ).
69
* Before entry with UPLO = 'U' or 'u', the leading n by n
70
* upper triangular part of the array A must contain the upper
71
* triangular part of the hermitian matrix and the strictly
72
* lower triangular part of A is not referenced. On exit, the
73
* upper triangular part of the array A is overwritten by the
74
* upper triangular part of the updated matrix.
75
* Before entry with UPLO = 'L' or 'l', the leading n by n
76
* lower triangular part of the array A must contain the lower
77
* triangular part of the hermitian matrix and the strictly
78
* upper triangular part of A is not referenced. On exit, the
79
* lower triangular part of the array A is overwritten by the
80
* lower triangular part of the updated matrix.
81
* Note that the imaginary parts of the diagonal elements need
82
* not be set, they are assumed to be zero, and on exit they
86
* On entry, LDA specifies the first dimension of A as declared
87
* in the calling (sub) program. LDA must be at least
92
* Level 2 Blas routine.
94
* -- Written on 22-October-1986.
95
* Jack Dongarra, Argonne National Lab.
96
* Jeremy Du Croz, Nag Central Office.
97
* Sven Hammarling, Nag Central Office.
98
* Richard Hanson, Sandia National Labs.
103
PARAMETER (ZERO= (0.0E+0,0.0E+0))
105
* .. Local Scalars ..
107
INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY
109
* .. External Functions ..
113
* .. External Subroutines ..
116
* .. Intrinsic Functions ..
117
INTRINSIC CONJG,MAX,REAL
120
* Test the input parameters.
123
IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
125
ELSE IF (N.LT.0) THEN
127
ELSE IF (INCX.EQ.0) THEN
129
ELSE IF (INCY.EQ.0) THEN
131
ELSE IF (LDA.LT.MAX(1,N)) THEN
135
CALL XERBLA('CHER2 ',INFO)
139
* Quick return if possible.
141
IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
143
* Set up the start points in X and Y if the increments are not both
146
IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN
161
* Start the operations. In this version the elements of A are
162
* accessed sequentially with one pass through the triangular part
165
IF (LSAME(UPLO,'U')) THEN
167
* Form A when A is stored in the upper triangle.
169
IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
171
IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
172
TEMP1 = ALPHA*CONJG(Y(J))
173
TEMP2 = CONJG(ALPHA*X(J))
175
A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
177
A(J,J) = REAL(A(J,J)) +
178
+ REAL(X(J)*TEMP1+Y(J)*TEMP2)
180
A(J,J) = REAL(A(J,J))
185
IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
186
TEMP1 = ALPHA*CONJG(Y(JY))
187
TEMP2 = CONJG(ALPHA*X(JX))
191
A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
195
A(J,J) = REAL(A(J,J)) +
196
+ REAL(X(JX)*TEMP1+Y(JY)*TEMP2)
198
A(J,J) = REAL(A(J,J))
206
* Form A when A is stored in the lower triangle.
208
IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
210
IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
211
TEMP1 = ALPHA*CONJG(Y(J))
212
TEMP2 = CONJG(ALPHA*X(J))
213
A(J,J) = REAL(A(J,J)) +
214
+ REAL(X(J)*TEMP1+Y(J)*TEMP2)
216
A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
219
A(J,J) = REAL(A(J,J))
224
IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
225
TEMP1 = ALPHA*CONJG(Y(JY))
226
TEMP2 = CONJG(ALPHA*X(JX))
227
A(J,J) = REAL(A(J,J)) +
228
+ REAL(X(JX)*TEMP1+Y(JY)*TEMP2)
234
A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
237
A(J,J) = REAL(A(J,J))