1 SUBROUTINE ZHER2
( UPLO
, N
, ALPHA
, X
, INCX
, Y
, INCY
, A
, LDA
)
2 * .. Scalar Arguments
..
4 INTEGER INCX
, INCY
, LDA
, N
6 * .. Array Arguments
..
7 COMPLEX*16 A
( LDA
, * ), X
( * ), Y
( * )
13 * ZHER2 performs the hermitian rank
2 operation
15 * A
:= alpha*x*conjg
( y
' ) + conjg( alpha )*y*conjg( x' ) + A
,
17 * where alpha is a scalar
, x and y are n element vectors and A is an n
18 * by n hermitian matrix
.
24 * On entry
, UPLO specifies whether the upper or lower
25 * triangular part of the array A is
to be referenced as
28 * UPLO
= 'U' or
'u' Only the upper triangular part of A
29 * is
to be referenced
.
31 * UPLO
= 'L' or
'l' Only the lower triangular part of A
32 * is
to be referenced
.
37 * On entry
, N specifies the order of the matrix A
.
38 * N must be at least zero
.
41 * ALPHA
- COMPLEX*16
.
42 * On entry
, ALPHA specifies the scalar alpha
.
45 * X
- COMPLEX*16 array of
dimension at least
46 * ( 1 + ( n
- 1 )*abs
( INCX
) ).
47 * Before entry
, the incremented array X must contain the n
52 * On entry
, INCX specifies the increment
for the elements of
53 * X
. INCX must not be zero
.
56 * Y
- COMPLEX*16 array of
dimension at least
57 * ( 1 + ( n
- 1 )*abs
( INCY
) ).
58 * Before entry
, the incremented array Y must contain the n
63 * On entry
, INCY specifies the increment
for the elements of
64 * Y
. INCY must not be zero
.
67 * A
- COMPLEX*16 array of
DIMENSION ( LDA
, n
).
68 * Before entry with UPLO
= 'U' or
'u', the leading n by n
69 * upper triangular part of the array A must contain the upper
70 * triangular part of the hermitian matrix and the strictly
71 * lower triangular part of A is not referenced
. On exit
, the
72 * upper triangular part of the array A is overwritten by the
73 * upper triangular part of the updated matrix
.
74 * Before entry with UPLO
= 'L' or
'l', the leading n by n
75 * lower triangular part of the array A must contain the lower
76 * triangular part of the hermitian matrix and the strictly
77 * upper triangular part of A is not referenced
. On exit
, the
78 * lower triangular part of the array A is overwritten by the
79 * lower triangular part of the updated matrix
.
80 * Note that the imaginary parts of the diagonal elements need
81 * not be set
, they are assumed
to be zero
, and on exit they
85 * On entry
, LDA specifies the first
dimension of A as declared
86 * in the calling
(sub
) program. LDA must be at least
91 * Level
2 Blas routine
.
93 * -- Written on
22-October
-1986.
94 * Jack Dongarra
, Argonne National Lab
.
95 * Jeremy Du Croz
, Nag Central Office
.
96 * Sven Hammarling
, Nag Central Office
.
97 * Richard Hanson
, Sandia National Labs
.
102 PARAMETER ( ZERO
= ( 0.0D
+0, 0.0D
+0 ) )
103 * .. Local Scalars
..
104 COMPLEX*16 TEMP1
, TEMP2
105 INTEGER I
, INFO
, IX
, IY
, J
, JX
, JY
, KX
, KY
106 * .. External Functions
..
109 * .. External Subroutines
..
111 * .. Intrinsic Functions
..
112 INTRINSIC DCONJG
, MAX
, DBLE
114 * .. Executable Statements
..
116 * Test the input parameters
.
119 IF ( .NOT
.LSAME
( UPLO
, 'U' ).AND
.
120 $
.NOT
.LSAME
( UPLO
, 'L' ) )THEN
122 ELSE IF( N
.LT
.0 )THEN
124 ELSE IF( INCX
.EQ
.0 )THEN
126 ELSE IF( INCY
.EQ
.0 )THEN
128 ELSE IF( LDA
.LT
.MAX
( 1, N
) )THEN
132 CALL XERBLA
( 'ZHER2 ', INFO
)
136 * Quick
return if possible
.
138 IF( ( N
.EQ
.0 ).OR
.( ALPHA
.EQ
.ZERO
) )
141 * Set up the start points in X and Y
if the increments are not both
144 IF( ( INCX
.NE
.1 ).OR
.( INCY
.NE
.1 ) )THEN
148 KX
= 1 - ( N
- 1 )*INCX
153 KY
= 1 - ( N
- 1 )*INCY
159 * Start the operations
. In this version the elements of A are
160 * accessed sequentially with one pass through the triangular part
163 IF( LSAME
( UPLO
, 'U' ) )THEN
165 * Form A when A is stored in the upper triangle
.
167 IF( ( INCX
.EQ
.1 ).AND
.( INCY
.EQ
.1 ) )THEN
169 IF( ( X
( J
).NE
.ZERO
).OR
.( Y
( J
).NE
.ZERO
) )THEN
170 TEMP1
= ALPHA*DCONJG
( Y
( J
) )
171 TEMP2
= DCONJG
( ALPHA*X
( J
) )
173 A
( I
, J
) = A
( I
, J
) + X
( I
)*TEMP1
+ Y
( I
)*TEMP2
175 A
( J
, J
) = DBLE
( A
( J
, J
) ) +
176 $ DBLE
( X
( J
)*TEMP1
+ Y
( J
)*TEMP2
)
178 A
( J
, J
) = DBLE
( A
( J
, J
) )
183 IF( ( X
( JX
).NE
.ZERO
).OR
.( Y
( JY
).NE
.ZERO
) )THEN
184 TEMP1
= ALPHA*DCONJG
( Y
( JY
) )
185 TEMP2
= DCONJG
( ALPHA*X
( JX
) )
189 A
( I
, J
) = A
( I
, J
) + X
( IX
)*TEMP1
194 A
( J
, J
) = DBLE
( A
( J
, J
) ) +
195 $ DBLE
( X
( JX
)*TEMP1
+ Y
( JY
)*TEMP2
)
197 A
( J
, J
) = DBLE
( A
( J
, J
) )
205 * Form A when A is stored in the lower triangle
.
207 IF( ( INCX
.EQ
.1 ).AND
.( INCY
.EQ
.1 ) )THEN
209 IF( ( X
( J
).NE
.ZERO
).OR
.( Y
( J
).NE
.ZERO
) )THEN
210 TEMP1
= ALPHA*DCONJG
( Y
( J
) )
211 TEMP2
= DCONJG
( ALPHA*X
( J
) )
212 A
( J
, J
) = DBLE
( A
( J
, J
) ) +
213 $ DBLE
( X
( J
)*TEMP1
+ Y
( J
)*TEMP2
)
215 A
( I
, J
) = A
( I
, J
) + X
( I
)*TEMP1
+ Y
( I
)*TEMP2
218 A
( J
, J
) = DBLE
( A
( J
, J
) )
223 IF( ( X
( JX
).NE
.ZERO
).OR
.( Y
( JY
).NE
.ZERO
) )THEN
224 TEMP1
= ALPHA*DCONJG
( Y
( JY
) )
225 TEMP2
= DCONJG
( ALPHA*X
( JX
) )
226 A
( J
, J
) = DBLE
( A
( J
, J
) ) +
227 $ DBLE
( X
( JX
)*TEMP1
+ Y
( JY
)*TEMP2
)
233 A
( I
, J
) = A
( I
, J
) + X
( IX
)*TEMP1
237 A
( J
, J
) = DBLE
( A
( J
, J
) )