1 SUBROUTINE ZHPTRD
( UPLO
, N
, AP
, D
, E
, TAU
, INFO
)
3 * -- LAPACK routine
(version
3.1) --
4 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
7 * .. Scalar Arguments
..
11 * .. Array Arguments
..
12 DOUBLE PRECISION D
( * ), E
( * )
13 COMPLEX*16 AP
( * ), TAU
( * )
19 * ZHPTRD reduces a
complex Hermitian matrix A stored in packed form
to
20 * real symmetric tridiagonal form T by a unitary similarity
21 * transformation
: Q**H
* A
* Q
= T
.
26 * UPLO
(input
) CHARACTER*1
27 * = 'U': Upper triangle of A is stored
;
28 * = 'L': Lower triangle of A is stored
.
31 * The order of the matrix A
. N
>= 0.
33 * AP
(input
/output
) COMPLEX*16 array
, dimension (N*
(N
+1)/2)
34 * On entry
, the upper or lower triangle of the Hermitian matrix
35 * A
, packed columnwise in a linear array
. The j
-th column of A
36 * is stored in the array AP as follows
:
37 * if UPLO
= 'U', AP
(i
+ (j
-1)*j
/2) = A
(i
,j
) for 1<=i
<=j
;
38 * if UPLO
= 'L', AP
(i
+ (j
-1)*(2*n
-j
)/2) = A
(i
,j
) for j
<=i
<=n
.
39 * On exit
, if UPLO
= 'U', the diagonal and first superdiagonal
40 * of A are overwritten by the corresponding elements of the
41 * tridiagonal matrix T
, and the elements above the first
42 * superdiagonal
, with the array TAU
, represent the unitary
43 * matrix Q as a product of elementary reflectors
; if UPLO
44 * = 'L', the diagonal and first subdiagonal of A are over
-
45 * written by the corresponding elements of the tridiagonal
46 * matrix T
, and the elements below the first subdiagonal
, with
47 * the array TAU
, represent the unitary matrix Q as a product
48 * of elementary reflectors
. See Further Details
.
50 * D
(output
) DOUBLE PRECISION array
, dimension (N
)
51 * The diagonal elements of the tridiagonal matrix T
:
54 * E
(output
) DOUBLE PRECISION array
, dimension (N
-1)
55 * The off
-diagonal elements of the tridiagonal matrix T
:
56 * E
(i
) = A
(i
,i
+1) if UPLO
= 'U', E
(i
) = A
(i
+1,i
) if UPLO
= 'L'.
58 * TAU
(output
) COMPLEX*16 array
, dimension (N
-1)
59 * The scalar factors of the elementary reflectors
(see Further
62 * INFO
(output
) INTEGER
63 * = 0: successful exit
64 * < 0: if INFO
= -i
, the i
-th argument had an illegal value
69 * If UPLO
= 'U', the matrix Q is represented as a product of elementary
72 * Q
= H
(n
-1) . . . H
(2) H
(1).
74 * Each H
(i
) has the form
76 * H
(i
) = I
- tau
* v
* v
'
78 * where tau is a complex scalar, and v is a complex vector with
79 * v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in AP,
80 * overwriting A(1:i-1,i+1), and tau is stored in TAU(i).
82 * If UPLO = 'L
', the matrix Q is represented as a product of elementary
85 * Q = H(1) H(2) . . . H(n-1).
87 * Each H(i) has the form
89 * H(i) = I - tau * v * v'
91 * where tau is a
complex scalar
, and v is a
complex vector with
92 * v
(1:i
) = 0 and v
(i
+1) = 1; v
(i
+2:n
) is stored on exit in AP
,
93 * overwriting A
(i
+2:n
,i
), and tau is stored in TAU
(i
).
95 * =====================================================================
98 COMPLEX*16 ONE
, ZERO
, HALF
99 PARAMETER ( ONE
= ( 1.0D
+0, 0.0D
+0 ),
100 $ ZERO
= ( 0.0D
+0, 0.0D
+0 ),
101 $ HALF
= ( 0.5D
+0, 0.0D
+0 ) )
103 * .. Local Scalars
..
105 INTEGER I
, I1
, I1I1
, II
106 COMPLEX*16 ALPHA
, TAUI
108 * .. External Subroutines
..
109 EXTERNAL XERBLA
, ZAXPY
, ZHPMV
, ZHPR2
, ZLARFG
111 * .. External Functions
..
114 EXTERNAL LSAME
, ZDOTC
116 * .. Intrinsic Functions
..
119 * .. Executable Statements
..
121 * Test the input parameters
124 UPPER
= LSAME
( UPLO
, 'U' )
125 IF( .NOT
.UPPER
.AND
. .NOT
.LSAME
( UPLO
, 'L' ) ) THEN
127 ELSE IF( N
.LT
.0 ) THEN
131 CALL XERBLA
( 'ZHPTRD', -INFO
)
135 * Quick
return if possible
142 * Reduce the upper triangle of A
.
143 * I1 is the index in AP of A
(1,I
+1).
145 I1
= N*
( N
-1 ) / 2 + 1
146 AP
( I1
+N
-1 ) = DBLE
( AP
( I1
+N
-1 ) )
147 DO 10 I
= N
- 1, 1, -1
149 * Generate elementary reflector H
(i
) = I
- tau
* v
* v
'
150 * to annihilate A(1:i-1,i+1)
153 CALL ZLARFG( I, ALPHA, AP( I1 ), 1, TAUI )
156 IF( TAUI.NE.ZERO ) THEN
158 * Apply H(i) from both sides to A(1:i,1:i)
162 * Compute y := tau * A * v storing y in TAU(1:i)
164 CALL ZHPMV( UPLO, I, TAUI, AP, AP( I1 ), 1, ZERO, TAU,
167 * Compute w := y - 1/2 * tau * (y'*v
) * v
169 ALPHA
= -HALF*TAUI*ZDOTC
( I
, TAU
, 1, AP
( I1
), 1 )
170 CALL ZAXPY
( I
, ALPHA
, AP
( I1
), 1, TAU
, 1 )
172 * Apply the transformation as a rank
-2 update
:
173 * A
:= A
- v
* w
' - w * v'
175 CALL ZHPR2
( UPLO
, I
, -ONE
, AP
( I1
), 1, TAU
, 1, AP
)
178 AP
( I1
+I
-1 ) = E
( I
)
179 D
( I
+1 ) = AP
( I1
+I
)
186 * Reduce the lower triangle of A
. II is the index in AP of
187 * A
(i
,i
) and I1I1 is the index of A
(i
+1,i
+1).
190 AP
( 1 ) = DBLE
( AP
( 1 ) )
192 I1I1
= II
+ N
- I
+ 1
194 * Generate elementary reflector H
(i
) = I
- tau
* v
* v
'
195 * to annihilate A(i+2:n,i)
198 CALL ZLARFG( N-I, ALPHA, AP( II+2 ), 1, TAUI )
201 IF( TAUI.NE.ZERO ) THEN
203 * Apply H(i) from both sides to A(i+1:n,i+1:n)
207 * Compute y := tau * A * v storing y in TAU(i:n-1)
209 CALL ZHPMV( UPLO, N-I, TAUI, AP( I1I1 ), AP( II+1 ), 1,
210 $ ZERO, TAU( I ), 1 )
212 * Compute w := y - 1/2 * tau * (y'*v
) * v
214 ALPHA
= -HALF*TAUI*ZDOTC
( N
-I
, TAU
( I
), 1, AP
( II
+1 ),
216 CALL ZAXPY
( N
-I
, ALPHA
, AP
( II
+1 ), 1, TAU
( I
), 1 )
218 * Apply the transformation as a rank
-2 update
:
219 * A
:= A
- v
* w
' - w * v'
221 CALL ZHPR2
( UPLO
, N
-I
, -ONE
, AP
( II
+1 ), 1, TAU
( I
), 1,