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

◆ zhpevd()

subroutine zhpevd ( character jobz,
character uplo,
integer n,
complex*16, dimension( * ) ap,
double precision, dimension( * ) w,
complex*16, dimension( ldz, * ) z,
integer ldz,
complex*16, dimension( * ) work,
integer lwork,
double precision, dimension( * ) rwork,
integer lrwork,
integer, dimension( * ) iwork,
integer liwork,
integer info )

ZHPEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices

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

Purpose:
!>
!> ZHPEVD computes all the eigenvalues and, optionally, eigenvectors of
!> a complex Hermitian matrix A in packed storage.  If eigenvectors are
!> desired, it uses a divide and conquer algorithm.
!>
!> 
Parameters
[in]JOBZ
!>          JOBZ is CHARACTER*1
!>          = 'N':  Compute eigenvalues only;
!>          = 'V':  Compute eigenvalues and eigenvectors.
!> 
[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]AP
!>          AP is COMPLEX*16 array, dimension (N*(N+1)/2)
!>          On entry, the upper or lower triangle of the Hermitian matrix
!>          A, packed columnwise in a linear array.  The j-th column of A
!>          is stored in the array AP as follows:
!>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
!>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
!>
!>          On exit, AP is overwritten by values generated during the
!>          reduction to tridiagonal form.  If UPLO = 'U', the diagonal
!>          and first superdiagonal of the tridiagonal matrix T overwrite
!>          the corresponding elements of A, and if UPLO = 'L', the
!>          diagonal and first subdiagonal of T overwrite the
!>          corresponding elements of A.
!> 
[out]W
!>          W is DOUBLE PRECISION array, dimension (N)
!>          If INFO = 0, the eigenvalues in ascending order.
!> 
[out]Z
!>          Z is COMPLEX*16 array, dimension (LDZ, N)
!>          If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
!>          eigenvectors of the matrix A, with the i-th column of Z
!>          holding the eigenvector associated with W(i).
!>          If JOBZ = 'N', then Z is not referenced.
!> 
[in]LDZ
!>          LDZ is INTEGER
!>          The leading dimension of the array Z.  LDZ >= 1, and if
!>          JOBZ = 'V', LDZ >= max(1,N).
!> 
[out]WORK
!>          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the required LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of array WORK.
!>          If N <= 1,               LWORK must be at least 1.
!>          If JOBZ = 'N' and N > 1, LWORK must be at least N.
!>          If JOBZ = 'V' and N > 1, LWORK must be at least 2*N.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the required sizes of the WORK, RWORK and
!>          IWORK arrays, returns these values as the first entries of
!>          the WORK, RWORK and IWORK arrays, and no error message
!>          related to LWORK or LRWORK or LIWORK is issued by XERBLA.
!> 
[out]RWORK
!>          RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK))
!>          On exit, if INFO = 0, RWORK(1) returns the required LRWORK.
!> 
[in]LRWORK
!>          LRWORK is INTEGER
!>          The dimension of array RWORK.
!>          If N <= 1,               LRWORK must be at least 1.
!>          If JOBZ = 'N' and N > 1, LRWORK must be at least N.
!>          If JOBZ = 'V' and N > 1, LRWORK must be at least
!>                    1 + 5*N + 2*N**2.
!>
!>          If LRWORK = -1, then a workspace query is assumed; the
!>          routine only calculates the required sizes of the WORK, RWORK
!>          and IWORK arrays, returns these values as the first entries
!>          of the WORK, RWORK and IWORK arrays, and no error message
!>          related to LWORK or LRWORK or LIWORK is issued by XERBLA.
!> 
[out]IWORK
!>          IWORK is INTEGER array, dimension (MAX(1,LIWORK))
!>          On exit, if INFO = 0, IWORK(1) returns the required LIWORK.
!> 
[in]LIWORK
!>          LIWORK is INTEGER
!>          The dimension of array IWORK.
!>          If JOBZ  = 'N' or N <= 1, LIWORK must be at least 1.
!>          If JOBZ  = 'V' and N > 1, LIWORK must be at least 3 + 5*N.
!>
!>          If LIWORK = -1, then a workspace query is assumed; the
!>          routine only calculates the required sizes of the WORK, RWORK
!>          and IWORK arrays, returns these values as the first entries
!>          of the WORK, RWORK and IWORK arrays, and no error message
!>          related to LWORK or LRWORK or LIWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value.
!>          > 0:  if INFO = i, the algorithm failed to converge; i
!>                off-diagonal elements of an intermediate tridiagonal
!>                form did not converge to zero.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 190 of file zhpevd.f.

192*
193* -- LAPACK driver 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 JOBZ, UPLO
199 INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N
200* ..
201* .. Array Arguments ..
202 INTEGER IWORK( * )
203 DOUBLE PRECISION RWORK( * ), W( * )
204 COMPLEX*16 AP( * ), WORK( * ), Z( LDZ, * )
205* ..
206*
207* =====================================================================
208*
209* .. Parameters ..
210 DOUBLE PRECISION ZERO, ONE
211 parameter( zero = 0.0d+0, one = 1.0d+0 )
212 COMPLEX*16 CONE
213 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
214* ..
215* .. Local Scalars ..
216 LOGICAL LQUERY, WANTZ
217 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWRK,
218 $ ISCALE, LIWMIN, LLRWK, LLWRK, LRWMIN, LWMIN
219 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
220 $ SMLNUM
221* ..
222* .. External Functions ..
223 LOGICAL LSAME
224 DOUBLE PRECISION DLAMCH, ZLANHP
225 EXTERNAL lsame, dlamch, zlanhp
226* ..
227* .. External Subroutines ..
228 EXTERNAL dscal, dsterf, xerbla, zdscal, zhptrd,
229 $ zstedc,
230 $ zupmtr
231* ..
232* .. Intrinsic Functions ..
233 INTRINSIC sqrt
234* ..
235* .. Executable Statements ..
236*
237* Test the input parameters.
238*
239 wantz = lsame( jobz, 'V' )
240 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
241*
242 info = 0
243 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
244 info = -1
245 ELSE IF( .NOT.( lsame( uplo, 'L' ) .OR.
246 $ lsame( uplo, 'U' ) ) )
247 $ THEN
248 info = -2
249 ELSE IF( n.LT.0 ) THEN
250 info = -3
251 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
252 info = -7
253 END IF
254*
255 IF( info.EQ.0 ) THEN
256 IF( n.LE.1 ) THEN
257 lwmin = 1
258 liwmin = 1
259 lrwmin = 1
260 ELSE
261 IF( wantz ) THEN
262 lwmin = 2*n
263 lrwmin = 1 + 5*n + 2*n**2
264 liwmin = 3 + 5*n
265 ELSE
266 lwmin = n
267 lrwmin = n
268 liwmin = 1
269 END IF
270 END IF
271 work( 1 ) = lwmin
272 rwork( 1 ) = real( lrwmin )
273 iwork( 1 ) = liwmin
274*
275 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
276 info = -9
277 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery ) THEN
278 info = -11
279 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
280 info = -13
281 END IF
282 END IF
283*
284 IF( info.NE.0 ) THEN
285 CALL xerbla( 'ZHPEVD', -info )
286 RETURN
287 ELSE IF( lquery ) THEN
288 RETURN
289 END IF
290*
291* Quick return if possible
292*
293 IF( n.EQ.0 )
294 $ RETURN
295*
296 IF( n.EQ.1 ) THEN
297 w( 1 ) = dble( ap( 1 ) )
298 IF( wantz )
299 $ z( 1, 1 ) = cone
300 RETURN
301 END IF
302*
303* Get machine constants.
304*
305 safmin = dlamch( 'Safe minimum' )
306 eps = dlamch( 'Precision' )
307 smlnum = safmin / eps
308 bignum = one / smlnum
309 rmin = sqrt( smlnum )
310 rmax = sqrt( bignum )
311*
312* Scale matrix to allowable range, if necessary.
313*
314 anrm = zlanhp( 'M', uplo, n, ap, rwork )
315 iscale = 0
316 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
317 iscale = 1
318 sigma = rmin / anrm
319 ELSE IF( anrm.GT.rmax ) THEN
320 iscale = 1
321 sigma = rmax / anrm
322 END IF
323 IF( iscale.EQ.1 ) THEN
324 CALL zdscal( ( n*( n+1 ) ) / 2, sigma, ap, 1 )
325 END IF
326*
327* Call ZHPTRD to reduce Hermitian packed matrix to tridiagonal form.
328*
329 inde = 1
330 indtau = 1
331 indrwk = inde + n
332 indwrk = indtau + n
333 llwrk = lwork - indwrk + 1
334 llrwk = lrwork - indrwk + 1
335 CALL zhptrd( uplo, n, ap, w, rwork( inde ), work( indtau ),
336 $ iinfo )
337*
338* For eigenvalues only, call DSTERF. For eigenvectors, first call
339* ZUPGTR to generate the orthogonal matrix, then call ZSTEDC.
340*
341 IF( .NOT.wantz ) THEN
342 CALL dsterf( n, w, rwork( inde ), info )
343 ELSE
344 CALL zstedc( 'I', n, w, rwork( inde ), z, ldz,
345 $ work( indwrk ),
346 $ llwrk, rwork( indrwk ), llrwk, iwork, liwork,
347 $ info )
348 CALL zupmtr( 'L', uplo, 'N', n, n, ap, work( indtau ), z,
349 $ ldz,
350 $ work( indwrk ), iinfo )
351 END IF
352*
353* If matrix was scaled, then rescale eigenvalues appropriately.
354*
355 IF( iscale.EQ.1 ) THEN
356 IF( info.EQ.0 ) THEN
357 imax = n
358 ELSE
359 imax = info - 1
360 END IF
361 CALL dscal( imax, one / sigma, w, 1 )
362 END IF
363*
364 work( 1 ) = lwmin
365 rwork( 1 ) = real( lrwmin )
366 iwork( 1 ) = liwmin
367 RETURN
368*
369* End of ZHPEVD
370*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zhptrd(uplo, n, ap, d, e, tau, info)
ZHPTRD
Definition zhptrd.f:149
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function zlanhp(norm, uplo, n, ap, work)
ZLANHP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition zlanhp.f:115
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zstedc(compz, n, d, e, z, ldz, work, lwork, rwork, lrwork, iwork, liwork, info)
ZSTEDC
Definition zstedc.f:204
subroutine dsterf(n, d, e, info)
DSTERF
Definition dsterf.f:84
subroutine zupmtr(side, uplo, trans, m, n, ap, tau, c, ldc, work, info)
ZUPMTR
Definition zupmtr.f:149
Here is the call graph for this function:
Here is the caller graph for this function: