LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zhbevd.f
Go to the documentation of this file.
1*> \brief <b> ZHBEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHBEVD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhbevd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhbevd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhbevd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHBEVD( JOBZ, UPLO, N, KD, AB, LDAB, W, Z, LDZ, WORK,
20* LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ, UPLO
24* INTEGER INFO, KD, LDAB, LDZ, LIWORK, LRWORK, LWORK, N
25* ..
26* .. Array Arguments ..
27* INTEGER IWORK( * )
28* DOUBLE PRECISION RWORK( * ), W( * )
29* COMPLEX*16 AB( LDAB, * ), WORK( * ), Z( LDZ, * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> ZHBEVD computes all the eigenvalues and, optionally, eigenvectors of
39*> a complex Hermitian band matrix A. If eigenvectors are desired, it
40*> uses a divide and conquer algorithm.
41*>
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] JOBZ
48*> \verbatim
49*> JOBZ is CHARACTER*1
50*> = 'N': Compute eigenvalues only;
51*> = 'V': Compute eigenvalues and eigenvectors.
52*> \endverbatim
53*>
54*> \param[in] UPLO
55*> \verbatim
56*> UPLO is CHARACTER*1
57*> = 'U': Upper triangle of A is stored;
58*> = 'L': Lower triangle of A is stored.
59*> \endverbatim
60*>
61*> \param[in] N
62*> \verbatim
63*> N is INTEGER
64*> The order of the matrix A. N >= 0.
65*> \endverbatim
66*>
67*> \param[in] KD
68*> \verbatim
69*> KD is INTEGER
70*> The number of superdiagonals of the matrix A if UPLO = 'U',
71*> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
72*> \endverbatim
73*>
74*> \param[in,out] AB
75*> \verbatim
76*> AB is COMPLEX*16 array, dimension (LDAB, N)
77*> On entry, the upper or lower triangle of the Hermitian band
78*> matrix A, stored in the first KD+1 rows of the array. The
79*> j-th column of A is stored in the j-th column of the array AB
80*> as follows:
81*> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
82*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
83*>
84*> On exit, AB is overwritten by values generated during the
85*> reduction to tridiagonal form. If UPLO = 'U', the first
86*> superdiagonal and the diagonal of the tridiagonal matrix T
87*> are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
88*> the diagonal and first subdiagonal of T are returned in the
89*> first two rows of AB.
90*> \endverbatim
91*>
92*> \param[in] LDAB
93*> \verbatim
94*> LDAB is INTEGER
95*> The leading dimension of the array AB. LDAB >= KD + 1.
96*> \endverbatim
97*>
98*> \param[out] W
99*> \verbatim
100*> W is DOUBLE PRECISION array, dimension (N)
101*> If INFO = 0, the eigenvalues in ascending order.
102*> \endverbatim
103*>
104*> \param[out] Z
105*> \verbatim
106*> Z is COMPLEX*16 array, dimension (LDZ, N)
107*> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
108*> eigenvectors of the matrix A, with the i-th column of Z
109*> holding the eigenvector associated with W(i).
110*> If JOBZ = 'N', then Z is not referenced.
111*> \endverbatim
112*>
113*> \param[in] LDZ
114*> \verbatim
115*> LDZ is INTEGER
116*> The leading dimension of the array Z. LDZ >= 1, and if
117*> JOBZ = 'V', LDZ >= max(1,N).
118*> \endverbatim
119*>
120*> \param[out] WORK
121*> \verbatim
122*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
123*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
124*> \endverbatim
125*>
126*> \param[in] LWORK
127*> \verbatim
128*> LWORK is INTEGER
129*> The dimension of the array WORK.
130*> If N <= 1, LWORK must be at least 1.
131*> If JOBZ = 'N' and N > 1, LWORK must be at least N.
132*> If JOBZ = 'V' and N > 1, LWORK must be at least 2*N**2.
133*>
134*> If LWORK = -1, then a workspace query is assumed; the routine
135*> only calculates the optimal sizes of the WORK, RWORK and
136*> IWORK arrays, returns these values as the first entries of
137*> the WORK, RWORK and IWORK arrays, and no error message
138*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
139*> \endverbatim
140*>
141*> \param[out] RWORK
142*> \verbatim
143*> RWORK is DOUBLE PRECISION array,
144*> dimension (LRWORK)
145*> On exit, if INFO = 0, RWORK(1) returns the optimal LRWORK.
146*> \endverbatim
147*>
148*> \param[in] LRWORK
149*> \verbatim
150*> LRWORK is INTEGER
151*> The dimension of array RWORK.
152*> If N <= 1, LRWORK must be at least 1.
153*> If JOBZ = 'N' and N > 1, LRWORK must be at least N.
154*> If JOBZ = 'V' and N > 1, LRWORK must be at least
155*> 1 + 5*N + 2*N**2.
156*>
157*> If LRWORK = -1, then a workspace query is assumed; the
158*> routine only calculates the optimal sizes of the WORK, RWORK
159*> and IWORK arrays, returns these values as the first entries
160*> of the WORK, RWORK and IWORK arrays, and no error message
161*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
162*> \endverbatim
163*>
164*> \param[out] IWORK
165*> \verbatim
166*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
167*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
168*> \endverbatim
169*>
170*> \param[in] LIWORK
171*> \verbatim
172*> LIWORK is INTEGER
173*> The dimension of array IWORK.
174*> If JOBZ = 'N' or N <= 1, LIWORK must be at least 1.
175*> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N .
176*>
177*> If LIWORK = -1, then a workspace query is assumed; the
178*> routine only calculates the optimal sizes of the WORK, RWORK
179*> and IWORK arrays, returns these values as the first entries
180*> of the WORK, RWORK and IWORK arrays, and no error message
181*> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
182*> \endverbatim
183*>
184*> \param[out] INFO
185*> \verbatim
186*> INFO is INTEGER
187*> = 0: successful exit.
188*> < 0: if INFO = -i, the i-th argument had an illegal value.
189*> > 0: if INFO = i, the algorithm failed to converge; i
190*> off-diagonal elements of an intermediate tridiagonal
191*> form did not converge to zero.
192*> \endverbatim
193*
194* Authors:
195* ========
196*
197*> \author Univ. of Tennessee
198*> \author Univ. of California Berkeley
199*> \author Univ. of Colorado Denver
200*> \author NAG Ltd.
201*
202*> \ingroup hbevd
203*
204* =====================================================================
205 SUBROUTINE zhbevd( JOBZ, UPLO, N, KD, AB, LDAB, W, Z, LDZ,
206 $ WORK,
207 $ LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO )
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 DOUBLE PRECISION RWORK( * ), W( * )
220 COMPLEX*16 AB( LDAB, * ), WORK( * ), Z( LDZ, * )
221* ..
222*
223* =====================================================================
224*
225* .. Parameters ..
226 DOUBLE PRECISION ZERO, ONE
227 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
228 COMPLEX*16 CZERO, CONE
229 parameter( czero = ( 0.0d0, 0.0d0 ),
230 $ cone = ( 1.0d0, 0.0d0 ) )
231* ..
232* .. Local Scalars ..
233 LOGICAL LOWER, LQUERY, WANTZ
234 INTEGER IINFO, IMAX, INDE, INDWK2, INDWRK, ISCALE,
235 $ liwmin, llrwk, llwk2, lrwmin, lwmin
236 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
237 $ SMLNUM
238* ..
239* .. External Functions ..
240 LOGICAL LSAME
241 DOUBLE PRECISION DLAMCH, ZLANHB
242 EXTERNAL lsame, dlamch, zlanhb
243* ..
244* .. External Subroutines ..
245 EXTERNAL dscal, dsterf, xerbla, zgemm, zhbtrd,
246 $ zlacpy,
247 $ zlascl, zstedc
248* ..
249* .. Intrinsic Functions ..
250 INTRINSIC sqrt
251* ..
252* .. Executable Statements ..
253*
254* Test the input parameters.
255*
256 wantz = lsame( jobz, 'V' )
257 lower = lsame( uplo, 'L' )
258 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 .OR. lrwork.EQ.-1 )
259*
260 info = 0
261 IF( n.LE.1 ) THEN
262 lwmin = 1
263 lrwmin = 1
264 liwmin = 1
265 ELSE
266 IF( wantz ) THEN
267 lwmin = 2*n**2
268 lrwmin = 1 + 5*n + 2*n**2
269 liwmin = 3 + 5*n
270 ELSE
271 lwmin = n
272 lrwmin = n
273 liwmin = 1
274 END IF
275 END IF
276 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
277 info = -1
278 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
279 info = -2
280 ELSE IF( n.LT.0 ) THEN
281 info = -3
282 ELSE IF( kd.LT.0 ) THEN
283 info = -4
284 ELSE IF( ldab.LT.kd+1 ) THEN
285 info = -6
286 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
287 info = -9
288 END IF
289*
290 IF( info.EQ.0 ) THEN
291 work( 1 ) = lwmin
292 rwork( 1 ) = real( lrwmin )
293 iwork( 1 ) = liwmin
294*
295 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
296 info = -11
297 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery ) THEN
298 info = -13
299 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
300 info = -15
301 END IF
302 END IF
303*
304 IF( info.NE.0 ) THEN
305 CALL xerbla( 'ZHBEVD', -info )
306 RETURN
307 ELSE IF( lquery ) THEN
308 RETURN
309 END IF
310*
311* Quick return if possible
312*
313 IF( n.EQ.0 )
314 $ RETURN
315*
316 IF( n.EQ.1 ) THEN
317 w( 1 ) = dble( ab( 1, 1 ) )
318 IF( wantz )
319 $ z( 1, 1 ) = cone
320 RETURN
321 END IF
322*
323* Get machine constants.
324*
325 safmin = dlamch( 'Safe minimum' )
326 eps = dlamch( 'Precision' )
327 smlnum = safmin / eps
328 bignum = one / smlnum
329 rmin = sqrt( smlnum )
330 rmax = sqrt( bignum )
331*
332* Scale matrix to allowable range, if necessary.
333*
334 anrm = zlanhb( 'M', uplo, n, kd, ab, ldab, rwork )
335 iscale = 0
336 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
337 iscale = 1
338 sigma = rmin / anrm
339 ELSE IF( anrm.GT.rmax ) THEN
340 iscale = 1
341 sigma = rmax / anrm
342 END IF
343 IF( iscale.EQ.1 ) THEN
344 IF( lower ) THEN
345 CALL zlascl( 'B', kd, kd, one, sigma, n, n, ab, ldab,
346 $ info )
347 ELSE
348 CALL zlascl( 'Q', kd, kd, one, sigma, n, n, ab, ldab,
349 $ info )
350 END IF
351 END IF
352*
353* Call ZHBTRD to reduce Hermitian band matrix to tridiagonal form.
354*
355 inde = 1
356 indwrk = inde + n
357 indwk2 = 1 + n*n
358 llwk2 = lwork - indwk2 + 1
359 llrwk = lrwork - indwrk + 1
360 CALL zhbtrd( jobz, uplo, n, kd, ab, ldab, w, rwork( inde ), z,
361 $ ldz, work, iinfo )
362*
363* For eigenvalues only, call DSTERF. For eigenvectors, call ZSTEDC.
364*
365 IF( .NOT.wantz ) THEN
366 CALL dsterf( n, w, rwork( inde ), info )
367 ELSE
368 CALL zstedc( 'I', n, w, rwork( inde ), work, n,
369 $ work( indwk2 ),
370 $ llwk2, rwork( indwrk ), llrwk, iwork, liwork,
371 $ info )
372 CALL zgemm( 'N', 'N', n, n, n, cone, z, ldz, work, n, czero,
373 $ work( indwk2 ), n )
374 CALL zlacpy( 'A', n, n, work( indwk2 ), n, z, ldz )
375 END IF
376*
377* If matrix was scaled, then rescale eigenvalues appropriately.
378*
379 IF( iscale.EQ.1 ) THEN
380 IF( info.EQ.0 ) THEN
381 imax = n
382 ELSE
383 imax = info - 1
384 END IF
385 CALL dscal( imax, one / sigma, w, 1 )
386 END IF
387*
388 work( 1 ) = lwmin
389 rwork( 1 ) = real( lrwmin )
390 iwork( 1 ) = liwmin
391 RETURN
392*
393* End of ZHBEVD
394*
395 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
Definition zgemm.f:188
subroutine zhbevd(jobz, uplo, n, kd, ab, ldab, w, z, ldz, work, lwork, rwork, lrwork, iwork, liwork, info)
ZHBEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrice...
Definition zhbevd.f:208
subroutine zhbtrd(vect, uplo, n, kd, ab, ldab, d, e, q, ldq, work, info)
ZHBTRD
Definition zhbtrd.f:161
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
Definition zlacpy.f:101
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition zlascl.f:142
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
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