LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
dspgvx.f
Go to the documentation of this file.
1 *> \brief \b DSPGST
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
9 *> Download DSPGVX + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspgvx.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspgvx.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspgvx.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE DSPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
22 * IL, IU, ABSTOL, M, W, Z, LDZ, WORK, IWORK,
23 * IFAIL, INFO )
24 *
25 * .. Scalar Arguments ..
26 * CHARACTER JOBZ, RANGE, UPLO
27 * INTEGER IL, INFO, ITYPE, IU, LDZ, M, N
28 * DOUBLE PRECISION ABSTOL, VL, VU
29 * ..
30 * .. Array Arguments ..
31 * INTEGER IFAIL( * ), IWORK( * )
32 * DOUBLE PRECISION AP( * ), BP( * ), W( * ), WORK( * ),
33 * $ Z( LDZ, * )
34 * ..
35 *
36 *
37 *> \par Purpose:
38 * =============
39 *>
40 *> \verbatim
41 *>
42 *> DSPGVX computes selected eigenvalues, and optionally, eigenvectors
43 *> of a real generalized symmetric-definite eigenproblem, of the form
44 *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A
45 *> and B are assumed to be symmetric, stored in packed storage, and B
46 *> is also positive definite. Eigenvalues and eigenvectors can be
47 *> selected by specifying either a range of values or a range of indices
48 *> for the 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 triangle of A and B are stored;
83 *> = 'L': Lower triangle of A and B are stored.
84 *> \endverbatim
85 *>
86 *> \param[in] N
87 *> \verbatim
88 *> N is INTEGER
89 *> The order of the matrix pencil (A,B). N >= 0.
90 *> \endverbatim
91 *>
92 *> \param[in,out] AP
93 *> \verbatim
94 *> AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
95 *> On entry, the upper or lower triangle of the symmetric 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 DOUBLE PRECISION array, dimension (N*(N+1)/2)
107 *> On entry, the upper or lower triangle of the symmetric 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**T*U or B = L*L**T, in the same storage
115 *> format as B.
116 *> \endverbatim
117 *>
118 *> \param[in] VL
119 *> \verbatim
120 *> VL is DOUBLE PRECISION
121 *> \endverbatim
122 *>
123 *> \param[in] VU
124 *> \verbatim
125 *> VU is DOUBLE PRECISION
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 DOUBLE PRECISION
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 A to tridiagonal form.
161 *>
162 *> Eigenvalues will be computed most accurately when ABSTOL is
163 *> set to twice the underflow threshold 2*DLAMCH('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*DLAMCH('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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (LDZ, max(1,M))
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**T*B*Z = I;
193 *> if ITYPE = 3, Z**T*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 DOUBLE PRECISION array, dimension (8*N)
213 *> \endverbatim
214 *>
215 *> \param[out] IWORK
216 *> \verbatim
217 *> IWORK is INTEGER array, dimension (5*N)
218 *> \endverbatim
219 *>
220 *> \param[out] IFAIL
221 *> \verbatim
222 *> IFAIL is INTEGER array, dimension (N)
223 *> If JOBZ = 'V', then if INFO = 0, the first M elements of
224 *> IFAIL are zero. If INFO > 0, then IFAIL contains the
225 *> indices of the eigenvectors that failed to converge.
226 *> If JOBZ = 'N', then IFAIL is not referenced.
227 *> \endverbatim
228 *>
229 *> \param[out] INFO
230 *> \verbatim
231 *> INFO is INTEGER
232 *> = 0: successful exit
233 *> < 0: if INFO = -i, the i-th argument had an illegal value
234 *> > 0: DPPTRF or DSPEVX returned an error code:
235 *> <= N: if INFO = i, DSPEVX failed to converge;
236 *> i eigenvectors failed to converge. Their indices
237 *> are stored in array IFAIL.
238 *> > N: if INFO = N + i, for 1 <= i <= N, then the leading
239 *> minor of order i of B is not positive definite.
240 *> The factorization of B could not be completed and
241 *> no eigenvalues or eigenvectors were computed.
242 *> \endverbatim
243 *
244 * Authors:
245 * ========
246 *
247 *> \author Univ. of Tennessee
248 *> \author Univ. of California Berkeley
249 *> \author Univ. of Colorado Denver
250 *> \author NAG Ltd.
251 *
252 *> \date November 2011
253 *
254 *> \ingroup doubleOTHEReigen
255 *
256 *> \par Contributors:
257 * ==================
258 *>
259 *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
260 *
261 * =====================================================================
262  SUBROUTINE dspgvx( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
263  $ il, iu, abstol, m, w, z, ldz, work, iwork,
264  $ ifail, info )
265 *
266 * -- LAPACK driver routine (version 3.4.0) --
267 * -- LAPACK is a software package provided by Univ. of Tennessee, --
268 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
269 * November 2011
270 *
271 * .. Scalar Arguments ..
272  CHARACTER jobz, range, uplo
273  INTEGER il, info, itype, iu, ldz, m, n
274  DOUBLE PRECISION abstol, vl, vu
275 * ..
276 * .. Array Arguments ..
277  INTEGER ifail( * ), iwork( * )
278  DOUBLE PRECISION ap( * ), bp( * ), w( * ), work( * ),
279  $ z( ldz, * )
280 * ..
281 *
282 * =====================================================================
283 *
284 * .. Local Scalars ..
285  LOGICAL alleig, indeig, upper, valeig, wantz
286  CHARACTER trans
287  INTEGER j
288 * ..
289 * .. External Functions ..
290  LOGICAL lsame
291  EXTERNAL lsame
292 * ..
293 * .. External Subroutines ..
294  EXTERNAL dpptrf, dspevx, dspgst, dtpmv, dtpsv, xerbla
295 * ..
296 * .. Intrinsic Functions ..
297  INTRINSIC min
298 * ..
299 * .. Executable Statements ..
300 *
301 * Test the input parameters.
302 *
303  upper = lsame( uplo, 'U' )
304  wantz = lsame( jobz, 'V' )
305  alleig = lsame( range, 'A' )
306  valeig = lsame( range, 'V' )
307  indeig = lsame( range, 'I' )
308 *
309  info = 0
310  IF( itype.LT.1 .OR. itype.GT.3 ) THEN
311  info = -1
312  ELSE IF( .NOT.( wantz .OR. lsame( jobz, 'N' ) ) ) THEN
313  info = -2
314  ELSE IF( .NOT.( alleig .OR. valeig .OR. indeig ) ) THEN
315  info = -3
316  ELSE IF( .NOT.( upper .OR. lsame( uplo, 'L' ) ) ) THEN
317  info = -4
318  ELSE IF( n.LT.0 ) THEN
319  info = -5
320  ELSE
321  IF( valeig ) THEN
322  IF( n.GT.0 .AND. vu.LE.vl ) THEN
323  info = -9
324  END IF
325  ELSE IF( indeig ) THEN
326  IF( il.LT.1 ) THEN
327  info = -10
328  ELSE IF( iu.LT.min( n, il ) .OR. iu.GT.n ) THEN
329  info = -11
330  END IF
331  END IF
332  END IF
333  IF( info.EQ.0 ) THEN
334  IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
335  info = -16
336  END IF
337  END IF
338 *
339  IF( info.NE.0 ) THEN
340  CALL xerbla( 'DSPGVX', -info )
341  return
342  END IF
343 *
344 * Quick return if possible
345 *
346  m = 0
347  IF( n.EQ.0 )
348  $ return
349 *
350 * Form a Cholesky factorization of B.
351 *
352  CALL dpptrf( uplo, n, bp, info )
353  IF( info.NE.0 ) THEN
354  info = n + info
355  return
356  END IF
357 *
358 * Transform problem to standard eigenvalue problem and solve.
359 *
360  CALL dspgst( itype, uplo, n, ap, bp, info )
361  CALL dspevx( jobz, range, uplo, n, ap, vl, vu, il, iu, abstol, m,
362  $ w, z, ldz, work, iwork, ifail, info )
363 *
364  IF( wantz ) THEN
365 *
366 * Backtransform eigenvectors to the original problem.
367 *
368  IF( info.GT.0 )
369  $ m = info - 1
370  IF( itype.EQ.1 .OR. itype.EQ.2 ) THEN
371 *
372 * For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
373 * backtransform eigenvectors: x = inv(L)**T*y or inv(U)*y
374 *
375  IF( upper ) THEN
376  trans = 'N'
377  ELSE
378  trans = 'T'
379  END IF
380 *
381  DO 10 j = 1, m
382  CALL dtpsv( uplo, trans, 'Non-unit', n, bp, z( 1, j ),
383  $ 1 )
384  10 continue
385 *
386  ELSE IF( itype.EQ.3 ) THEN
387 *
388 * For B*A*x=(lambda)*x;
389 * backtransform eigenvectors: x = L*y or U**T*y
390 *
391  IF( upper ) THEN
392  trans = 'T'
393  ELSE
394  trans = 'N'
395  END IF
396 *
397  DO 20 j = 1, m
398  CALL dtpmv( uplo, trans, 'Non-unit', n, bp, z( 1, j ),
399  $ 1 )
400  20 continue
401  END IF
402  END IF
403 *
404  return
405 *
406 * End of DSPGVX
407 *
408  END