LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
chpgvx.f
Go to the documentation of this file.
1 *> \brief \b CHPGST
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download CHPGVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chpgvx.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chpgvx.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chpgvx.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
22 * IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
23 * IWORK, IFAIL, INFO )
24 *
25 * .. Scalar Arguments ..
26 * CHARACTER JOBZ, RANGE, UPLO
27 * INTEGER IL, INFO, ITYPE, IU, LDZ, M, N
28 * REAL ABSTOL, VL, VU
29 * ..
30 * .. Array Arguments ..
31 * INTEGER IFAIL( * ), IWORK( * )
32 * REAL RWORK( * ), W( * )
33 * COMPLEX AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
34 * ..
35 *
36 *
37 *> \par Purpose:
38 * =============
39 *>
40 *> \verbatim
41 *>
42 *> CHPGVX computes selected eigenvalues and, optionally, eigenvectors
43 *> of a complex generalized Hermitian-definite eigenproblem, of the form
44 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and
45 *> B are assumed to be Hermitian, stored in packed format, and B is also
46 *> positive definite. Eigenvalues and eigenvectors can be selected by
47 *> specifying either a range of values or a range of indices for the
48 *> desired eigenvalues.
49 *> \endverbatim
50 *
51 * Arguments:
52 * ==========
53 *
54 *> \param[in] ITYPE
55 *> \verbatim
56 *> ITYPE is INTEGER
57 *> Specifies the problem type to be solved:
58 *> = 1: A*x = (lambda)*B*x
59 *> = 2: A*B*x = (lambda)*x
60 *> = 3: B*A*x = (lambda)*x
61 *> \endverbatim
62 *>
63 *> \param[in] JOBZ
64 *> \verbatim
65 *> JOBZ is CHARACTER*1
66 *> = 'N': Compute eigenvalues only;
67 *> = 'V': Compute eigenvalues and eigenvectors.
68 *> \endverbatim
69 *>
70 *> \param[in] RANGE
71 *> \verbatim
72 *> RANGE is CHARACTER*1
73 *> = 'A': all eigenvalues will be found;
74 *> = 'V': all eigenvalues in the half-open interval (VL,VU]
75 *> will be found;
76 *> = 'I': the IL-th through IU-th eigenvalues will be found.
77 *> \endverbatim
78 *>
79 *> \param[in] UPLO
80 *> \verbatim
81 *> UPLO is CHARACTER*1
82 *> = 'U': Upper triangles of A and B are stored;
83 *> = 'L': Lower triangles of A and B are stored.
84 *> \endverbatim
85 *>
86 *> \param[in] N
87 *> \verbatim
88 *> N is INTEGER
89 *> The order of the matrices A and B. N >= 0.
90 *> \endverbatim
91 *>
92 *> \param[in,out] AP
93 *> \verbatim
94 *> AP is COMPLEX array, dimension (N*(N+1)/2)
95 *> On entry, the upper or lower triangle of the Hermitian matrix
96 *> A, packed columnwise in a linear array. The j-th column of A
97 *> is stored in the array AP as follows:
98 *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
99 *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
100 *>
101 *> On exit, the contents of AP are destroyed.
102 *> \endverbatim
103 *>
104 *> \param[in,out] BP
105 *> \verbatim
106 *> BP is COMPLEX array, dimension (N*(N+1)/2)
107 *> On entry, the upper or lower triangle of the Hermitian matrix
108 *> B, packed columnwise in a linear array. The j-th column of B
109 *> is stored in the array BP as follows:
110 *> if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
111 *> if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
112 *>
113 *> On exit, the triangular factor U or L from the Cholesky
114 *> factorization B = U**H*U or B = L*L**H, in the same storage
115 *> format as B.
116 *> \endverbatim
117 *>
118 *> \param[in] VL
119 *> \verbatim
120 *> VL is REAL
121 *> \endverbatim
122 *>
123 *> \param[in] VU
124 *> \verbatim
125 *> VU is REAL
126 *>
127 *> If RANGE='V', the lower and upper bounds of the interval to
128 *> be searched for eigenvalues. VL < VU.
129 *> Not referenced if RANGE = 'A' or 'I'.
130 *> \endverbatim
131 *>
132 *> \param[in] IL
133 *> \verbatim
134 *> IL is INTEGER
135 *> \endverbatim
136 *>
137 *> \param[in] IU
138 *> \verbatim
139 *> IU is INTEGER
140 *>
141 *> If RANGE='I', the indices (in ascending order) of the
142 *> smallest and largest eigenvalues to be returned.
143 *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
144 *> Not referenced if RANGE = 'A' or 'V'.
145 *> \endverbatim
146 *>
147 *> \param[in] ABSTOL
148 *> \verbatim
149 *> ABSTOL is REAL
150 *> The absolute error tolerance for the eigenvalues.
151 *> An approximate eigenvalue is accepted as converged
152 *> when it is determined to lie in an interval [a,b]
153 *> of width less than or equal to
154 *>
155 *> ABSTOL + EPS * max( |a|,|b| ) ,
156 *>
157 *> where EPS is the machine precision. If ABSTOL is less than
158 *> or equal to zero, then EPS*|T| will be used in its place,
159 *> where |T| is the 1-norm of the tridiagonal matrix obtained
160 *> by reducing AP to tridiagonal form.
161 *>
162 *> Eigenvalues will be computed most accurately when ABSTOL is
163 *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
164 *> If this routine returns with INFO>0, indicating that some
165 *> eigenvectors did not converge, try setting ABSTOL to
166 *> 2*SLAMCH('S').
167 *> \endverbatim
168 *>
169 *> \param[out] M
170 *> \verbatim
171 *> M is INTEGER
172 *> The total number of eigenvalues found. 0 <= M <= N.
173 *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
174 *> \endverbatim
175 *>
176 *> \param[out] W
177 *> \verbatim
178 *> W is REAL array, dimension (N)
179 *> On normal exit, the first M elements contain the selected
180 *> eigenvalues in ascending order.
181 *> \endverbatim
182 *>
183 *> \param[out] Z
184 *> \verbatim
185 *> Z is COMPLEX array, dimension (LDZ, N)
186 *> If JOBZ = 'N', then Z is not referenced.
187 *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
188 *> contain the orthonormal eigenvectors of the matrix A
189 *> corresponding to the selected eigenvalues, with the i-th
190 *> column of Z holding the eigenvector associated with W(i).
191 *> The eigenvectors are normalized as follows:
192 *> if ITYPE = 1 or 2, Z**H*B*Z = I;
193 *> if ITYPE = 3, Z**H*inv(B)*Z = I.
194 *>
195 *> If an eigenvector fails to converge, then that column of Z
196 *> contains the latest approximation to the eigenvector, and the
197 *> index of the eigenvector is returned in IFAIL.
198 *> Note: the user must ensure that at least max(1,M) columns are
199 *> supplied in the array Z; if RANGE = 'V', the exact value of M
200 *> is not known in advance and an upper bound must be used.
201 *> \endverbatim
202 *>
203 *> \param[in] LDZ
204 *> \verbatim
205 *> LDZ is INTEGER
206 *> The leading dimension of the array Z. LDZ >= 1, and if
207 *> JOBZ = 'V', LDZ >= max(1,N).
208 *> \endverbatim
209 *>
210 *> \param[out] WORK
211 *> \verbatim
212 *> WORK is COMPLEX array, dimension (2*N)
213 *> \endverbatim
214 *>
215 *> \param[out] RWORK
216 *> \verbatim
217 *> RWORK is REAL array, dimension (7*N)
218 *> \endverbatim
219 *>
220 *> \param[out] IWORK
221 *> \verbatim
222 *> IWORK is INTEGER array, dimension (5*N)
223 *> \endverbatim
224 *>
225 *> \param[out] IFAIL
226 *> \verbatim
227 *> IFAIL is INTEGER array, dimension (N)
228 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
229 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
230 *> indices of the eigenvectors that failed to converge.
231 *> If JOBZ = 'N', then IFAIL is not referenced.
232 *> \endverbatim
233 *>
234 *> \param[out] INFO
235 *> \verbatim
236 *> INFO is INTEGER
237 *> = 0: successful exit
238 *> < 0: if INFO = -i, the i-th argument had an illegal value
239 *> > 0: CPPTRF or CHPEVX returned an error code:
240 *> <= N: if INFO = i, CHPEVX failed to converge;
241 *> i eigenvectors failed to converge. Their indices
242 *> are stored in array IFAIL.
243 *> > N: if INFO = N + i, for 1 <= i <= n, then the leading
244 *> minor of order i of B is not positive definite.
245 *> The factorization of B could not be completed and
246 *> no eigenvalues or eigenvectors were computed.
247 *> \endverbatim
248 *
249 * Authors:
250 * ========
251 *
252 *> \author Univ. of Tennessee
253 *> \author Univ. of California Berkeley
254 *> \author Univ. of Colorado Denver
255 *> \author NAG Ltd.
256 *
257 *> \date November 2011
258 *
259 *> \ingroup complexOTHEReigen
260 *
261 *> \par Contributors:
262 * ==================
263 *>
264 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
265 *
266 * =====================================================================
267  SUBROUTINE chpgvx( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
268  $ il, iu, abstol, m, w, z, ldz, work, rwork,
269  $ iwork, ifail, info )
270 *
271 * -- LAPACK driver routine (version 3.4.0) --
272 * -- LAPACK is a software package provided by Univ. of Tennessee, --
273 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
274 * November 2011
275 *
276 * .. Scalar Arguments ..
277  CHARACTER jobz, range, uplo
278  INTEGER il, info, itype, iu, ldz, m, n
279  REAL abstol, vl, vu
280 * ..
281 * .. Array Arguments ..
282  INTEGER ifail( * ), iwork( * )
283  REAL rwork( * ), w( * )
284  COMPLEX ap( * ), bp( * ), work( * ), z( ldz, * )
285 * ..
286 *
287 * =====================================================================
288 *
289 * .. Local Scalars ..
290  LOGICAL alleig, indeig, upper, valeig, wantz
291  CHARACTER trans
292  INTEGER j
293 * ..
294 * .. External Functions ..
295  LOGICAL lsame
296  EXTERNAL lsame
297 * ..
298 * .. External Subroutines ..
299  EXTERNAL chpevx, chpgst, cpptrf, ctpmv, ctpsv, xerbla
300 * ..
301 * .. Intrinsic Functions ..
302  INTRINSIC min
303 * ..
304 * .. Executable Statements ..
305 *
306 * Test the input parameters.
307 *
308  wantz = lsame( jobz, 'V' )
309  upper = lsame( uplo, 'U' )
310  alleig = lsame( range, 'A' )
311  valeig = lsame( range, 'V' )
312  indeig = lsame( range, 'I' )
313 *
314  info = 0
315  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
316  info = -1
317  ELSE IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
318  info = -2
319  ELSE IF( .NOT.( alleig .OR. valeig .OR. indeig ) ) THEN
320  info = -3
321  ELSE IF( .NOT.( upper .OR. lsame( uplo, 'L' ) ) ) THEN
322  info = -4
323  ELSE IF( n.LT.0 ) THEN
324  info = -5
325  ELSE
326  IF( valeig ) THEN
327  IF( n.GT.0 .AND. vu.LE.vl ) THEN
328  info = -9
329  END IF
330  ELSE IF( indeig ) THEN
331  IF( il.LT.1 ) THEN
332  info = -10
333  ELSE IF( iu.LT.min( n, il ) .OR. iu.GT.n ) THEN
334  info = -11
335  END IF
336  END IF
337  END IF
338  IF( info.EQ.0 ) THEN
339  IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
340  info = -16
341  END IF
342  END IF
343 *
344  IF( info.NE.0 ) THEN
345  CALL xerbla( 'CHPGVX', -info )
346  return
347  END IF
348 *
349 * Quick return if possible
350 *
351  IF( n.EQ.0 )
352  $ return
353 *
354 * Form a Cholesky factorization of B.
355 *
356  CALL cpptrf( uplo, n, bp, info )
357  IF( info.NE.0 ) THEN
358  info = n + info
359  return
360  END IF
361 *
362 * Transform problem to standard eigenvalue problem and solve.
363 *
364  CALL chpgst( itype, uplo, n, ap, bp, info )
365  CALL chpevx( jobz, range, uplo, n, ap, vl, vu, il, iu, abstol, m,
366  $ w, z, ldz, work, rwork, iwork, ifail, info )
367 *
368  IF( wantz ) THEN
369 *
370 * Backtransform eigenvectors to the original problem.
371 *
372  IF( info.GT.0 )
373  $ m = info - 1
374  IF( itype.EQ.1 .OR. itype.EQ.2 ) THEN
375 *
376 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
377 * backtransform eigenvectors: x = inv(L)**H*y or inv(U)*y
378 *
379  IF( upper ) THEN
380  trans = 'N'
381  ELSE
382  trans = 'C'
383  END IF
384 *
385  DO 10 j = 1, m
386  CALL ctpsv( uplo, trans, 'Non-unit', n, bp, z( 1, j ),
387  $ 1 )
388  10 continue
389 *
390  ELSE IF( itype.EQ.3 ) THEN
391 *
392 * For B*A*x=(lambda)*x;
393 * backtransform eigenvectors: x = L*y or U**H*y
394 *
395  IF( upper ) THEN
396  trans = 'C'
397  ELSE
398  trans = 'N'
399  END IF
400 *
401  DO 20 j = 1, m
402  CALL ctpmv( uplo, trans, 'Non-unit', n, bp, z( 1, j ),
403  $ 1 )
404  20 continue
405  END IF
406  END IF
407 *
408  return
409 *
410 * End of CHPGVX
411 *
412  END