LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sspevd.f
Go to the documentation of this file.
1*> \brief <b> SSPEVD 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 SSPEVD + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sspevd.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sspevd.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sspevd.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SSPEVD( 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* REAL AP( * ), W( * ), WORK( * ), Z( LDZ, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> SSPEVD 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 REAL 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 REAL array, dimension (N)
86*> If INFO = 0, the eigenvalues in ascending order.
87*> \endverbatim
88*>
89*> \param[out] Z
90*> \verbatim
91*> Z is REAL 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 REAL 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 sspevd( 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 REAL AP( * ), W( * ), WORK( * ), Z( LDZ, * )
182* ..
183*
184* =====================================================================
185*
186* .. Parameters ..
187 REAL ZERO, ONE
188 parameter( zero = 0.0e+0, one = 1.0e+0 )
189* ..
190* .. Local Scalars ..
191 LOGICAL LQUERY, WANTZ
192 INTEGER IINFO, INDE, INDTAU, INDWRK, ISCALE, LIWMIN,
193 $ llwork, lwmin
194 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
195 $ smlnum
196* ..
197* .. External Functions ..
198 LOGICAL LSAME
199 REAL SLAMCH, SLANSP, SROUNDUP_LWORK
200 EXTERNAL lsame, slamch, slansp,
201 $ sroundup_lwork
202* ..
203* .. External Subroutines ..
204 EXTERNAL sopmtr, sscal, ssptrd, sstedc, ssterf,
205 $ xerbla
206* ..
207* .. Intrinsic Functions ..
208 INTRINSIC sqrt
209* ..
210* .. Executable Statements ..
211*
212* Test the input parameters.
213*
214 wantz = lsame( jobz, 'V' )
215 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
216*
217 info = 0
218 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
219 info = -1
220 ELSE IF( .NOT.( lsame( uplo, 'U' ) .OR.
221 $ lsame( uplo, 'L' ) ) )
222 $ THEN
223 info = -2
224 ELSE IF( n.LT.0 ) THEN
225 info = -3
226 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
227 info = -7
228 END IF
229*
230 IF( info.EQ.0 ) THEN
231 IF( n.LE.1 ) THEN
232 liwmin = 1
233 lwmin = 1
234 ELSE
235 IF( wantz ) THEN
236 liwmin = 3 + 5*n
237 lwmin = 1 + 6*n + n**2
238 ELSE
239 liwmin = 1
240 lwmin = 2*n
241 END IF
242 END IF
243 iwork( 1 ) = liwmin
244 work( 1 ) = sroundup_lwork(lwmin)
245*
246 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
247 info = -9
248 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
249 info = -11
250 END IF
251 END IF
252*
253 IF( info.NE.0 ) THEN
254 CALL xerbla( 'SSPEVD', -info )
255 RETURN
256 ELSE IF( lquery ) THEN
257 RETURN
258 END IF
259*
260* Quick return if possible
261*
262 IF( n.EQ.0 )
263 $ RETURN
264*
265 IF( n.EQ.1 ) THEN
266 w( 1 ) = ap( 1 )
267 IF( wantz )
268 $ z( 1, 1 ) = one
269 RETURN
270 END IF
271*
272* Get machine constants.
273*
274 safmin = slamch( 'Safe minimum' )
275 eps = slamch( 'Precision' )
276 smlnum = safmin / eps
277 bignum = one / smlnum
278 rmin = sqrt( smlnum )
279 rmax = sqrt( bignum )
280*
281* Scale matrix to allowable range, if necessary.
282*
283 anrm = slansp( 'M', uplo, n, ap, work )
284 iscale = 0
285 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
286 iscale = 1
287 sigma = rmin / anrm
288 ELSE IF( anrm.GT.rmax ) THEN
289 iscale = 1
290 sigma = rmax / anrm
291 END IF
292 IF( iscale.EQ.1 ) THEN
293 CALL sscal( ( n*( n+1 ) ) / 2, sigma, ap, 1 )
294 END IF
295*
296* Call SSPTRD to reduce symmetric packed matrix to tridiagonal form.
297*
298 inde = 1
299 indtau = inde + n
300 CALL ssptrd( uplo, n, ap, w, work( inde ), work( indtau ),
301 $ iinfo )
302*
303* For eigenvalues only, call SSTERF. For eigenvectors, first call
304* SSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the
305* tridiagonal matrix, then call SOPMTR to multiply it by the
306* Householder transformations represented in AP.
307*
308 IF( .NOT.wantz ) THEN
309 CALL ssterf( n, w, work( inde ), info )
310 ELSE
311 indwrk = indtau + n
312 llwork = lwork - indwrk + 1
313 CALL sstedc( 'I', n, w, work( inde ), z, ldz,
314 $ work( indwrk ),
315 $ llwork, iwork, liwork, info )
316 CALL sopmtr( 'L', uplo, 'N', n, n, ap, work( indtau ), z,
317 $ ldz,
318 $ work( indwrk ), iinfo )
319 END IF
320*
321* If matrix was scaled, then rescale eigenvalues appropriately.
322*
323 IF( iscale.EQ.1 )
324 $ CALL sscal( n, one / sigma, w, 1 )
325*
326 work( 1 ) = sroundup_lwork(lwmin)
327 iwork( 1 ) = liwmin
328 RETURN
329*
330* End of SSPEVD
331*
332 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sspevd(jobz, uplo, n, ap, w, z, ldz, work, lwork, iwork, liwork, info)
SSPEVD computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrice...
Definition sspevd.f:170
subroutine ssptrd(uplo, n, ap, d, e, tau, info)
SSPTRD
Definition ssptrd.f:148
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 sopmtr(side, uplo, trans, m, n, ap, tau, c, ldc, work, info)
SOPMTR
Definition sopmtr.f:149