LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
chpev.f
Go to the documentation of this file.
1*> \brief <b> CHPEV 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 CHPEV + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chpev.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chpev.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chpev.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CHPEV( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, RWORK,
20* INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBZ, UPLO
24* INTEGER INFO, LDZ, N
25* ..
26* .. Array Arguments ..
27* REAL RWORK( * ), W( * )
28* COMPLEX AP( * ), WORK( * ), Z( LDZ, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> CHPEV computes all the eigenvalues and, optionally, eigenvectors of a
38*> complex Hermitian matrix in packed storage.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] JOBZ
45*> \verbatim
46*> JOBZ is CHARACTER*1
47*> = 'N': Compute eigenvalues only;
48*> = 'V': Compute eigenvalues and eigenvectors.
49*> \endverbatim
50*>
51*> \param[in] UPLO
52*> \verbatim
53*> UPLO is CHARACTER*1
54*> = 'U': Upper triangle of A is stored;
55*> = 'L': Lower triangle of A is stored.
56*> \endverbatim
57*>
58*> \param[in] N
59*> \verbatim
60*> N is INTEGER
61*> The order of the matrix A. N >= 0.
62*> \endverbatim
63*>
64*> \param[in,out] AP
65*> \verbatim
66*> AP is COMPLEX array, dimension (N*(N+1)/2)
67*> On entry, the upper or lower triangle of the Hermitian matrix
68*> A, packed columnwise in a linear array. The j-th column of A
69*> is stored in the array AP as follows:
70*> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
71*> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
72*>
73*> On exit, AP is overwritten by values generated during the
74*> reduction to tridiagonal form. If UPLO = 'U', the diagonal
75*> and first superdiagonal of the tridiagonal matrix T overwrite
76*> the corresponding elements of A, and if UPLO = 'L', the
77*> diagonal and first subdiagonal of T overwrite the
78*> corresponding elements of A.
79*> \endverbatim
80*>
81*> \param[out] W
82*> \verbatim
83*> W is REAL array, dimension (N)
84*> If INFO = 0, the eigenvalues in ascending order.
85*> \endverbatim
86*>
87*> \param[out] Z
88*> \verbatim
89*> Z is COMPLEX array, dimension (LDZ, N)
90*> If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
91*> eigenvectors of the matrix A, with the i-th column of Z
92*> holding the eigenvector associated with W(i).
93*> If JOBZ = 'N', then Z is not referenced.
94*> \endverbatim
95*>
96*> \param[in] LDZ
97*> \verbatim
98*> LDZ is INTEGER
99*> The leading dimension of the array Z. LDZ >= 1, and if
100*> JOBZ = 'V', LDZ >= max(1,N).
101*> \endverbatim
102*>
103*> \param[out] WORK
104*> \verbatim
105*> WORK is COMPLEX array, dimension (max(1, 2*N-1))
106*> \endverbatim
107*>
108*> \param[out] RWORK
109*> \verbatim
110*> RWORK is REAL array, dimension (max(1, 3*N-2))
111*> \endverbatim
112*>
113*> \param[out] INFO
114*> \verbatim
115*> INFO is INTEGER
116*> = 0: successful exit.
117*> < 0: if INFO = -i, the i-th argument had an illegal value.
118*> > 0: if INFO = i, the algorithm failed to converge; i
119*> off-diagonal elements of an intermediate tridiagonal
120*> form did not converge to zero.
121*> \endverbatim
122*
123* Authors:
124* ========
125*
126*> \author Univ. of Tennessee
127*> \author Univ. of California Berkeley
128*> \author Univ. of Colorado Denver
129*> \author NAG Ltd.
130*
131*> \ingroup hpev
132*
133* =====================================================================
134 SUBROUTINE chpev( JOBZ, UPLO, N, AP, W, Z, LDZ, WORK, RWORK,
135 $ INFO )
136*
137* -- LAPACK driver routine --
138* -- LAPACK is a software package provided by Univ. of Tennessee, --
139* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
140*
141* .. Scalar Arguments ..
142 CHARACTER JOBZ, UPLO
143 INTEGER INFO, LDZ, N
144* ..
145* .. Array Arguments ..
146 REAL RWORK( * ), W( * )
147 COMPLEX AP( * ), WORK( * ), Z( LDZ, * )
148* ..
149*
150* =====================================================================
151*
152* .. Parameters ..
153 REAL ZERO, ONE
154 parameter( zero = 0.0e0, one = 1.0e0 )
155* ..
156* .. Local Scalars ..
157 LOGICAL WANTZ
158 INTEGER IINFO, IMAX, INDE, INDRWK, INDTAU, INDWRK,
159 $ iscale
160 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
161 $ smlnum
162* ..
163* .. External Functions ..
164 LOGICAL LSAME
165 REAL CLANHP, SLAMCH
166 EXTERNAL lsame, clanhp, slamch
167* ..
168* .. External Subroutines ..
169 EXTERNAL chptrd, csscal, csteqr, cupgtr, sscal,
170 $ ssterf,
171 $ xerbla
172* ..
173* .. Intrinsic Functions ..
174 INTRINSIC sqrt
175* ..
176* .. Executable Statements ..
177*
178* Test the input parameters.
179*
180 wantz = lsame( jobz, 'V' )
181*
182 info = 0
183 IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
184 info = -1
185 ELSE IF( .NOT.( lsame( uplo, 'L' ) .OR.
186 $ lsame( uplo, 'U' ) ) )
187 $ THEN
188 info = -2
189 ELSE IF( n.LT.0 ) THEN
190 info = -3
191 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
192 info = -7
193 END IF
194*
195 IF( info.NE.0 ) THEN
196 CALL xerbla( 'CHPEV ', -info )
197 RETURN
198 END IF
199*
200* Quick return if possible
201*
202 IF( n.EQ.0 )
203 $ RETURN
204*
205 IF( n.EQ.1 ) THEN
206 w( 1 ) = real( ap( 1 ) )
207 rwork( 1 ) = 1
208 IF( wantz )
209 $ z( 1, 1 ) = one
210 RETURN
211 END IF
212*
213* Get machine constants.
214*
215 safmin = slamch( 'Safe minimum' )
216 eps = slamch( 'Precision' )
217 smlnum = safmin / eps
218 bignum = one / smlnum
219 rmin = sqrt( smlnum )
220 rmax = sqrt( bignum )
221*
222* Scale matrix to allowable range, if necessary.
223*
224 anrm = clanhp( 'M', uplo, n, ap, rwork )
225 iscale = 0
226 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
227 iscale = 1
228 sigma = rmin / anrm
229 ELSE IF( anrm.GT.rmax ) THEN
230 iscale = 1
231 sigma = rmax / anrm
232 END IF
233 IF( iscale.EQ.1 ) THEN
234 CALL csscal( ( n*( n+1 ) ) / 2, sigma, ap, 1 )
235 END IF
236*
237* Call CHPTRD to reduce Hermitian packed matrix to tridiagonal form.
238*
239 inde = 1
240 indtau = 1
241 CALL chptrd( uplo, n, ap, w, rwork( inde ), work( indtau ),
242 $ iinfo )
243*
244* For eigenvalues only, call SSTERF. For eigenvectors, first call
245* CUPGTR to generate the orthogonal matrix, then call CSTEQR.
246*
247 IF( .NOT.wantz ) THEN
248 CALL ssterf( n, w, rwork( inde ), info )
249 ELSE
250 indwrk = indtau + n
251 CALL cupgtr( uplo, n, ap, work( indtau ), z, ldz,
252 $ work( indwrk ), iinfo )
253 indrwk = inde + n
254 CALL csteqr( jobz, n, w, rwork( inde ), z, ldz,
255 $ rwork( indrwk ), info )
256 END IF
257*
258* If matrix was scaled, then rescale eigenvalues appropriately.
259*
260 IF( iscale.EQ.1 ) THEN
261 IF( info.EQ.0 ) THEN
262 imax = n
263 ELSE
264 imax = info - 1
265 END IF
266 CALL sscal( imax, one / sigma, w, 1 )
267 END IF
268*
269 RETURN
270*
271* End of CHPEV
272*
273 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine chpev(jobz, uplo, n, ap, w, z, ldz, work, rwork, info)
CHPEV computes the eigenvalues and, optionally, the left and/or right eigenvectors for OTHER matrices
Definition chpev.f:136
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 csteqr(compz, n, d, e, z, ldz, work, info)
CSTEQR
Definition csteqr.f:130
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
subroutine cupgtr(uplo, n, ap, tau, q, ldq, work, info)
CUPGTR
Definition cupgtr.f:112