LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dsyevd.f
Go to the documentation of this file.
1*> \brief <b> DSYEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DSYEVD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsyevd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsyevd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsyevd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DSYEVD( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK, IWORK,
20* LIWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ, UPLO
24* INTEGER INFO, LDA, LIWORK, LWORK, N
25* ..
26* .. Array Arguments ..
27* INTEGER IWORK( * )
28* DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> DSYEVD computes all eigenvalues and, optionally, eigenvectors of a
38*> real symmetric matrix A. If eigenvectors are desired, it uses a
39*> divide and conquer algorithm.
40*>
41*> Because of large use of BLAS of level 3, DSYEVD needs N**2 more
42*> workspace than DSYEVX.
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,out] A
69*> \verbatim
70*> A is DOUBLE PRECISION array, dimension (LDA, N)
71*> On entry, the symmetric matrix A. If UPLO = 'U', the
72*> leading N-by-N upper triangular part of A contains the
73*> upper triangular part of the matrix A. If UPLO = 'L',
74*> the leading N-by-N lower triangular part of A contains
75*> the lower triangular part of the matrix A.
76*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
77*> orthonormal eigenvectors of the matrix A.
78*> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
79*> or the upper triangle (if UPLO='U') of A, including the
80*> diagonal, is destroyed.
81*> \endverbatim
82*>
83*> \param[in] LDA
84*> \verbatim
85*> LDA is INTEGER
86*> The leading dimension of the array A. LDA >= max(1,N).
87*> \endverbatim
88*>
89*> \param[out] W
90*> \verbatim
91*> W is DOUBLE PRECISION array, dimension (N)
92*> If INFO = 0, the eigenvalues in ascending order.
93*> \endverbatim
94*>
95*> \param[out] WORK
96*> \verbatim
97*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
98*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
99*> \endverbatim
100*>
101*> \param[in] LWORK
102*> \verbatim
103*> LWORK is INTEGER
104*> The dimension of the array WORK.
105*> If N <= 1, LWORK must be at least 1.
106*> If JOBZ = 'N' and N > 1, LWORK must be at least 2*N+1.
107*> If JOBZ = 'V' and N > 1, LWORK must be at least
108*> 1 + 6*N + 2*N**2.
109*>
110*> If LWORK = -1, then a workspace query is assumed; the routine
111*> only calculates the optimal sizes of the WORK and IWORK
112*> arrays, returns these values as the first entries of the WORK
113*> and IWORK arrays, and no error message related to LWORK or
114*> LIWORK is issued by XERBLA.
115*> \endverbatim
116*>
117*> \param[out] IWORK
118*> \verbatim
119*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
120*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
121*> \endverbatim
122*>
123*> \param[in] LIWORK
124*> \verbatim
125*> LIWORK is INTEGER
126*> The dimension of the array IWORK.
127*> If N <= 1, LIWORK must be at least 1.
128*> If JOBZ = 'N' and N > 1, LIWORK must be at least 1.
129*> If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N.
130*>
131*> If LIWORK = -1, then a workspace query is assumed; the
132*> routine only calculates the optimal sizes of the WORK and
133*> IWORK arrays, returns these values as the first entries of
134*> the WORK and IWORK arrays, and no error message related to
135*> LWORK or LIWORK is issued by XERBLA.
136*> \endverbatim
137*>
138*> \param[out] INFO
139*> \verbatim
140*> INFO is INTEGER
141*> = 0: successful exit
142*> < 0: if INFO = -i, the i-th argument had an illegal value
143*> > 0: if INFO = i and JOBZ = 'N', then the algorithm failed
144*> to converge; i off-diagonal elements of an intermediate
145*> tridiagonal form did not converge to zero;
146*> if INFO = i and JOBZ = 'V', then the algorithm failed
147*> to compute an eigenvalue while working on the submatrix
148*> lying in rows and columns INFO/(N+1) through
149*> mod(INFO,N+1).
150*> \endverbatim
151*
152* Authors:
153* ========
154*
155*> \author Univ. of Tennessee
156*> \author Univ. of California Berkeley
157*> \author Univ. of Colorado Denver
158*> \author NAG Ltd.
159*
160*> \ingroup heevd
161*
162*> \par Contributors:
163* ==================
164*>
165*> Jeff Rutter, Computer Science Division, University of California
166*> at Berkeley, USA \n
167*> Modified by Francoise Tisseur, University of Tennessee \n
168*> Modified description of INFO. Sven, 16 Feb 05. \n
169
170
171*>
172* =====================================================================
173 SUBROUTINE dsyevd( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK,
174 $ IWORK,
175 $ LIWORK, INFO )
176*
177* -- LAPACK driver routine --
178* -- LAPACK is a software package provided by Univ. of Tennessee, --
179* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
180*
181* .. Scalar Arguments ..
182 CHARACTER JOBZ, UPLO
183 INTEGER INFO, LDA, LIWORK, LWORK, N
184* ..
185* .. Array Arguments ..
186 INTEGER IWORK( * )
187 DOUBLE PRECISION A( LDA, * ), W( * ), WORK( * )
188* ..
189*
190* =====================================================================
191*
192* .. Parameters ..
193 DOUBLE PRECISION ZERO, ONE
194 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0 )
195* ..
196* .. Local Scalars ..
197*
198 LOGICAL LOWER, LQUERY, WANTZ
199 INTEGER IINFO, INDE, INDTAU, INDWK2, INDWRK, ISCALE,
200 $ liopt, liwmin, llwork, llwrk2, lopt, lwmin
201 DOUBLE PRECISION ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
202 $ SMLNUM
203* ..
204* .. External Functions ..
205 LOGICAL LSAME
206 INTEGER ILAENV
207 DOUBLE PRECISION DLAMCH, DLANSY
208 EXTERNAL lsame, dlamch, dlansy, ilaenv
209* ..
210* .. External Subroutines ..
211 EXTERNAL dlacpy, dlascl, dormtr, dscal, dstedc,
212 $ dsterf,
213 $ dsytrd, xerbla
214* ..
215* .. Intrinsic Functions ..
216 INTRINSIC max, sqrt
217* ..
218* .. Executable Statements ..
219*
220* Test the input parameters.
221*
222 wantz = lsame( jobz, 'V' )
223 lower = lsame( uplo, 'L' )
224 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
225*
226 info = 0
227 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
228 info = -1
229 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
230 info = -2
231 ELSE IF( n.LT.0 ) THEN
232 info = -3
233 ELSE IF( lda.LT.max( 1, n ) ) THEN
234 info = -5
235 END IF
236*
237 IF( info.EQ.0 ) THEN
238 IF( n.LE.1 ) THEN
239 liwmin = 1
240 lwmin = 1
241 lopt = lwmin
242 liopt = liwmin
243 ELSE
244 IF( wantz ) THEN
245 liwmin = 3 + 5*n
246 lwmin = 1 + 6*n + 2*n**2
247 ELSE
248 liwmin = 1
249 lwmin = 2*n + 1
250 END IF
251 lopt = max( lwmin, 2*n +
252 $ n*ilaenv( 1, 'DSYTRD', uplo, n, -1, -1,
253 $ -1 ) )
254 liopt = liwmin
255 END IF
256 work( 1 ) = lopt
257 iwork( 1 ) = liopt
258*
259 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
260 info = -8
261 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
262 info = -10
263 END IF
264 END IF
265*
266 IF( info.NE.0 ) THEN
267 CALL xerbla( 'DSYEVD', -info )
268 RETURN
269 ELSE IF( lquery ) THEN
270 RETURN
271 END IF
272*
273* Quick return if possible
274*
275 IF( n.EQ.0 )
276 $ RETURN
277*
278 IF( n.EQ.1 ) THEN
279 w( 1 ) = a( 1, 1 )
280 IF( wantz )
281 $ a( 1, 1 ) = one
282 RETURN
283 END IF
284*
285* Get machine constants.
286*
287 safmin = dlamch( 'Safe minimum' )
288 eps = dlamch( 'Precision' )
289 smlnum = safmin / eps
290 bignum = one / smlnum
291 rmin = sqrt( smlnum )
292 rmax = sqrt( bignum )
293*
294* Scale matrix to allowable range, if necessary.
295*
296 anrm = dlansy( 'M', uplo, n, a, lda, work )
297 iscale = 0
298 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
299 iscale = 1
300 sigma = rmin / anrm
301 ELSE IF( anrm.GT.rmax ) THEN
302 iscale = 1
303 sigma = rmax / anrm
304 END IF
305 IF( iscale.EQ.1 )
306 $ CALL dlascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
307*
308* Call DSYTRD to reduce symmetric matrix to tridiagonal form.
309*
310 inde = 1
311 indtau = inde + n
312 indwrk = indtau + n
313 llwork = lwork - indwrk + 1
314 indwk2 = indwrk + n*n
315 llwrk2 = lwork - indwk2 + 1
316*
317 CALL dsytrd( uplo, n, a, lda, w, work( inde ), work( indtau ),
318 $ work( indwrk ), llwork, iinfo )
319*
320* For eigenvalues only, call DSTERF. For eigenvectors, first call
321* DSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the
322* tridiagonal matrix, then call DORMTR to multiply it by the
323* Householder transformations stored in A.
324*
325 IF( .NOT.wantz ) THEN
326 CALL dsterf( n, w, work( inde ), info )
327 ELSE
328 CALL dstedc( 'I', n, w, work( inde ), work( indwrk ), n,
329 $ work( indwk2 ), llwrk2, iwork, liwork, info )
330 CALL dormtr( 'L', uplo, 'N', n, n, a, lda, work( indtau ),
331 $ work( indwrk ), n, work( indwk2 ), llwrk2, iinfo )
332 CALL dlacpy( 'A', n, n, work( indwrk ), n, a, lda )
333 END IF
334*
335* If matrix was scaled, then rescale eigenvalues appropriately.
336*
337 IF( iscale.EQ.1 )
338 $ CALL dscal( n, one / sigma, w, 1 )
339*
340 work( 1 ) = lopt
341 iwork( 1 ) = liopt
342*
343 RETURN
344*
345* End of DSYEVD
346*
347 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dsyevd(jobz, uplo, n, a, lda, w, work, lwork, iwork, liwork, info)
DSYEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for SY matrices
Definition dsyevd.f:176
subroutine dsytrd(uplo, n, a, lda, d, e, tau, work, lwork, info)
DSYTRD
Definition dsytrd.f:191
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:101
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:142
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:180
subroutine dsterf(n, d, e, info)
DSTERF
Definition dsterf.f:84
subroutine dormtr(side, uplo, trans, m, n, a, lda, tau, c, ldc, work, lwork, info)
DORMTR
Definition dormtr.f:170