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