LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ zhetrd()

subroutine zhetrd ( character uplo,
integer n,
complex*16, dimension( lda, * ) a,
integer lda,
double precision, dimension( * ) d,
double precision, dimension( * ) e,
complex*16, dimension( * ) tau,
complex*16, dimension( * ) work,
integer lwork,
integer info )

ZHETRD

Download ZHETRD + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> ZHETRD reduces a complex Hermitian matrix A to real symmetric
!> tridiagonal form T by a unitary similarity transformation:
!> Q**H * A * Q = T.
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          = 'U':  Upper triangle of A is stored;
!>          = 'L':  Lower triangle of A is stored.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in,out]A
!>          A is COMPLEX*16 array, dimension (LDA,N)
!>          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
!>          N-by-N upper triangular part of A contains the upper
!>          triangular part of the matrix A, and the strictly lower
!>          triangular part of A is not referenced.  If UPLO = 'L', the
!>          leading N-by-N lower triangular part of A contains the lower
!>          triangular part of the matrix A, and the strictly upper
!>          triangular part of A is not referenced.
!>          On exit, if UPLO = 'U', the diagonal and first superdiagonal
!>          of A are overwritten by the corresponding elements of the
!>          tridiagonal matrix T, and the elements above the first
!>          superdiagonal, with the array TAU, represent the unitary
!>          matrix Q as a product of elementary reflectors; if UPLO
!>          = 'L', the diagonal and first subdiagonal of A are over-
!>          written by the corresponding elements of the tridiagonal
!>          matrix T, and the elements below the first subdiagonal, with
!>          the array TAU, represent the unitary matrix Q as a product
!>          of elementary reflectors. See Further Details.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[out]D
!>          D is DOUBLE PRECISION array, dimension (N)
!>          The diagonal elements of the tridiagonal matrix T:
!>          D(i) = A(i,i).
!> 
[out]E
!>          E is DOUBLE PRECISION array, dimension (N-1)
!>          The off-diagonal elements of the tridiagonal matrix T:
!>          E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
!> 
[out]TAU
!>          TAU is COMPLEX*16 array, dimension (N-1)
!>          The scalar factors of the elementary reflectors (see Further
!>          Details).
!> 
[out]WORK
!>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.  LWORK >= 1.
!>          For optimum performance LWORK >= N*NB, where NB is the
!>          optimal blocksize.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  If UPLO = 'U', the matrix Q is represented as a product of elementary
!>  reflectors
!>
!>     Q = H(n-1) . . . H(2) H(1).
!>
!>  Each H(i) has the form
!>
!>     H(i) = I - tau * v * v**H
!>
!>  where tau is a complex scalar, and v is a complex vector with
!>  v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
!>  A(1:i-1,i+1), and tau in TAU(i).
!>
!>  If UPLO = 'L', the matrix Q is represented as a product of elementary
!>  reflectors
!>
!>     Q = H(1) H(2) . . . H(n-1).
!>
!>  Each H(i) has the form
!>
!>     H(i) = I - tau * v * v**H
!>
!>  where tau is a complex scalar, and v is a complex vector with
!>  v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
!>  and tau in TAU(i).
!>
!>  The contents of A on exit are illustrated by the following examples
!>  with n = 5:
!>
!>  if UPLO = 'U':                       if UPLO = 'L':
!>
!>    (  d   e   v2  v3  v4 )              (  d                  )
!>    (      d   e   v3  v4 )              (  e   d              )
!>    (          d   e   v4 )              (  v1  e   d          )
!>    (              d   e  )              (  v1  v2  e   d      )
!>    (                  d  )              (  v1  v2  v3  e   d  )
!>
!>  where d and e denote diagonal and off-diagonal elements of T, and vi
!>  denotes an element of the vector defining H(i).
!> 

Definition at line 189 of file zhetrd.f.

