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

◆ chbevd()

subroutine chbevd ( character jobz,
character uplo,
integer n,
integer kd,
complex, dimension( ldab, * ) ab,
integer ldab,
real, dimension( * ) w,
complex, dimension( ldz, * ) z,
integer ldz,
complex, dimension( * ) work,
integer lwork,
real, dimension( * ) rwork,
integer lrwork,
integer, dimension( * ) iwork,
integer liwork,
integer info )

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

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

Purpose:
!>
!> CHBEVD computes all the eigenvalues and, optionally, eigenvectors of
!> a complex Hermitian band matrix A.  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]KD
!>          KD is INTEGER
!>          The number of superdiagonals of the matrix A if UPLO = 'U',
!>          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
!> 
[in,out]AB
!>          AB is COMPLEX array, dimension (LDAB, N)
!>          On entry, the upper or lower triangle of the Hermitian band
!>          matrix A, stored in the first KD+1 rows of the array.  The
!>          j-th column of A is stored in the j-th column of the array AB
!>          as follows:
!>          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
!>          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
!>
!>          On exit, AB is overwritten by values generated during the
!>          reduction to tridiagonal form.  If UPLO = 'U', the first
!>          superdiagonal and the diagonal of the tridiagonal matrix T
!>          are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
!>          the diagonal and first subdiagonal of T are returned in the
!>          first two rows of AB.
!> 
[in]LDAB
!>          LDAB is INTEGER
!>          The leading dimension of the array AB.  LDAB >= KD + 1.
!> 
[out]W
!>          W is REAL array, dimension (N)
!>          If INFO = 0, the eigenvalues in ascending order.
!> 
[out]Z
!>          Z is COMPLEX 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 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 at least N.
!>          If JOBZ = 'V' and N > 1, LWORK must be at least 2*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 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 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 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, 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 205 of file chbevd.f.

208*
209* -- LAPACK driver routine --
210* -- LAPACK is a software package provided by Univ. of Tennessee, --
211* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
212*
213* .. Scalar Arguments ..
214 CHARACTER JOBZ, UPLO
215 INTEGER INFO, KD, LDAB, LDZ, LIWORK, LRWORK, LWORK, N
216* ..
217* .. Array Arguments ..
218 INTEGER IWORK( * )
219 REAL RWORK( * ), W( * )
220 COMPLEX AB( LDAB, * ), WORK( * ), Z( LDZ, * )
221* ..
222*
223* =====================================================================
224*
225* .. Parameters ..
226 REAL ZERO, ONE
227 parameter( zero = 0.0e0, one = 1.0e0 )
228 COMPLEX CZERO, CONE
229 parameter( czero = ( 0.0e0, 0.0e0 ),
230 $ cone = ( 1.0e0, 0.0e0 ) )
231* ..
232* .. Local Scalars ..
233 LOGICAL LOWER, LQUERY, WANTZ
234 INTEGER IINFO, IMAX, INDE, INDWK2, INDWRK, ISCALE,
235 $ LIWMIN, LLRWK, LLWK2, LRWMIN, LWMIN
236 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
237 $ SMLNUM
238* ..
239* .. External Functions ..
240 LOGICAL LSAME
241 REAL CLANHB, SLAMCH, SROUNDUP_LWORK
242 EXTERNAL lsame, clanhb, slamch,
244* ..
245* .. External Subroutines ..
246 EXTERNAL cgemm, chbtrd, clacpy, clascl, cstedc,
247 $ sscal,
248 $ ssterf, xerbla
249* ..
250* .. Intrinsic Functions ..
251 INTRINSIC sqrt
252* ..
253* .. Executable Statements ..
254*
255* Test the input parameters.
256*
257 wantz = lsame( jobz, 'V' )
258 lower = lsame( uplo, 'L' )
259 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 .OR. lrwork.EQ.-1 )
260*
261 info = 0
262 IF( n.LE.1 ) THEN
263 lwmin = 1
264 lrwmin = 1
265 liwmin = 1
266 ELSE
267 IF( wantz ) THEN
268 lwmin = 2*n**2
269 lrwmin = 1 + 5*n + 2*n**2
270 liwmin = 3 + 5*n
271 ELSE
272 lwmin = n
273 lrwmin = n
274 liwmin = 1
275 END IF
276 END IF
277 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
278 info = -1
279 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
280 info = -2
281 ELSE IF( n.LT.0 ) THEN
282 info = -3
283 ELSE IF( kd.LT.0 ) THEN
284 info = -4
285 ELSE IF( ldab.LT.kd+1 ) THEN
286 info = -6
287 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
288 info = -9
289 END IF
290*
291 IF( info.EQ.0 ) THEN
292 work( 1 ) = sroundup_lwork(lwmin)
293 rwork( 1 ) = real( lrwmin )
294 iwork( 1 ) = liwmin
295*
296 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
297 info = -11
298 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery ) THEN
299 info = -13
300 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
301 info = -15
302 END IF
303 END IF
304*
305 IF( info.NE.0 ) THEN
306 CALL xerbla( 'CHBEVD', -info )
307 RETURN
308 ELSE IF( lquery ) THEN
309 RETURN
310 END IF
311*
312* Quick return if possible
313*
314 IF( n.EQ.0 )
315 $ RETURN
316*
317 IF( n.EQ.1 ) THEN
318 w( 1 ) = real( ab( 1, 1 ) )
319 IF( wantz )
320 $ z( 1, 1 ) = cone
321 RETURN
322 END IF
323*
324* Get machine constants.
325*
326 safmin = slamch( 'Safe minimum' )
327 eps = slamch( 'Precision' )
328 smlnum = safmin / eps
329 bignum = one / smlnum
330 rmin = sqrt( smlnum )
331 rmax = sqrt( bignum )
332*
333* Scale matrix to allowable range, if necessary.
334*
335 anrm = clanhb( 'M', uplo, n, kd, ab, ldab, rwork )
336 iscale = 0
337 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
338 iscale = 1
339 sigma = rmin / anrm
340 ELSE IF( anrm.GT.rmax ) THEN
341 iscale = 1
342 sigma = rmax / anrm
343 END IF
344 IF( iscale.EQ.1 ) THEN
345 IF( lower ) THEN
346 CALL clascl( 'B', kd, kd, one, sigma, n, n, ab, ldab,
347 $ info )
348 ELSE
349 CALL clascl( 'Q', kd, kd, one, sigma, n, n, ab, ldab,
350 $ info )
351 END IF
352 END IF
353*
354* Call CHBTRD to reduce Hermitian band matrix to tridiagonal form.
355*
356 inde = 1
357 indwrk = inde + n
358 indwk2 = 1 + n*n
359 llwk2 = lwork - indwk2 + 1
360 llrwk = lrwork - indwrk + 1
361 CALL chbtrd( jobz, uplo, n, kd, ab, ldab, w, rwork( inde ), z,
362 $ ldz, work, iinfo )
363*
364* For eigenvalues only, call SSTERF. For eigenvectors, call CSTEDC.
365*
366 IF( .NOT.wantz ) THEN
367 CALL ssterf( n, w, rwork( inde ), info )
368 ELSE
369 CALL cstedc( 'I', n, w, rwork( inde ), work, n,
370 $ work( indwk2 ),
371 $ llwk2, rwork( indwrk ), llrwk, iwork, liwork,
372 $ info )
373 CALL cgemm( 'N', 'N', n, n, n, cone, z, ldz, work, n, czero,
374 $ work( indwk2 ), n )
375 CALL clacpy( 'A', n, n, work( indwk2 ), n, z, ldz )
376 END IF
377*
378* If matrix was scaled, then rescale eigenvalues appropriately.
379*
380 IF( iscale.EQ.1 ) THEN
381 IF( info.EQ.0 ) THEN
382 imax = n
383 ELSE
384 imax = info - 1
385 END IF
386 CALL sscal( imax, one / sigma, w, 1 )
387 END IF
388*
389 work( 1 ) = sroundup_lwork(lwmin)
390 rwork( 1 ) = real( lrwmin )
391 iwork( 1 ) = liwmin
392 RETURN
393*
394* End of CHBEVD
395*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
Definition cgemm.f:188
subroutine chbtrd(vect, uplo, n, kd, ab, ldab, d, e, q, ldq, work, info)
CHBTRD
Definition chbtrd.f:161
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:101
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
real function clanhb(norm, uplo, n, k, ab, ldab, work)
CLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition clanhb.f:130
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:142
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine cstedc(compz, n, d, e, z, ldz, work, lwork, rwork, lrwork, iwork, liwork, info)
CSTEDC
Definition cstedc.f:204
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
Here is the call graph for this function:
Here is the caller graph for this function: