LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sstevd.f
Go to the documentation of this file.
1*> \brief <b> SSTEVD 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 SSTEVD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sstevd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sstevd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sstevd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SSTEVD( JOBZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
20* LIWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ
24* INTEGER INFO, LDZ, LIWORK, LWORK, N
25* ..
26* .. Array Arguments ..
27* INTEGER IWORK( * )
28* REAL D( * ), E( * ), WORK( * ), Z( LDZ, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> SSTEVD computes all eigenvalues and, optionally, eigenvectors of a
38*> real symmetric tridiagonal matrix. If eigenvectors are desired, it
39*> 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] N
54*> \verbatim
55*> N is INTEGER
56*> The order of the matrix. N >= 0.
57*> \endverbatim
58*>
59*> \param[in,out] D
60*> \verbatim
61*> D is REAL array, dimension (N)
62*> On entry, the n diagonal elements of the tridiagonal matrix
63*> A.
64*> On exit, if INFO = 0, the eigenvalues in ascending order.
65*> \endverbatim
66*>
67*> \param[in,out] E
68*> \verbatim
69*> E is REAL array, dimension (N-1)
70*> On entry, the (n-1) subdiagonal elements of the tridiagonal
71*> matrix A, stored in elements 1 to N-1 of E.
72*> On exit, the contents of E are destroyed.
73*> \endverbatim
74*>
75*> \param[out] Z
76*> \verbatim
77*> Z is REAL array, dimension (LDZ, N)
78*> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
79*> eigenvectors of the matrix A, with the i-th column of Z
80*> holding the eigenvector associated with D(i).
81*> If JOBZ = 'N', then Z is not referenced.
82*> \endverbatim
83*>
84*> \param[in] LDZ
85*> \verbatim
86*> LDZ is INTEGER
87*> The leading dimension of the array Z. LDZ >= 1, and if
88*> JOBZ = 'V', LDZ >= max(1,N).
89*> \endverbatim
90*>
91*> \param[out] WORK
92*> \verbatim
93*> WORK is REAL array,
94*> dimension (LWORK)
95*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
96*> \endverbatim
97*>
98*> \param[in] LWORK
99*> \verbatim
100*> LWORK is INTEGER
101*> The dimension of the array WORK.
102*> If JOBZ = 'N' or N <= 1 then LWORK must be at least 1.
103*> If JOBZ = 'V' and N > 1 then LWORK must be at least
104*> ( 1 + 4*N + N**2 ).
105*>
106*> If LWORK = -1, then a workspace query is assumed; the routine
107*> only calculates the optimal sizes of the WORK and IWORK
108*> arrays, returns these values as the first entries of the WORK
109*> and IWORK arrays, and no error message related to LWORK or
110*> LIWORK is issued by XERBLA.
111*> \endverbatim
112*>
113*> \param[out] IWORK
114*> \verbatim
115*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
116*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
117*> \endverbatim
118*>
119*> \param[in] LIWORK
120*> \verbatim
121*> LIWORK is INTEGER
122*> The dimension of the array IWORK.
123*> If JOBZ = 'N' or N <= 1 then LIWORK must be at least 1.
124*> If JOBZ = 'V' and N > 1 then LIWORK must be at least 3+5*N.
125*>
126*> If LIWORK = -1, then a workspace query is assumed; the
127*> routine only calculates the optimal sizes of the WORK and
128*> IWORK arrays, returns these values as the first entries of
129*> the WORK and IWORK arrays, and no error message related to
130*> LWORK or LIWORK is issued by XERBLA.
131*> \endverbatim
132*>
133*> \param[out] INFO
134*> \verbatim
135*> INFO is INTEGER
136*> = 0: successful exit
137*> < 0: if INFO = -i, the i-th argument had an illegal value
138*> > 0: if INFO = i, the algorithm failed to converge; i
139*> off-diagonal elements of E did not converge to zero.
140*> \endverbatim
141*
142* Authors:
143* ========
144*
145*> \author Univ. of Tennessee
146*> \author Univ. of California Berkeley
147*> \author Univ. of Colorado Denver
148*> \author NAG Ltd.
149*
150*> \ingroup stevd
151*
152* =====================================================================
153 SUBROUTINE sstevd( JOBZ, N, D, E, Z, LDZ, WORK, LWORK, IWORK,
154 $ LIWORK, INFO )
155*
156* -- LAPACK driver routine --
157* -- LAPACK is a software package provided by Univ. of Tennessee, --
158* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
159*
160* .. Scalar Arguments ..
161 CHARACTER JOBZ
162 INTEGER INFO, LDZ, LIWORK, LWORK, N
163* ..
164* .. Array Arguments ..
165 INTEGER IWORK( * )
166 REAL D( * ), E( * ), WORK( * ), Z( LDZ, * )
167* ..
168*
169* =====================================================================
170*
171* .. Parameters ..
172 REAL ZERO, ONE
173 parameter( zero = 0.0e0, one = 1.0e0 )
174* ..
175* .. Local Scalars ..
176 LOGICAL LQUERY, WANTZ
177 INTEGER ISCALE, LIWMIN, LWMIN
178 REAL BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
179 $ tnrm
180* ..
181* .. External Functions ..
182 LOGICAL LSAME
183 REAL SLAMCH, SLANST, SROUNDUP_LWORK
184 EXTERNAL lsame, slamch, slanst,
185 $ sroundup_lwork
186* ..
187* .. External Subroutines ..
188 EXTERNAL sscal, sstedc, ssterf, xerbla
189* ..
190* .. Intrinsic Functions ..
191 INTRINSIC sqrt
192* ..
193* .. Executable Statements ..
194*
195* Test the input parameters.
196*
197 wantz = lsame( jobz, 'V' )
198 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
199*
200 info = 0
201 liwmin = 1
202 lwmin = 1
203 IF( n.GT.1 .AND. wantz ) THEN
204 lwmin = 1 + 4*n + n**2
205 liwmin = 3 + 5*n
206 END IF
207*
208 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
209 info = -1
210 ELSE IF( n.LT.0 ) THEN
211 info = -2
212 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
213 info = -6
214 END IF
215*
216 IF( info.EQ.0 ) THEN
217 work( 1 ) = sroundup_lwork(lwmin)
218 iwork( 1 ) = liwmin
219*
220 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
221 info = -8
222 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
223 info = -10
224 END IF
225 END IF
226*
227 IF( info.NE.0 ) THEN
228 CALL xerbla( 'SSTEVD', -info )
229 RETURN
230 ELSE IF( lquery ) THEN
231 RETURN
232 END IF
233*
234* Quick return if possible
235*
236 IF( n.EQ.0 )
237 $ RETURN
238*
239 IF( n.EQ.1 ) THEN
240 IF( wantz )
241 $ z( 1, 1 ) = one
242 RETURN
243 END IF
244*
245* Get machine constants.
246*
247 safmin = slamch( 'Safe minimum' )
248 eps = slamch( 'Precision' )
249 smlnum = safmin / eps
250 bignum = one / smlnum
251 rmin = sqrt( smlnum )
252 rmax = sqrt( bignum )
253*
254* Scale matrix to allowable range, if necessary.
255*
256 iscale = 0
257 tnrm = slanst( 'M', n, d, e )
258 IF( tnrm.GT.zero .AND. tnrm.LT.rmin ) THEN
259 iscale = 1
260 sigma = rmin / tnrm
261 ELSE IF( tnrm.GT.rmax ) THEN
262 iscale = 1
263 sigma = rmax / tnrm
264 END IF
265 IF( iscale.EQ.1 ) THEN
266 CALL sscal( n, sigma, d, 1 )
267 CALL sscal( n-1, sigma, e( 1 ), 1 )
268 END IF
269*
270* For eigenvalues only, call SSTERF. For eigenvalues and
271* eigenvectors, call SSTEDC.
272*
273 IF( .NOT.wantz ) THEN
274 CALL ssterf( n, d, e, info )
275 ELSE
276 CALL sstedc( 'I', n, d, e, z, ldz, work, lwork, iwork,
277 $ liwork,
278 $ info )
279 END IF
280*
281* If matrix was scaled, then rescale eigenvalues appropriately.
282*
283 IF( iscale.EQ.1 )
284 $ CALL sscal( n, one / sigma, d, 1 )
285*
286 work( 1 ) = sroundup_lwork(lwmin)
287 iwork( 1 ) = liwmin
288*
289 RETURN
290*
291* End of SSTEVD
292*
293 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine sstedc(compz, n, d, e, z, ldz, work, lwork, iwork, liwork, info)
SSTEDC
Definition sstedc.f:180
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
subroutine sstevd(jobz, n, d, e, z, ldz, work, lwork, iwork, liwork, info)
SSTEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrice...
Definition sstevd.f:155