191*
192* -- LAPACK computational routine --
193* -- LAPACK is a software package provided by Univ. of Tennessee, --
194* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
195*
196* .. Scalar Arguments ..
197 CHARACTER UPLO
198 INTEGER INFO, LDA, LWORK, N
199* ..
200* .. Array Arguments ..
201 DOUBLE PRECISION D( * ), E( * )
202 COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
203* ..
204*
205* =====================================================================
206*
207* .. Parameters ..
208 DOUBLE PRECISION ONE
209 parameter( one = 1.0d+0 )
210 COMPLEX*16 CONE
211 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
212* ..
213* .. Local Scalars ..
214 LOGICAL LQUERY, UPPER
215 INTEGER I, IINFO, IWS, J, KK, LDWORK, LWKOPT, NB,
216 $ NBMIN, NX
217* ..
218* .. External Subroutines ..
219 EXTERNAL xerbla, zher2k, zhetd2, zlatrd
220* ..
221* .. Intrinsic Functions ..
222 INTRINSIC max
223* ..
224* .. External Functions ..
225 LOGICAL LSAME
226 INTEGER ILAENV
227 EXTERNAL lsame, ilaenv
228* ..
229* .. Executable Statements ..
230*
231* Test the input parameters
232*
233 info = 0
234 upper = lsame( uplo, 'U' )
235 lquery = ( lwork.EQ.-1 )
236 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
237 info = -1
238 ELSE IF( n.LT.0 ) THEN
239 info = -2
240 ELSE IF( lda.LT.max( 1, n ) ) THEN
241 info = -4
242 ELSE IF( lwork.LT.1 .AND. .NOT.lquery ) THEN
243 info = -9
244 END IF
245*
246 IF( info.EQ.0 ) THEN
247*
248* Determine the block size.
249*
250 nb = ilaenv( 1, 'ZHETRD', uplo, n, -1, -1, -1 )
251 lwkopt = max( 1, n*nb )
252 work( 1 ) = lwkopt
253 END IF
254*
255 IF( info.NE.0 ) THEN
256 CALL xerbla( 'ZHETRD', -info )
257 RETURN
258 ELSE IF( lquery ) THEN
259 RETURN
260 END IF
261*
262* Quick return if possible
263*
264 IF( n.EQ.0 ) THEN
265 work( 1 ) = 1
266 RETURN
267 END IF
268*
269 nx = n
270 iws = 1
271 IF( nb.GT.1 .AND. nb.LT.n ) THEN
272*
273* Determine when to cross over from blocked to unblocked code
274* (last block is always handled by unblocked code).
275*
276 nx = max( nb, ilaenv( 3, 'ZHETRD', uplo, n, -1, -1, -1 ) )
277 IF( nx.LT.n ) THEN
278*
279* Determine if workspace is large enough for blocked code.
280*
281 ldwork = n
282 iws = ldwork*nb
283 IF( lwork.LT.iws ) THEN
284*
285* Not enough workspace to use optimal NB: determine the
286* minimum value of NB, and reduce NB or force use of
287* unblocked code by setting NX = N.
288*
289 nb = max( lwork / ldwork, 1 )
290 nbmin = ilaenv( 2, 'ZHETRD', uplo, n, -1, -1, -1 )
291 IF( nb.LT.nbmin )
292 $ nx = n
293 END IF
294 ELSE
295 nx = n
296 END IF
297 ELSE
298 nb = 1
299 END IF
300*
301 IF( upper ) THEN
302*
303* Reduce the upper triangle of A.
304* Columns 1:kk are handled by the unblocked method.
305*
306 kk = n - ( ( n-nx+nb-1 ) / nb )*nb
307 DO 20 i = n - nb + 1, kk + 1, -nb
308*
309* Reduce columns i:i+nb-1 to tridiagonal form and form the
310* matrix W which is needed to update the unreduced part of
311* the matrix
312*
313 CALL zlatrd( uplo, i+nb-1, nb, a, lda, e, tau, work,
314 $ ldwork )
315*
316* Update the unreduced submatrix A(1:i-1,1:i-1), using an
317* update of the form: A := A - V*W**H - W*V**H
318*
319 CALL zher2k( uplo, 'No transpose', i-1, nb, -cone,
320 $ a( 1, i ), lda, work, ldwork, one, a, lda )
321*
322* Copy superdiagonal elements back into A, and diagonal
323* elements into D
324*
325 DO 10 j = i, i + nb - 1
326 a( j-1, j ) = e( j-1 )
327 d( j ) = dble( a( j, j ) )
328 10 CONTINUE
329 20 CONTINUE
330*
331* Use unblocked code to reduce the last or only block
332*
333 CALL zhetd2( uplo, kk, a, lda, d, e, tau, iinfo )
334 ELSE
335*
336* Reduce the lower triangle of A
337*
338 DO 40 i = 1, n - nx, nb
339*
340* Reduce columns i:i+nb-1 to tridiagonal form and form the
341* matrix W which is needed to update the unreduced part of
342* the matrix
343*
344 CALL zlatrd( uplo, n-i+1, nb, a( i, i ), lda, e( i ),
345 $ tau( i ), work, ldwork )
346*
347* Update the unreduced submatrix A(i+nb:n,i+nb:n), using
348* an update of the form: A := A - V*W**H - W*V**H
349*
350 CALL zher2k( uplo, 'No transpose', n-i-nb+1, nb, -cone,
351 $ a( i+nb, i ), lda, work( nb+1 ), ldwork, one,
352 $ a( i+nb, i+nb ), lda )
353*
354* Copy subdiagonal elements back into A, and diagonal
355* elements into D
356*
357 DO 30 j = i, i + nb - 1
358 a( j+1, j ) = e( j )
359 d( j ) = dble( a( j, j ) )
360 30 CONTINUE
361 40 CONTINUE
362*
363* Use unblocked code to reduce the last or only block
364*
365 CALL zhetd2( uplo, n-i+1, a( i, i ), lda, d( i ), e( i ),
366 $ tau( i ), iinfo )
367 END IF
368*
369 work( 1 ) = lwkopt
370 RETURN
371*
372* End of ZHETRD
373*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zher2k(uplo, trans, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZHER2K
Definition zher2k.f:198
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:173
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
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:197
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
Here is the call graph for this function:
Here is the caller graph for this function: