OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
zhetrd.f
Go to the documentation of this file.
1*> \brief \b ZHETRD
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download ZHETRD + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetrd.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetrd.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetrd.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE ZHETRD( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )
22*
23* .. Scalar Arguments ..
24* CHARACTER UPLO
25* INTEGER INFO, LDA, LWORK, N
26* ..
27* .. Array Arguments ..
28* DOUBLE PRECISION D( * ), E( * )
29* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> ZHETRD reduces a complex Hermitian matrix A to real symmetric
39*> tridiagonal form T by a unitary similarity transformation:
40*> Q**H * A * Q = T.
41*> \endverbatim
42*
43* Arguments:
44* ==========
45*
46*> \param[in] UPLO
47*> \verbatim
48*> UPLO is CHARACTER*1
49*> = 'U': Upper triangle of A is stored;
50*> = 'L': Lower triangle of A is stored.
51*> \endverbatim
52*>
53*> \param[in] N
54*> \verbatim
55*> N is INTEGER
56*> The order of the matrix A. N >= 0.
57*> \endverbatim
58*>
59*> \param[in,out] A
60*> \verbatim
61*> A is COMPLEX*16 array, dimension (LDA,N)
62*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading
63*> N-by-N upper triangular part of A contains the upper
64*> triangular part of the matrix A, and the strictly lower
65*> triangular part of A is not referenced. If UPLO = 'L', the
66*> leading N-by-N lower triangular part of A contains the lower
67*> triangular part of the matrix A, and the strictly upper
68*> triangular part of A is not referenced.
69*> On exit, if UPLO = 'U', the diagonal and first superdiagonal
70*> of A are overwritten by the corresponding elements of the
71*> tridiagonal matrix T, and the elements above the first
72*> superdiagonal, with the array TAU, represent the unitary
73*> matrix Q as a product of elementary reflectors; if UPLO
74*> = 'L', the diagonal and first subdiagonal of A are over-
75*> written by the corresponding elements of the tridiagonal
76*> matrix T, and the elements below the first subdiagonal, with
77*> the array TAU, represent the unitary matrix Q as a product
78*> of elementary reflectors. See Further Details.
79*> \endverbatim
80*>
81*> \param[in] LDA
82*> \verbatim
83*> LDA is INTEGER
84*> The leading dimension of the array A. LDA >= max(1,N).
85*> \endverbatim
86*>
87*> \param[out] D
88*> \verbatim
89*> D is DOUBLE PRECISION array, dimension (N)
90*> The diagonal elements of the tridiagonal matrix T:
91*> D(i) = A(i,i).
92*> \endverbatim
93*>
94*> \param[out] E
95*> \verbatim
96*> E is DOUBLE PRECISION array, dimension (N-1)
97*> The off-diagonal elements of the tridiagonal matrix T:
98*> E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
99*> \endverbatim
100*>
101*> \param[out] TAU
102*> \verbatim
103*> TAU is COMPLEX*16 array, dimension (N-1)
104*> The scalar factors of the elementary reflectors (see Further
105*> Details).
106*> \endverbatim
107*>
108*> \param[out] WORK
109*> \verbatim
110*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
111*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
112*> \endverbatim
113*>
114*> \param[in] LWORK
115*> \verbatim
116*> LWORK is INTEGER
117*> The dimension of the array WORK. LWORK >= 1.
118*> For optimum performance LWORK >= N*NB, where NB is the
119*> optimal blocksize.
120*>
121*> If LWORK = -1, then a workspace query is assumed; the routine
122*> only calculates the optimal size of the WORK array, returns
123*> this value as the first entry of the WORK array, and no error
124*> message related to LWORK is issued by XERBLA.
125*> \endverbatim
126*>
127*> \param[out] INFO
128*> \verbatim
129*> INFO is INTEGER
130*> = 0: successful exit
131*> < 0: if INFO = -i, the i-th argument had an illegal value
132*> \endverbatim
133*
134* Authors:
135* ========
136*
137*> \author Univ. of Tennessee
138*> \author Univ. of California Berkeley
139*> \author Univ. of Colorado Denver
140*> \author NAG Ltd.
141*
142*> \ingroup complex16HEcomputational
143*
144*> \par Further Details:
145* =====================
146*>
147*> \verbatim
148*>
149*> If UPLO = 'U', the matrix Q is represented as a product of elementary
150*> reflectors
151*>
152*> Q = H(n-1) . . . H(2) H(1).
153*>
154*> Each H(i) has the form
155*>
156*> H(i) = I - tau * v * v**H
157*>
158*> where tau is a complex scalar, and v is a complex vector with
159*> v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
160*> A(1:i-1,i+1), and tau in TAU(i).
161*>
162*> If UPLO = 'L', the matrix Q is represented as a product of elementary
163*> reflectors
164*>
165*> Q = H(1) H(2) . . . H(n-1).
166*>
167*> Each H(i) has the form
168*>
169*> H(i) = I - tau * v * v**H
170*>
171*> where tau is a complex scalar, and v is a complex vector with
172*> v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
173*> and tau in TAU(i).
174*>
175*> The contents of A on exit are illustrated by the following examples
176*> with n = 5:
177*>
178*> if UPLO = 'U': if UPLO = 'L':
179*>
180*> ( d e v2 v3 v4 ) ( d )
181*> ( d e v3 v4 ) ( e d )
182*> ( d e v4 ) ( v1 e d )
183*> ( d e ) ( v1 v2 e d )
184*> ( d ) ( v1 v2 v3 e d )
185*>
186*> where d and e denote diagonal and off-diagonal elements of T, and vi
187*> denotes an element of the vector defining H(i).
188*> \endverbatim
189*>
190* =====================================================================
191 SUBROUTINE zhetrd( UPLO, N, A, LDA, D, E, TAU, WORK, LWORK, INFO )
192*
193* -- LAPACK computational routine --
194* -- LAPACK is a software package provided by Univ. of Tennessee, --
195* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
196*
197* .. Scalar Arguments ..
198 CHARACTER UPLO
199 INTEGER INFO, LDA, LWORK, N
200* ..
201* .. Array Arguments ..
202 DOUBLE PRECISION D( * ), E( * )
203 COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
204* ..
205*
206* =====================================================================
207*
208* .. Parameters ..
209 DOUBLE PRECISION ONE
210 parameter( one = 1.0d+0 )
211 COMPLEX*16 CONE
212 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
213* ..
214* .. Local Scalars ..
215 LOGICAL LQUERY, UPPER
216 INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB,
217 $ NBMIN, NX
218* ..
219* .. External Subroutines ..
220 EXTERNAL xerbla, zher2k, zhetd2, zlatrd
221* ..
222* .. Intrinsic Functions ..
223 INTRINSIC max
224* ..
225* .. External Functions ..
226 LOGICAL LSAME
227 INTEGER ILAENV
228 EXTERNAL lsame, ilaenv
229* ..
230* .. Executable Statements ..
231*
232* Test the input parameters
233*
234 info = 0
235 upper = lsame( uplo, 'u' )
236.EQ. LQUERY = ( LWORK-1 )
237.NOT..AND..NOT. IF( UPPER LSAME( UPLO, 'l' ) ) THEN
238 INFO = -1
239.LT. ELSE IF( N0 ) THEN
240 INFO = -2
241.LT. ELSE IF( LDAMAX( 1, N ) ) THEN
242 INFO = -4
243.LT..AND..NOT. ELSE IF( LWORK1 LQUERY ) THEN
244 INFO = -9
245 END IF
246*
247.EQ. IF( INFO0 ) THEN
248*
249* Determine the block size.
250*
251 NB = ILAENV( 1, 'zhetrd', UPLO, N, -1, -1, -1 )
252 LWKOPT = N*NB
253 WORK( 1 ) = LWKOPT
254 END IF
255*
256.NE. IF( INFO0 ) THEN
257 CALL XERBLA( 'zhetrd', -INFO )
258 RETURN
259 ELSE IF( LQUERY ) THEN
260 RETURN
261 END IF
262*
263* Quick return if possible
264*
265.EQ. IF( N0 ) THEN
266 WORK( 1 ) = 1
267 RETURN
268 END IF
269*
270 NX = N
271 IWS = 1
272.GT..AND..LT. IF( NB1 NBN ) THEN
273*
274* Determine when to cross over from blocked to unblocked code
275* (last block is always handled by unblocked code).
276*
277 NX = MAX( NB, ILAENV( 3, 'zhetrd', UPLO, N, -1, -1, -1 ) )
278.LT. IF( NXN ) THEN
279*
280* Determine if workspace is large enough for blocked code.
281*
282 LDWORK = N
283 IWS = LDWORK*NB
284.LT. IF( LWORKIWS ) THEN
285*
286* Not enough workspace to use optimal NB: determine the
287* minimum value of NB, and reduce NB or force use of
288* unblocked code by setting NX = N.
289*
290 NB = MAX( LWORK / LDWORK, 1 )
291 NBMIN = ILAENV( 2, 'zhetrd', UPLO, N, -1, -1, -1 )
292.LT. IF( NBNBMIN )
293 $ NX = N
294 END IF
295 ELSE
296 NX = N
297 END IF
298 ELSE
299 NB = 1
300 END IF
301*
302 IF( UPPER ) THEN
303*
304* Reduce the upper triangle of A.
305* Columns 1:kk are handled by the unblocked method.
306*
307 KK = N - ( ( N-NX+NB-1 ) / NB )*NB
308 DO 20 I = N - NB + 1, KK + 1, -NB
309*
310* Reduce columns i:i+nb-1 to tridiagonal form and form the
311* matrix W which is needed to update the unreduced part of
312* the matrix
313*
314 CALL ZLATRD( UPLO, I+NB-1, NB, A, LDA, E, TAU, WORK,
315 $ LDWORK )
316*
317* Update the unreduced submatrix A(1:i-1,1:i-1), using an
318* update of the form: A := A - V*W**H - W*V**H
319*
320 CALL ZHER2K( UPLO, 'no transpose', I-1, NB, -CONE,
321 $ A( 1, I ), LDA, WORK, LDWORK, ONE, A, LDA )
322*
323* Copy superdiagonal elements back into A, and diagonal
324* elements into D
325*
326 DO 10 J = I, I + NB - 1
327 A( J-1, J ) = E( J-1 )
328 D( J ) = DBLE( A( J, J ) )
329 10 CONTINUE
330 20 CONTINUE
331*
332* Use unblocked code to reduce the last or only block
333*
334 CALL ZHETD2( UPLO, KK, A, LDA, D, E, TAU, IINFO )
335 ELSE
336*
337* Reduce the lower triangle of A
338*
339 DO 40 I = 1, N - NX, NB
340*
341* Reduce columns i:i+nb-1 to tridiagonal form and form the
342* matrix W which is needed to update the unreduced part of
343* the matrix
344*
345 CALL ZLATRD( UPLO, N-I+1, NB, A( I, I ), LDA, E( I ),
346 $ TAU( I ), WORK, LDWORK )
347*
348* Update the unreduced submatrix A(i+nb:n,i+nb:n), using
349* an update of the form: A := A - V*W**H - W*V**H
350*
351 CALL ZHER2K( UPLO, 'no transpose', N-I-NB+1, NB, -CONE,
352 $ A( I+NB, I ), LDA, WORK( NB+1 ), LDWORK, ONE,
353 $ A( I+NB, I+NB ), LDA )
354*
355* Copy subdiagonal elements back into A, and diagonal
356* elements into D
357*
358 DO 30 J = I, I + NB - 1
359 A( J+1, J ) = E( J )
360 D( J ) = DBLE( A( J, J ) )
361 30 CONTINUE
362 40 CONTINUE
363*
364* Use unblocked code to reduce the last or only block
365*
366 CALL ZHETD2( UPLO, N-I+1, A( I, I ), LDA, D( I ), E( I ),
367 $ TAU( I ), IINFO )
368 END IF
369*
370 WORK( 1 ) = LWKOPT
371 RETURN
372*
373* End of ZHETRD
374*
375 END
subroutine xerbla(srname, info)
XERBLA
Definition xerbla.f:60
subroutine zhetd2(uplo, n, a, lda, d, e, tau, info)
ZHETD2 reduces a Hermitian matrix to real symmetric tridiagonal form by an unitary similarity transfo...
Definition zhetd2.f:175
subroutine zhetrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
ZHETRD
Definition zhetrd.f:192
subroutine zlatrd(uplo, n, nb, a, lda, e, tau, w, ldw)
ZLATRD reduces the first nb rows and columns of a symmetric/Hermitian matrix A to real tridiagonal fo...
Definition zlatrd.f:199
subroutine zher2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZHER2K
Definition zher2k.f:198
#define max(a, b)
Definition macros.h:21