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