LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ cheevd_2stage()

subroutine cheevd_2stage ( character  JOBZ,
character  UPLO,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
real, dimension( * )  W,
complex, dimension( * )  WORK,
integer  LWORK,
real, dimension( * )  RWORK,
integer  LRWORK,
integer, dimension( * )  IWORK,
integer  LIWORK,
integer  INFO 
)

CHEEVD_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices

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

Purpose:
 CHEEVD_2STAGE computes all eigenvalues and, optionally, eigenvectors of a
 complex Hermitian matrix A using the 2stage technique for
 the reduction to tridiagonal.  If eigenvectors are desired, it uses a
 divide and conquer algorithm.

 The divide and conquer algorithm makes very mild assumptions about
 floating point arithmetic. It will work on machines with a guard
 digit in add/subtract, or on those binary machines without guard
 digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
 Cray-2. It could conceivably fail on hexadecimal or decimal machines
 without guard digits, but we know of none.
Parameters
[in]JOBZ
          JOBZ is CHARACTER*1
          = 'N':  Compute eigenvalues only;
          = 'V':  Compute eigenvalues and eigenvectors.
                  Not available in this release.
[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 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.  If UPLO = 'L',
          the leading N-by-N lower triangular part of A contains
          the lower triangular part of the matrix A.
          On exit, if JOBZ = 'V', then if INFO = 0, A contains the
          orthonormal eigenvectors of the matrix A.
          If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
          or the upper triangle (if UPLO='U') of A, including the
          diagonal, is destroyed.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]W
          W is REAL array, dimension (N)
          If INFO = 0, the eigenvalues in ascending order.
[out]WORK
          WORK is COMPLEX 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.
          If N <= 1,               LWORK must be at least 1.
          If JOBZ = 'N' and N > 1, LWORK must be queried.
                                   LWORK = MAX(1, dimension) where
                                   dimension = max(stage1,stage2) + (KD+1)*N + N+1
                                             = N*KD + N*max(KD+1,FACTOPTNB) 
                                               + max(2*KD*KD, KD*NTHREADS) 
                                               + (KD+1)*N + N+1
                                   where KD is the blocking size of the reduction,
                                   FACTOPTNB is the blocking used by the QR or LQ
                                   algorithm, usually FACTOPTNB=128 is a good choice
                                   NTHREADS is the number of threads used when
                                   openMP compilation is enabled, otherwise =1.
          If JOBZ = 'V' and N > 1, LWORK must be at least 2*N + N**2

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal 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 REAL array,
                                         dimension (LRWORK)
          On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.
[in]LRWORK
          LRWORK is INTEGER
          The dimension of the 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 optimal 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 optimal LIWORK.
[in]LIWORK
          LIWORK is INTEGER
          The dimension of the array IWORK.
          If N <= 1,                LIWORK must be at least 1.
          If JOBZ  = 'N' and 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 optimal 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 and JOBZ = 'N', then the algorithm failed
                to converge; i off-diagonal elements of an intermediate
                tridiagonal form did not converge to zero;
                if INFO = i and JOBZ = 'V', then the algorithm failed
                to compute an eigenvalue while working on the submatrix
                lying in rows and columns INFO/(N+1) through
                mod(INFO,N+1).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2017
