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