Further Details:
Modified description of INFO. Sven, 16 Feb 05.
Contributors:
Jeff Rutter, Computer Science Division, University of California at Berkeley, USA
Further Details:
  All details about the 2stage techniques are available in:

  Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
  Parallel reduction to condensed forms for symmetric eigenvalue problems
  using aggregated fine-grained and memory-aware kernels. In Proceedings
  of 2011 International Conference for High Performance Computing,
  Networking, Storage and Analysis (SC '11), New York, NY, USA,
  Article 8 , 11 pages.
  http://doi.acm.org/10.1145/2063384.2063394

  A. Haidar, J. Kurzak, P. Luszczek, 2013.
  An improved parallel singular value algorithm and its implementation 
  for multicore hardware, In Proceedings of 2013 International Conference
  for High Performance Computing, Networking, Storage and Analysis (SC '13).
  Denver, Colorado, USA, 2013.
  Article 90, 12 pages.
  http://doi.acm.org/10.1145/2503210.2503292

  A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
  A novel hybrid CPU-GPU generalized eigensolver for electronic structure 
  calculations based on fine-grained memory aware tasks.
  International Journal of High Performance Computing Applications.
  Volume 28 Issue 2, Pages 196-209, May 2014.
  http://hpc.sagepub.com/content/28/2/196 

Definition at line 255 of file cheevd_2stage.f.

255 *
256  IMPLICIT NONE
257 *
258 * -- LAPACK driver routine (version 3.8.0) --
259 * -- LAPACK is a software package provided by Univ. of Tennessee, --
260 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
261 * November 2017
262 *
263 * .. Scalar Arguments ..
264  CHARACTER JOBZ, UPLO
265  INTEGER INFO, LDA, LIWORK, LRWORK, LWORK, N
266 * ..
267 * .. Array Arguments ..
268  INTEGER IWORK( * )
269  REAL RWORK( * ), W( * )
270  COMPLEX A( LDA, * ), WORK( * )
271 * ..
272 *
273 * =====================================================================
274 *
275 * .. Parameters ..
276  REAL ZERO, ONE
277  parameter( zero = 0.0e0, one = 1.0e0 )
278  COMPLEX CONE
279  parameter( cone = ( 1.0e0, 0.0e0 ) )
280 * ..
281 * .. Local Scalars ..
282  LOGICAL LOWER, LQUERY, WANTZ
283  INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWK2,
284  $ INDWRK, ISCALE, LIWMIN, LLRWK, LLWORK,
285  $ LLWRK2, LRWMIN, LWMIN,
286  $ LHTRD, LWTRD, KD, IB, INDHOUS
287 
288 
289  REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
290  $ SMLNUM
291 * ..
292 * .. External Functions ..
293  LOGICAL LSAME
294  INTEGER ILAENV2STAGE
295  REAL SLAMCH, CLANHE
296  EXTERNAL lsame, slamch, clanhe, ilaenv2stage
297 * ..
298 * .. External Subroutines ..
299  EXTERNAL sscal, ssterf, xerbla, clacpy, clascl,
301 * ..
302 * .. Intrinsic Functions ..
303  INTRINSIC real, max, sqrt
304 * ..
305 * .. Executable Statements ..
306 *
307 * Test the input parameters.
308 *
309  wantz = lsame( jobz, 'V' )
310  lower = lsame( uplo, 'L' )
311  lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
312 *
313  info = 0
314  IF( .NOT.( lsame( jobz, 'N' ) ) ) THEN
315  info = -1
316  ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
317  info = -2
318  ELSE IF( n.LT.0 ) THEN
319  info = -3
320  ELSE IF( lda.LT.max( 1, n ) ) THEN
321  info = -5
322  END IF
323 *
324  IF( info.EQ.0 ) THEN
325  IF( n.LE.1 ) THEN
326  lwmin = 1
327  lrwmin = 1
328  liwmin = 1
329  ELSE
330  kd = ilaenv2stage( 1, 'CHETRD_2STAGE', jobz,
331  $ n, -1, -1, -1 )
332  ib = ilaenv2stage( 2, 'CHETRD_2STAGE', jobz,
333  $ n, kd, -1, -1 )
334  lhtrd = ilaenv2stage( 3, 'CHETRD_2STAGE', jobz,
335  $ n, kd, ib, -1 )
336  lwtrd = ilaenv2stage( 4, 'CHETRD_2STAGE', jobz,
337  $ n, kd, ib, -1 )
338  IF( wantz ) THEN
339  lwmin = 2*n + n*n
340  lrwmin = 1 + 5*n + 2*n**2
341  liwmin = 3 + 5*n
342  ELSE
343  lwmin = n + 1 + lhtrd + lwtrd
344  lrwmin = n
345  liwmin = 1
346  END IF
347  END IF
348  work( 1 ) = lwmin
349  rwork( 1 ) = lrwmin
350  iwork( 1 ) = liwmin
351 *
352  IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
353  info = -8
354  ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery ) THEN
355  info = -10
356  ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
357  info = -12
358  END IF
359  END IF
360 *
361  IF( info.NE.0 ) THEN
362  CALL xerbla( 'CHEEVD_2STAGE', -info )
363  RETURN
364  ELSE IF( lquery ) THEN
365  RETURN
366  END IF
367 *
368 * Quick return if possible
369 *
370  IF( n.EQ.0 )
371  $ RETURN
372 *
373  IF( n.EQ.1 ) THEN
374  w( 1 ) = real( a( 1, 1 ) )
375  IF( wantz )
376  $ a( 1, 1 ) = cone
377  RETURN
378  END IF
379 *
380 * Get machine constants.
381 *
382  safmin = slamch( 'Safe minimum' )
383  eps = slamch( 'Precision' )
384  smlnum = safmin / eps
385  bignum = one / smlnum
386  rmin = sqrt( smlnum )
387  rmax = sqrt( bignum )
388 *
389 * Scale matrix to allowable range, if necessary.
390 *
391  anrm = clanhe( 'M', uplo, n, a, lda, rwork )
392  iscale = 0
393  IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
394  iscale = 1
395  sigma = rmin / anrm
396  ELSE IF( anrm.GT.rmax ) THEN
397  iscale = 1
398  sigma = rmax / anrm
399  END IF
400  IF( iscale.EQ.1 )
401  $ CALL clascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
402 *
403 * Call CHETRD_2STAGE to reduce Hermitian matrix to tridiagonal form.
404 *
405  inde = 1
406  indrwk = inde + n
407  llrwk = lrwork - indrwk + 1
408  indtau = 1
409  indhous = indtau + n
410  indwrk = indhous + lhtrd
411  llwork = lwork - indwrk + 1
412  indwk2 = indwrk + n*n
413  llwrk2 = lwork - indwk2 + 1
414 *
415  CALL chetrd_2stage( jobz, uplo, n, a, lda, w, rwork( inde ),
416  $ work( indtau ), work( indhous ), lhtrd,
417  $ work( indwrk ), llwork, iinfo )
418 *
419 * For eigenvalues only, call SSTERF. For eigenvectors, first call
420 * CSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the
421 * tridiagonal matrix, then call CUNMTR to multiply it to the
422 * Householder transformations represented as Householder vectors in
423 * A.
424 *
425  IF( .NOT.wantz ) THEN
426  CALL ssterf( n, w, rwork( inde ), info )
427  ELSE
428  CALL cstedc( 'I', n, w, rwork( inde ), work( indwrk ), n,
429  $ work( indwk2 ), llwrk2, rwork( indrwk ), llrwk,
430  $ iwork, liwork, info )
431  CALL cunmtr( 'L', uplo, 'N', n, n, a, lda, work( indtau ),
432  $ work( indwrk ), n, work( indwk2 ), llwrk2, iinfo )
433  CALL clacpy( 'A', n, n, work( indwrk ), n, a, lda )
434  END IF
435 *
436 * If matrix was scaled, then rescale eigenvalues appropriately.
437 *
438  IF( iscale.EQ.1 ) THEN
439  IF( info.EQ.0 ) THEN
440  imax = n
441  ELSE
442  imax = info - 1
443  END IF
444  CALL sscal( imax, one / sigma, w, 1 )
445  END IF
446 *
447  work( 1 ) = lwmin
448  rwork( 1 ) = lrwmin
449  iwork( 1 ) = liwmin
450 *
451  RETURN
452 *
453 * End of CHEEVD_2STAGE
454 *
Here is the call graph for this function:
Here is the caller graph for this function:
cstedc
subroutine cstedc(COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO)
CSTEDC
Definition: cstedc.f:214
clacpy
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
ssterf
subroutine ssterf(N, D, E, INFO)
SSTERF
Definition: ssterf.f:88
sscal
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:81
chetrd_2stage
subroutine chetrd_2stage(VECT, UPLO, N, A, LDA, D, E, TAU, HOUS2, LHOUS2, WORK, LWORK, INFO)
CHETRD_2STAGE
Definition: chetrd_2stage.f:226
clanhe
real function clanhe(NORM, UPLO, N, A, LDA, WORK)
CLANHE returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clanhe.f:126
xerbla
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
slamch
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:70
cunmtr
subroutine cunmtr(SIDE, UPLO, TRANS, M, N, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMTR
Definition: cunmtr.f:174
ilaenv2stage
integer function ilaenv2stage(ISPEC, NAME, OPTS, N1, N2, N3, N4)
ILAENV2STAGE
Definition: ilaenv2stage.f:151
clascl
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: clascl.f:145