1: *> \brief \b ZLARRV
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download ZLARRV + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarrv.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarrv.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarrv.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
22: * ISPLIT, M, DOL, DOU, MINRGP,
23: * RTOL1, RTOL2, W, WERR, WGAP,
24: * IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ,
25: * WORK, IWORK, INFO )
26: *
27: * .. Scalar Arguments ..
28: * INTEGER DOL, DOU, INFO, LDZ, M, N
29: * DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU
30: * ..
31: * .. Array Arguments ..
32: * INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ),
33: * $ ISUPPZ( * ), IWORK( * )
34: * DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ),
35: * $ WGAP( * ), WORK( * )
36: * COMPLEX*16 Z( LDZ, * )
37: * ..
38: *
39: *
40: *> \par Purpose:
41: * =============
42: *>
43: *> \verbatim
44: *>
45: *> ZLARRV computes the eigenvectors of the tridiagonal matrix
46: *> T = L D L**T given L, D and APPROXIMATIONS to the eigenvalues of L D L**T.
47: *> The input eigenvalues should have been computed by DLARRE.
48: *> \endverbatim
49: *
50: * Arguments:
51: * ==========
52: *
53: *> \param[in] N
54: *> \verbatim
55: *> N is INTEGER
56: *> The order of the matrix. N >= 0.
57: *> \endverbatim
58: *>
59: *> \param[in] VL
60: *> \verbatim
61: *> VL is DOUBLE PRECISION
62: *> \endverbatim
63: *>
64: *> \param[in] VU
65: *> \verbatim
66: *> VU is DOUBLE PRECISION
67: *> Lower and upper bounds of the interval that contains the desired
68: *> eigenvalues. VL < VU. Needed to compute gaps on the left or right
69: *> end of the extremal eigenvalues in the desired RANGE.
70: *> \endverbatim
71: *>
72: *> \param[in,out] D
73: *> \verbatim
74: *> D is DOUBLE PRECISION array, dimension (N)
75: *> On entry, the N diagonal elements of the diagonal matrix D.
76: *> On exit, D may be overwritten.
77: *> \endverbatim
78: *>
79: *> \param[in,out] L
80: *> \verbatim
81: *> L is DOUBLE PRECISION array, dimension (N)
82: *> On entry, the (N-1) subdiagonal elements of the unit
83: *> bidiagonal matrix L are in elements 1 to N-1 of L
84: *> (if the matrix is not splitted.) At the end of each block
85: *> is stored the corresponding shift as given by DLARRE.
86: *> On exit, L is overwritten.
87: *> \endverbatim
88: *>
89: *> \param[in] PIVMIN
90: *> \verbatim
91: *> PIVMIN is DOUBLE PRECISION
92: *> The minimum pivot allowed in the Sturm sequence.
93: *> \endverbatim
94: *>
95: *> \param[in] ISPLIT
96: *> \verbatim
97: *> ISPLIT is INTEGER array, dimension (N)
98: *> The splitting points, at which T breaks up into blocks.
99: *> The first block consists of rows/columns 1 to
100: *> ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
101: *> through ISPLIT( 2 ), etc.
102: *> \endverbatim
103: *>
104: *> \param[in] M
105: *> \verbatim
106: *> M is INTEGER
107: *> The total number of input eigenvalues. 0 <= M <= N.
108: *> \endverbatim
109: *>
110: *> \param[in] DOL
111: *> \verbatim
112: *> DOL is INTEGER
113: *> \endverbatim
114: *>
115: *> \param[in] DOU
116: *> \verbatim
117: *> DOU is INTEGER
118: *> If the user wants to compute only selected eigenvectors from all
119: *> the eigenvalues supplied, he can specify an index range DOL:DOU.
120: *> Or else the setting DOL=1, DOU=M should be applied.
121: *> Note that DOL and DOU refer to the order in which the eigenvalues
122: *> are stored in W.
123: *> If the user wants to compute only selected eigenpairs, then
124: *> the columns DOL-1 to DOU+1 of the eigenvector space Z contain the
125: *> computed eigenvectors. All other columns of Z are set to zero.
126: *> \endverbatim
127: *>
128: *> \param[in] MINRGP
129: *> \verbatim
130: *> MINRGP is DOUBLE PRECISION
131: *> \endverbatim
132: *>
133: *> \param[in] RTOL1
134: *> \verbatim
135: *> RTOL1 is DOUBLE PRECISION
136: *> \endverbatim
137: *>
138: *> \param[in] RTOL2
139: *> \verbatim
140: *> RTOL2 is DOUBLE PRECISION
141: *> Parameters for bisection.
142: *> An interval [LEFT,RIGHT] has converged if
143: *> RIGHT-LEFT.LT.MAX( RTOL1*GAP, RTOL2*MAX(|LEFT|,|RIGHT|) )
144: *> \endverbatim
145: *>
146: *> \param[in,out] W
147: *> \verbatim
148: *> W is DOUBLE PRECISION array, dimension (N)
149: *> The first M elements of W contain the APPROXIMATE eigenvalues for
150: *> which eigenvectors are to be computed. The eigenvalues
151: *> should be grouped by split-off block and ordered from
152: *> smallest to largest within the block ( The output array
153: *> W from DLARRE is expected here ). Furthermore, they are with
154: *> respect to the shift of the corresponding root representation
155: *> for their block. On exit, W holds the eigenvalues of the
156: *> UNshifted matrix.
157: *> \endverbatim
158: *>
159: *> \param[in,out] WERR
160: *> \verbatim
161: *> WERR is DOUBLE PRECISION array, dimension (N)
162: *> The first M elements contain the semiwidth of the uncertainty
163: *> interval of the corresponding eigenvalue in W
164: *> \endverbatim
165: *>
166: *> \param[in,out] WGAP
167: *> \verbatim
168: *> WGAP is DOUBLE PRECISION array, dimension (N)
169: *> The separation from the right neighbor eigenvalue in W.
170: *> \endverbatim
171: *>
172: *> \param[in] IBLOCK
173: *> \verbatim
174: *> IBLOCK is INTEGER array, dimension (N)
175: *> The indices of the blocks (submatrices) associated with the
176: *> corresponding eigenvalues in W; IBLOCK(i)=1 if eigenvalue
177: *> W(i) belongs to the first block from the top, =2 if W(i)
178: *> belongs to the second block, etc.
179: *> \endverbatim
180: *>
181: *> \param[in] INDEXW
182: *> \verbatim
183: *> INDEXW is INTEGER array, dimension (N)
184: *> The indices of the eigenvalues within each block (submatrix);
185: *> for example, INDEXW(i)= 10 and IBLOCK(i)=2 imply that the
186: *> i-th eigenvalue W(i) is the 10-th eigenvalue in the second block.
187: *> \endverbatim
188: *>
189: *> \param[in] GERS
190: *> \verbatim
191: *> GERS is DOUBLE PRECISION array, dimension (2*N)
192: *> The N Gerschgorin intervals (the i-th Gerschgorin interval
193: *> is (GERS(2*i-1), GERS(2*i)). The Gerschgorin intervals should
194: *> be computed from the original UNshifted matrix.
195: *> \endverbatim
196: *>
197: *> \param[out] Z
198: *> \verbatim
199: *> Z is COMPLEX*16 array, dimension (LDZ, max(1,M) )
200: *> If INFO = 0, the first M columns of Z contain the
201: *> orthonormal eigenvectors of the matrix T
202: *> corresponding to the input eigenvalues, with the i-th
203: *> column of Z holding the eigenvector associated with W(i).
204: *> Note: the user must ensure that at least max(1,M) columns are
205: *> supplied in the array Z.
206: *> \endverbatim
207: *>
208: *> \param[in] LDZ
209: *> \verbatim
210: *> LDZ is INTEGER
211: *> The leading dimension of the array Z. LDZ >= 1, and if
212: *> JOBZ = 'V', LDZ >= max(1,N).
213: *> \endverbatim
214: *>
215: *> \param[out] ISUPPZ
216: *> \verbatim
217: *> ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
218: *> The support of the eigenvectors in Z, i.e., the indices
219: *> indicating the nonzero elements in Z. The I-th eigenvector
220: *> is nonzero only in elements ISUPPZ( 2*I-1 ) through
221: *> ISUPPZ( 2*I ).
222: *> \endverbatim
223: *>
224: *> \param[out] WORK
225: *> \verbatim
226: *> WORK is DOUBLE PRECISION array, dimension (12*N)
227: *> \endverbatim
228: *>
229: *> \param[out] IWORK
230: *> \verbatim
231: *> IWORK is INTEGER array, dimension (7*N)
232: *> \endverbatim
233: *>
234: *> \param[out] INFO
235: *> \verbatim
236: *> INFO is INTEGER
237: *> = 0: successful exit
238: *>
239: *> > 0: A problem occured in ZLARRV.
240: *> < 0: One of the called subroutines signaled an internal problem.
241: *> Needs inspection of the corresponding parameter IINFO
242: *> for further information.
243: *>
244: *> =-1: Problem in DLARRB when refining a child's eigenvalues.
245: *> =-2: Problem in DLARRF when computing the RRR of a child.
246: *> When a child is inside a tight cluster, it can be difficult
247: *> to find an RRR. A partial remedy from the user's point of
248: *> view is to make the parameter MINRGP smaller and recompile.
249: *> However, as the orthogonality of the computed vectors is
250: *> proportional to 1/MINRGP, the user should be aware that
251: *> he might be trading in precision when he decreases MINRGP.
252: *> =-3: Problem in DLARRB when refining a single eigenvalue
253: *> after the Rayleigh correction was rejected.
254: *> = 5: The Rayleigh Quotient Iteration failed to converge to
255: *> full accuracy in MAXITR steps.
256: *> \endverbatim
257: *
258: * Authors:
259: * ========
260: *
261: *> \author Univ. of Tennessee
262: *> \author Univ. of California Berkeley
263: *> \author Univ. of Colorado Denver
264: *> \author NAG Ltd.
265: *
266: *> \date November 2011
267: *
268: *> \ingroup complex16OTHERauxiliary
269: *
270: *> \par Contributors:
271: * ==================
272: *>
273: *> Beresford Parlett, University of California, Berkeley, USA \n
274: *> Jim Demmel, University of California, Berkeley, USA \n
275: *> Inderjit Dhillon, University of Texas, Austin, USA \n
276: *> Osni Marques, LBNL/NERSC, USA \n
277: *> Christof Voemel, University of California, Berkeley, USA
278: *
279: * =====================================================================
280: SUBROUTINE ZLARRV( N, VL, VU, D, L, PIVMIN,
281: $ ISPLIT, M, DOL, DOU, MINRGP,
282: $ RTOL1, RTOL2, W, WERR, WGAP,
283: $ IBLOCK, INDEXW, GERS, Z, LDZ, ISUPPZ,
284: $ WORK, IWORK, INFO )
285: *
286: * -- LAPACK auxiliary routine (version 3.4.0) --
287: * -- LAPACK is a software package provided by Univ. of Tennessee, --
288: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
289: * November 2011
290: *
291: * .. Scalar Arguments ..
292: INTEGER DOL, DOU, INFO, LDZ, M, N
293: DOUBLE PRECISION MINRGP, PIVMIN, RTOL1, RTOL2, VL, VU
294: * ..
295: * .. Array Arguments ..
296: INTEGER IBLOCK( * ), INDEXW( * ), ISPLIT( * ),
297: $ ISUPPZ( * ), IWORK( * )
298: DOUBLE PRECISION D( * ), GERS( * ), L( * ), W( * ), WERR( * ),
299: $ WGAP( * ), WORK( * )
300: COMPLEX*16 Z( LDZ, * )
301: * ..
302: *
303: * =====================================================================
304: *
305: * .. Parameters ..
306: INTEGER MAXITR
307: PARAMETER ( MAXITR = 10 )
308: COMPLEX*16 CZERO
309: PARAMETER ( CZERO = ( 0.0D0, 0.0D0 ) )
310: DOUBLE PRECISION ZERO, ONE, TWO, THREE, FOUR, HALF
311: PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0,
312: $ TWO = 2.0D0, THREE = 3.0D0,
313: $ FOUR = 4.0D0, HALF = 0.5D0)
314: * ..
315: * .. Local Scalars ..
316: LOGICAL ESKIP, NEEDBS, STP2II, TRYRQC, USEDBS, USEDRQ
317: INTEGER DONE, I, IBEGIN, IDONE, IEND, II, IINDC1,
318: $ IINDC2, IINDR, IINDWK, IINFO, IM, IN, INDEIG,
319: $ INDLD, INDLLD, INDWRK, ISUPMN, ISUPMX, ITER,
320: $ ITMP1, J, JBLK, K, MINIWSIZE, MINWSIZE, NCLUS,
321: $ NDEPTH, NEGCNT, NEWCLS, NEWFST, NEWFTT, NEWLST,
322: $ NEWSIZ, OFFSET, OLDCLS, OLDFST, OLDIEN, OLDLST,
323: $ OLDNCL, P, PARITY, Q, WBEGIN, WEND, WINDEX,
324: $ WINDMN, WINDPL, ZFROM, ZTO, ZUSEDL, ZUSEDU,
325: $ ZUSEDW
326: INTEGER INDIN1, INDIN2
327: DOUBLE PRECISION BSTRES, BSTW, EPS, FUDGE, GAP, GAPTOL, GL, GU,
328: $ LAMBDA, LEFT, LGAP, MINGMA, NRMINV, RESID,
329: $ RGAP, RIGHT, RQCORR, RQTOL, SAVGAP, SGNDEF,
330: $ SIGMA, SPDIAM, SSIGMA, TAU, TMP, TOL, ZTZ
331: * ..
332: * .. External Functions ..
333: DOUBLE PRECISION DLAMCH
334: EXTERNAL DLAMCH
335: * ..
336: * .. External Subroutines ..
337: EXTERNAL DCOPY, DLARRB, DLARRF, ZDSCAL, ZLAR1V,
338: $ ZLASET
339: * ..
340: * .. Intrinsic Functions ..
341: INTRINSIC ABS, DBLE, MAX, MIN
342: INTRINSIC DCMPLX
343: * ..
344: * .. Executable Statements ..
345: * ..
346:
347: * The first N entries of WORK are reserved for the eigenvalues
348: INDLD = N+1
349: INDLLD= 2*N+1
350: INDIN1 = 3*N + 1
351: INDIN2 = 4*N + 1
352: INDWRK = 5*N + 1
353: MINWSIZE = 12 * N
354:
355: DO 5 I= 1,MINWSIZE
356: WORK( I ) = ZERO
357: 5 CONTINUE
358:
359: * IWORK(IINDR+1:IINDR+N) hold the twist indices R for the
360: * factorization used to compute the FP vector
361: IINDR = 0
362: * IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current
363: * layer and the one above.
364: IINDC1 = N
365: IINDC2 = 2*N
366: IINDWK = 3*N + 1
367:
368: MINIWSIZE = 7 * N
369: DO 10 I= 1,MINIWSIZE
370: IWORK( I ) = 0
371: 10 CONTINUE
372:
373: ZUSEDL = 1
374: IF(DOL.GT.1) THEN
375: * Set lower bound for use of Z
376: ZUSEDL = DOL-1
377: ENDIF
378: ZUSEDU = M
379: IF(DOU.LT.M) THEN
380: * Set lower bound for use of Z
381: ZUSEDU = DOU+1
382: ENDIF
383: * The width of the part of Z that is used
384: ZUSEDW = ZUSEDU - ZUSEDL + 1
385:
386:
387: CALL ZLASET( 'Full', N, ZUSEDW, CZERO, CZERO,
388: $ Z(1,ZUSEDL), LDZ )
389:
390: EPS = DLAMCH( 'Precision' )
391: RQTOL = TWO * EPS
392: *
393: * Set expert flags for standard code.
394: TRYRQC = .TRUE.
395:
396: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
397: ELSE
398: * Only selected eigenpairs are computed. Since the other evalues
399: * are not refined by RQ iteration, bisection has to compute to full
400: * accuracy.
401: RTOL1 = FOUR * EPS
402: RTOL2 = FOUR * EPS
403: ENDIF
404:
405: * The entries WBEGIN:WEND in W, WERR, WGAP correspond to the
406: * desired eigenvalues. The support of the nonzero eigenvector
407: * entries is contained in the interval IBEGIN:IEND.
408: * Remark that if k eigenpairs are desired, then the eigenvectors
409: * are stored in k contiguous columns of Z.
410:
411: * DONE is the number of eigenvectors already computed
412: DONE = 0
413: IBEGIN = 1
414: WBEGIN = 1
415: DO 170 JBLK = 1, IBLOCK( M )
416: IEND = ISPLIT( JBLK )
417: SIGMA = L( IEND )
418: * Find the eigenvectors of the submatrix indexed IBEGIN
419: * through IEND.
420: WEND = WBEGIN - 1
421: 15 CONTINUE
422: IF( WEND.LT.M ) THEN
423: IF( IBLOCK( WEND+1 ).EQ.JBLK ) THEN
424: WEND = WEND + 1
425: GO TO 15
426: END IF
427: END IF
428: IF( WEND.LT.WBEGIN ) THEN
429: IBEGIN = IEND + 1
430: GO TO 170
431: ELSEIF( (WEND.LT.DOL).OR.(WBEGIN.GT.DOU) ) THEN
432: IBEGIN = IEND + 1
433: WBEGIN = WEND + 1
434: GO TO 170
435: END IF
436:
437: * Find local spectral diameter of the block
438: GL = GERS( 2*IBEGIN-1 )
439: GU = GERS( 2*IBEGIN )
440: DO 20 I = IBEGIN+1 , IEND
441: GL = MIN( GERS( 2*I-1 ), GL )
442: GU = MAX( GERS( 2*I ), GU )
443: 20 CONTINUE
444: SPDIAM = GU - GL
445:
446: * OLDIEN is the last index of the previous block
447: OLDIEN = IBEGIN - 1
448: * Calculate the size of the current block
449: IN = IEND - IBEGIN + 1
450: * The number of eigenvalues in the current block
451: IM = WEND - WBEGIN + 1
452:
453: * This is for a 1x1 block
454: IF( IBEGIN.EQ.IEND ) THEN
455: DONE = DONE+1
456: Z( IBEGIN, WBEGIN ) = DCMPLX( ONE, ZERO )
457: ISUPPZ( 2*WBEGIN-1 ) = IBEGIN
458: ISUPPZ( 2*WBEGIN ) = IBEGIN
459: W( WBEGIN ) = W( WBEGIN ) + SIGMA
460: WORK( WBEGIN ) = W( WBEGIN )
461: IBEGIN = IEND + 1
462: WBEGIN = WBEGIN + 1
463: GO TO 170
464: END IF
465:
466: * The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND)
467: * Note that these can be approximations, in this case, the corresp.
468: * entries of WERR give the size of the uncertainty interval.
469: * The eigenvalue approximations will be refined when necessary as
470: * high relative accuracy is required for the computation of the
471: * corresponding eigenvectors.
472: CALL DCOPY( IM, W( WBEGIN ), 1,
473: $ WORK( WBEGIN ), 1 )
474:
475: * We store in W the eigenvalue approximations w.r.t. the original
476: * matrix T.
477: DO 30 I=1,IM
478: W(WBEGIN+I-1) = W(WBEGIN+I-1)+SIGMA
479: 30 CONTINUE
480:
481:
482: * NDEPTH is the current depth of the representation tree
483: NDEPTH = 0
484: * PARITY is either 1 or 0
485: PARITY = 1
486: * NCLUS is the number of clusters for the next level of the
487: * representation tree, we start with NCLUS = 1 for the root
488: NCLUS = 1
489: IWORK( IINDC1+1 ) = 1
490: IWORK( IINDC1+2 ) = IM
491:
492: * IDONE is the number of eigenvectors already computed in the current
493: * block
494: IDONE = 0
495: * loop while( IDONE.LT.IM )
496: * generate the representation tree for the current block and
497: * compute the eigenvectors
498: 40 CONTINUE
499: IF( IDONE.LT.IM ) THEN
500: * This is a crude protection against infinitely deep trees
501: IF( NDEPTH.GT.M ) THEN
502: INFO = -2
503: RETURN
504: ENDIF
505: * breadth first processing of the current level of the representation
506: * tree: OLDNCL = number of clusters on current level
507: OLDNCL = NCLUS
508: * reset NCLUS to count the number of child clusters
509: NCLUS = 0
510: *
511: PARITY = 1 - PARITY
512: IF( PARITY.EQ.0 ) THEN
513: OLDCLS = IINDC1
514: NEWCLS = IINDC2
515: ELSE
516: OLDCLS = IINDC2
517: NEWCLS = IINDC1
518: END IF
519: * Process the clusters on the current level
520: DO 150 I = 1, OLDNCL
521: J = OLDCLS + 2*I
522: * OLDFST, OLDLST = first, last index of current cluster.
523: * cluster indices start with 1 and are relative
524: * to WBEGIN when accessing W, WGAP, WERR, Z
525: OLDFST = IWORK( J-1 )
526: OLDLST = IWORK( J )
527: IF( NDEPTH.GT.0 ) THEN
528: * Retrieve relatively robust representation (RRR) of cluster
529: * that has been computed at the previous level
530: * The RRR is stored in Z and overwritten once the eigenvectors
531: * have been computed or when the cluster is refined
532:
533: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
534: * Get representation from location of the leftmost evalue
535: * of the cluster
536: J = WBEGIN + OLDFST - 1
537: ELSE
538: IF(WBEGIN+OLDFST-1.LT.DOL) THEN
539: * Get representation from the left end of Z array
540: J = DOL - 1
541: ELSEIF(WBEGIN+OLDFST-1.GT.DOU) THEN
542: * Get representation from the right end of Z array
543: J = DOU
544: ELSE
545: J = WBEGIN + OLDFST - 1
546: ENDIF
547: ENDIF
548: DO 45 K = 1, IN - 1
549: D( IBEGIN+K-1 ) = DBLE( Z( IBEGIN+K-1,
550: $ J ) )
551: L( IBEGIN+K-1 ) = DBLE( Z( IBEGIN+K-1,
552: $ J+1 ) )
553: 45 CONTINUE
554: D( IEND ) = DBLE( Z( IEND, J ) )
555: SIGMA = DBLE( Z( IEND, J+1 ) )
556:
557: * Set the corresponding entries in Z to zero
558: CALL ZLASET( 'Full', IN, 2, CZERO, CZERO,
559: $ Z( IBEGIN, J), LDZ )
560: END IF
561:
562: * Compute DL and DLL of current RRR
563: DO 50 J = IBEGIN, IEND-1
564: TMP = D( J )*L( J )
565: WORK( INDLD-1+J ) = TMP
566: WORK( INDLLD-1+J ) = TMP*L( J )
567: 50 CONTINUE
568:
569: IF( NDEPTH.GT.0 ) THEN
570: * P and Q are index of the first and last eigenvalue to compute
571: * within the current block
572: P = INDEXW( WBEGIN-1+OLDFST )
573: Q = INDEXW( WBEGIN-1+OLDLST )
574: * Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET
575: * through the Q-OFFSET elements of these arrays are to be used.
576: * OFFSET = P-OLDFST
577: OFFSET = INDEXW( WBEGIN ) - 1
578: * perform limited bisection (if necessary) to get approximate
579: * eigenvalues to the precision needed.
580: CALL DLARRB( IN, D( IBEGIN ),
581: $ WORK(INDLLD+IBEGIN-1),
582: $ P, Q, RTOL1, RTOL2, OFFSET,
583: $ WORK(WBEGIN),WGAP(WBEGIN),WERR(WBEGIN),
584: $ WORK( INDWRK ), IWORK( IINDWK ),
585: $ PIVMIN, SPDIAM, IN, IINFO )
586: IF( IINFO.NE.0 ) THEN
587: INFO = -1
588: RETURN
589: ENDIF
590: * We also recompute the extremal gaps. W holds all eigenvalues
591: * of the unshifted matrix and must be used for computation
592: * of WGAP, the entries of WORK might stem from RRRs with
593: * different shifts. The gaps from WBEGIN-1+OLDFST to
594: * WBEGIN-1+OLDLST are correctly computed in DLARRB.
595: * However, we only allow the gaps to become greater since
596: * this is what should happen when we decrease WERR
597: IF( OLDFST.GT.1) THEN
598: WGAP( WBEGIN+OLDFST-2 ) =
599: $ MAX(WGAP(WBEGIN+OLDFST-2),
600: $ W(WBEGIN+OLDFST-1)-WERR(WBEGIN+OLDFST-1)
601: $ - W(WBEGIN+OLDFST-2)-WERR(WBEGIN+OLDFST-2) )
602: ENDIF
603: IF( WBEGIN + OLDLST -1 .LT. WEND ) THEN
604: WGAP( WBEGIN+OLDLST-1 ) =
605: $ MAX(WGAP(WBEGIN+OLDLST-1),
606: $ W(WBEGIN+OLDLST)-WERR(WBEGIN+OLDLST)
607: $ - W(WBEGIN+OLDLST-1)-WERR(WBEGIN+OLDLST-1) )
608: ENDIF
609: * Each time the eigenvalues in WORK get refined, we store
610: * the newly found approximation with all shifts applied in W
611: DO 53 J=OLDFST,OLDLST
612: W(WBEGIN+J-1) = WORK(WBEGIN+J-1)+SIGMA
613: 53 CONTINUE
614: END IF
615:
616: * Process the current node.
617: NEWFST = OLDFST
618: DO 140 J = OLDFST, OLDLST
619: IF( J.EQ.OLDLST ) THEN
620: * we are at the right end of the cluster, this is also the
621: * boundary of the child cluster
622: NEWLST = J
623: ELSE IF ( WGAP( WBEGIN + J -1).GE.
624: $ MINRGP* ABS( WORK(WBEGIN + J -1) ) ) THEN
625: * the right relative gap is big enough, the child cluster
626: * (NEWFST,..,NEWLST) is well separated from the following
627: NEWLST = J
628: ELSE
629: * inside a child cluster, the relative gap is not
630: * big enough.
631: GOTO 140
632: END IF
633:
634: * Compute size of child cluster found
635: NEWSIZ = NEWLST - NEWFST + 1
636:
637: * NEWFTT is the place in Z where the new RRR or the computed
638: * eigenvector is to be stored
639: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
640: * Store representation at location of the leftmost evalue
641: * of the cluster
642: NEWFTT = WBEGIN + NEWFST - 1
643: ELSE
644: IF(WBEGIN+NEWFST-1.LT.DOL) THEN
645: * Store representation at the left end of Z array
646: NEWFTT = DOL - 1
647: ELSEIF(WBEGIN+NEWFST-1.GT.DOU) THEN
648: * Store representation at the right end of Z array
649: NEWFTT = DOU
650: ELSE
651: NEWFTT = WBEGIN + NEWFST - 1
652: ENDIF
653: ENDIF
654:
655: IF( NEWSIZ.GT.1) THEN
656: *
657: * Current child is not a singleton but a cluster.
658: * Compute and store new representation of child.
659: *
660: *
661: * Compute left and right cluster gap.
662: *
663: * LGAP and RGAP are not computed from WORK because
664: * the eigenvalue approximations may stem from RRRs
665: * different shifts. However, W hold all eigenvalues
666: * of the unshifted matrix. Still, the entries in WGAP
667: * have to be computed from WORK since the entries
668: * in W might be of the same order so that gaps are not
669: * exhibited correctly for very close eigenvalues.
670: IF( NEWFST.EQ.1 ) THEN
671: LGAP = MAX( ZERO,
672: $ W(WBEGIN)-WERR(WBEGIN) - VL )
673: ELSE
674: LGAP = WGAP( WBEGIN+NEWFST-2 )
675: ENDIF
676: RGAP = WGAP( WBEGIN+NEWLST-1 )
677: *
678: * Compute left- and rightmost eigenvalue of child
679: * to high precision in order to shift as close
680: * as possible and obtain as large relative gaps
681: * as possible
682: *
683: DO 55 K =1,2
684: IF(K.EQ.1) THEN
685: P = INDEXW( WBEGIN-1+NEWFST )
686: ELSE
687: P = INDEXW( WBEGIN-1+NEWLST )
688: ENDIF
689: OFFSET = INDEXW( WBEGIN ) - 1
690: CALL DLARRB( IN, D(IBEGIN),
691: $ WORK( INDLLD+IBEGIN-1 ),P,P,
692: $ RQTOL, RQTOL, OFFSET,
693: $ WORK(WBEGIN),WGAP(WBEGIN),
694: $ WERR(WBEGIN),WORK( INDWRK ),
695: $ IWORK( IINDWK ), PIVMIN, SPDIAM,
696: $ IN, IINFO )
697: 55 CONTINUE
698: *
699: IF((WBEGIN+NEWLST-1.LT.DOL).OR.
700: $ (WBEGIN+NEWFST-1.GT.DOU)) THEN
701: * if the cluster contains no desired eigenvalues
702: * skip the computation of that branch of the rep. tree
703: *
704: * We could skip before the refinement of the extremal
705: * eigenvalues of the child, but then the representation
706: * tree could be different from the one when nothing is
707: * skipped. For this reason we skip at this place.
708: IDONE = IDONE + NEWLST - NEWFST + 1
709: GOTO 139
710: ENDIF
711: *
712: * Compute RRR of child cluster.
713: * Note that the new RRR is stored in Z
714: *
715: * DLARRF needs LWORK = 2*N
716: CALL DLARRF( IN, D( IBEGIN ), L( IBEGIN ),
717: $ WORK(INDLD+IBEGIN-1),
718: $ NEWFST, NEWLST, WORK(WBEGIN),
719: $ WGAP(WBEGIN), WERR(WBEGIN),
720: $ SPDIAM, LGAP, RGAP, PIVMIN, TAU,
721: $ WORK( INDIN1 ), WORK( INDIN2 ),
722: $ WORK( INDWRK ), IINFO )
723: * In the complex case, DLARRF cannot write
724: * the new RRR directly into Z and needs an intermediate
725: * workspace
726: DO 56 K = 1, IN-1
727: Z( IBEGIN+K-1, NEWFTT ) =
728: $ DCMPLX( WORK( INDIN1+K-1 ), ZERO )
729: Z( IBEGIN+K-1, NEWFTT+1 ) =
730: $ DCMPLX( WORK( INDIN2+K-1 ), ZERO )
731: 56 CONTINUE
732: Z( IEND, NEWFTT ) =
733: $ DCMPLX( WORK( INDIN1+IN-1 ), ZERO )
734: IF( IINFO.EQ.0 ) THEN
735: * a new RRR for the cluster was found by DLARRF
736: * update shift and store it
737: SSIGMA = SIGMA + TAU
738: Z( IEND, NEWFTT+1 ) = DCMPLX( SSIGMA, ZERO )
739: * WORK() are the midpoints and WERR() the semi-width
740: * Note that the entries in W are unchanged.
741: DO 116 K = NEWFST, NEWLST
742: FUDGE =
743: $ THREE*EPS*ABS(WORK(WBEGIN+K-1))
744: WORK( WBEGIN + K - 1 ) =
745: $ WORK( WBEGIN + K - 1) - TAU
746: FUDGE = FUDGE +
747: $ FOUR*EPS*ABS(WORK(WBEGIN+K-1))
748: * Fudge errors
749: WERR( WBEGIN + K - 1 ) =
750: $ WERR( WBEGIN + K - 1 ) + FUDGE
751: * Gaps are not fudged. Provided that WERR is small
752: * when eigenvalues are close, a zero gap indicates
753: * that a new representation is needed for resolving
754: * the cluster. A fudge could lead to a wrong decision
755: * of judging eigenvalues 'separated' which in
756: * reality are not. This could have a negative impact
757: * on the orthogonality of the computed eigenvectors.
758: 116 CONTINUE
759:
760: NCLUS = NCLUS + 1
761: K = NEWCLS + 2*NCLUS
762: IWORK( K-1 ) = NEWFST
763: IWORK( K ) = NEWLST
764: ELSE
765: INFO = -2
766: RETURN
767: ENDIF
768: ELSE
769: *
770: * Compute eigenvector of singleton
771: *
772: ITER = 0
773: *
774: TOL = FOUR * LOG(DBLE(IN)) * EPS
775: *
776: K = NEWFST
777: WINDEX = WBEGIN + K - 1
778: WINDMN = MAX(WINDEX - 1,1)
779: WINDPL = MIN(WINDEX + 1,M)
780: LAMBDA = WORK( WINDEX )
781: DONE = DONE + 1
782: * Check if eigenvector computation is to be skipped
783: IF((WINDEX.LT.DOL).OR.
784: $ (WINDEX.GT.DOU)) THEN
785: ESKIP = .TRUE.
786: GOTO 125
787: ELSE
788: ESKIP = .FALSE.
789: ENDIF
790: LEFT = WORK( WINDEX ) - WERR( WINDEX )
791: RIGHT = WORK( WINDEX ) + WERR( WINDEX )
792: INDEIG = INDEXW( WINDEX )
793: * Note that since we compute the eigenpairs for a child,
794: * all eigenvalue approximations are w.r.t the same shift.
795: * In this case, the entries in WORK should be used for
796: * computing the gaps since they exhibit even very small
797: * differences in the eigenvalues, as opposed to the
798: * entries in W which might "look" the same.
799:
800: IF( K .EQ. 1) THEN
801: * In the case RANGE='I' and with not much initial
802: * accuracy in LAMBDA and VL, the formula
803: * LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA )
804: * can lead to an overestimation of the left gap and
805: * thus to inadequately early RQI 'convergence'.
806: * Prevent this by forcing a small left gap.
807: LGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
808: ELSE
809: LGAP = WGAP(WINDMN)
810: ENDIF
811: IF( K .EQ. IM) THEN
812: * In the case RANGE='I' and with not much initial
813: * accuracy in LAMBDA and VU, the formula
814: * can lead to an overestimation of the right gap and
815: * thus to inadequately early RQI 'convergence'.
816: * Prevent this by forcing a small right gap.
817: RGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
818: ELSE
819: RGAP = WGAP(WINDEX)
820: ENDIF
821: GAP = MIN( LGAP, RGAP )
822: IF(( K .EQ. 1).OR.(K .EQ. IM)) THEN
823: * The eigenvector support can become wrong
824: * because significant entries could be cut off due to a
825: * large GAPTOL parameter in LAR1V. Prevent this.
826: GAPTOL = ZERO
827: ELSE
828: GAPTOL = GAP * EPS
829: ENDIF
830: ISUPMN = IN
831: ISUPMX = 1
832: * Update WGAP so that it holds the minimum gap
833: * to the left or the right. This is crucial in the
834: * case where bisection is used to ensure that the
835: * eigenvalue is refined up to the required precision.
836: * The correct value is restored afterwards.
837: SAVGAP = WGAP(WINDEX)
838: WGAP(WINDEX) = GAP
839: * We want to use the Rayleigh Quotient Correction
840: * as often as possible since it converges quadratically
841: * when we are close enough to the desired eigenvalue.
842: * However, the Rayleigh Quotient can have the wrong sign
843: * and lead us away from the desired eigenvalue. In this
844: * case, the best we can do is to use bisection.
845: USEDBS = .FALSE.
846: USEDRQ = .FALSE.
847: * Bisection is initially turned off unless it is forced
848: NEEDBS = .NOT.TRYRQC
849: 120 CONTINUE
850: * Check if bisection should be used to refine eigenvalue
851: IF(NEEDBS) THEN
852: * Take the bisection as new iterate
853: USEDBS = .TRUE.
854: ITMP1 = IWORK( IINDR+WINDEX )
855: OFFSET = INDEXW( WBEGIN ) - 1
856: CALL DLARRB( IN, D(IBEGIN),
857: $ WORK(INDLLD+IBEGIN-1),INDEIG,INDEIG,
858: $ ZERO, TWO*EPS, OFFSET,
859: $ WORK(WBEGIN),WGAP(WBEGIN),
860: $ WERR(WBEGIN),WORK( INDWRK ),
861: $ IWORK( IINDWK ), PIVMIN, SPDIAM,
862: $ ITMP1, IINFO )
863: IF( IINFO.NE.0 ) THEN
864: INFO = -3
865: RETURN
866: ENDIF
867: LAMBDA = WORK( WINDEX )
868: * Reset twist index from inaccurate LAMBDA to
869: * force computation of true MINGMA
870: IWORK( IINDR+WINDEX ) = 0
871: ENDIF
872: * Given LAMBDA, compute the eigenvector.
873: CALL ZLAR1V( IN, 1, IN, LAMBDA, D( IBEGIN ),
874: $ L( IBEGIN ), WORK(INDLD+IBEGIN-1),
875: $ WORK(INDLLD+IBEGIN-1),
876: $ PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
877: $ .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
878: $ IWORK( IINDR+WINDEX ), ISUPPZ( 2*WINDEX-1 ),
879: $ NRMINV, RESID, RQCORR, WORK( INDWRK ) )
880: IF(ITER .EQ. 0) THEN
881: BSTRES = RESID
882: BSTW = LAMBDA
883: ELSEIF(RESID.LT.BSTRES) THEN
884: BSTRES = RESID
885: BSTW = LAMBDA
886: ENDIF
887: ISUPMN = MIN(ISUPMN,ISUPPZ( 2*WINDEX-1 ))
888: ISUPMX = MAX(ISUPMX,ISUPPZ( 2*WINDEX ))
889: ITER = ITER + 1
890:
891: * sin alpha <= |resid|/gap
892: * Note that both the residual and the gap are
893: * proportional to the matrix, so ||T|| doesn't play
894: * a role in the quotient
895:
896: *
897: * Convergence test for Rayleigh-Quotient iteration
898: * (omitted when Bisection has been used)
899: *
900: IF( RESID.GT.TOL*GAP .AND. ABS( RQCORR ).GT.
901: $ RQTOL*ABS( LAMBDA ) .AND. .NOT. USEDBS)
902: $ THEN
903: * We need to check that the RQCORR update doesn't
904: * move the eigenvalue away from the desired one and
905: * towards a neighbor. -> protection with bisection
906: IF(INDEIG.LE.NEGCNT) THEN
907: * The wanted eigenvalue lies to the left
908: SGNDEF = -ONE
909: ELSE
910: * The wanted eigenvalue lies to the right
911: SGNDEF = ONE
912: ENDIF
913: * We only use the RQCORR if it improves the
914: * the iterate reasonably.
915: IF( ( RQCORR*SGNDEF.GE.ZERO )
916: $ .AND.( LAMBDA + RQCORR.LE. RIGHT)
917: $ .AND.( LAMBDA + RQCORR.GE. LEFT)
918: $ ) THEN
919: USEDRQ = .TRUE.
920: * Store new midpoint of bisection interval in WORK
921: IF(SGNDEF.EQ.ONE) THEN
922: * The current LAMBDA is on the left of the true
923: * eigenvalue
924: LEFT = LAMBDA
925: * We prefer to assume that the error estimate
926: * is correct. We could make the interval not
927: * as a bracket but to be modified if the RQCORR
928: * chooses to. In this case, the RIGHT side should
929: * be modified as follows:
930: * RIGHT = MAX(RIGHT, LAMBDA + RQCORR)
931: ELSE
932: * The current LAMBDA is on the right of the true
933: * eigenvalue
934: RIGHT = LAMBDA
935: * See comment about assuming the error estimate is
936: * correct above.
937: * LEFT = MIN(LEFT, LAMBDA + RQCORR)
938: ENDIF
939: WORK( WINDEX ) =
940: $ HALF * (RIGHT + LEFT)
941: * Take RQCORR since it has the correct sign and
942: * improves the iterate reasonably
943: LAMBDA = LAMBDA + RQCORR
944: * Update width of error interval
945: WERR( WINDEX ) =
946: $ HALF * (RIGHT-LEFT)
947: ELSE
948: NEEDBS = .TRUE.
949: ENDIF
950: IF(RIGHT-LEFT.LT.RQTOL*ABS(LAMBDA)) THEN
951: * The eigenvalue is computed to bisection accuracy
952: * compute eigenvector and stop
953: USEDBS = .TRUE.
954: GOTO 120
955: ELSEIF( ITER.LT.MAXITR ) THEN
956: GOTO 120
957: ELSEIF( ITER.EQ.MAXITR ) THEN
958: NEEDBS = .TRUE.
959: GOTO 120
960: ELSE
961: INFO = 5
962: RETURN
963: END IF
964: ELSE
965: STP2II = .FALSE.
966: IF(USEDRQ .AND. USEDBS .AND.
967: $ BSTRES.LE.RESID) THEN
968: LAMBDA = BSTW
969: STP2II = .TRUE.
970: ENDIF
971: IF (STP2II) THEN
972: * improve error angle by second step
973: CALL ZLAR1V( IN, 1, IN, LAMBDA,
974: $ D( IBEGIN ), L( IBEGIN ),
975: $ WORK(INDLD+IBEGIN-1),
976: $ WORK(INDLLD+IBEGIN-1),
977: $ PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
978: $ .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
979: $ IWORK( IINDR+WINDEX ),
980: $ ISUPPZ( 2*WINDEX-1 ),
981: $ NRMINV, RESID, RQCORR, WORK( INDWRK ) )
982: ENDIF
983: WORK( WINDEX ) = LAMBDA
984: END IF
985: *
986: * Compute FP-vector support w.r.t. whole matrix
987: *
988: ISUPPZ( 2*WINDEX-1 ) = ISUPPZ( 2*WINDEX-1 )+OLDIEN
989: ISUPPZ( 2*WINDEX ) = ISUPPZ( 2*WINDEX )+OLDIEN
990: ZFROM = ISUPPZ( 2*WINDEX-1 )
991: ZTO = ISUPPZ( 2*WINDEX )
992: ISUPMN = ISUPMN + OLDIEN
993: ISUPMX = ISUPMX + OLDIEN
994: * Ensure vector is ok if support in the RQI has changed
995: IF(ISUPMN.LT.ZFROM) THEN
996: DO 122 II = ISUPMN,ZFROM-1
997: Z( II, WINDEX ) = ZERO
998: 122 CONTINUE
999: ENDIF
1000: IF(ISUPMX.GT.ZTO) THEN
1001: DO 123 II = ZTO+1,ISUPMX
1002: Z( II, WINDEX ) = ZERO
1003: 123 CONTINUE
1004: ENDIF
1005: CALL ZDSCAL( ZTO-ZFROM+1, NRMINV,
1006: $ Z( ZFROM, WINDEX ), 1 )
1007: 125 CONTINUE
1008: * Update W
1009: W( WINDEX ) = LAMBDA+SIGMA
1010: * Recompute the gaps on the left and right
1011: * But only allow them to become larger and not
1012: * smaller (which can only happen through "bad"
1013: * cancellation and doesn't reflect the theory
1014: * where the initial gaps are underestimated due
1015: * to WERR being too crude.)
1016: IF(.NOT.ESKIP) THEN
1017: IF( K.GT.1) THEN
1018: WGAP( WINDMN ) = MAX( WGAP(WINDMN),
1019: $ W(WINDEX)-WERR(WINDEX)
1020: $ - W(WINDMN)-WERR(WINDMN) )
1021: ENDIF
1022: IF( WINDEX.LT.WEND ) THEN
1023: WGAP( WINDEX ) = MAX( SAVGAP,
1024: $ W( WINDPL )-WERR( WINDPL )
1025: $ - W( WINDEX )-WERR( WINDEX) )
1026: ENDIF
1027: ENDIF
1028: IDONE = IDONE + 1
1029: ENDIF
1030: * here ends the code for the current child
1031: *
1032: 139 CONTINUE
1033: * Proceed to any remaining child nodes
1034: NEWFST = J + 1
1035: 140 CONTINUE
1036: 150 CONTINUE
1037: NDEPTH = NDEPTH + 1
1038: GO TO 40
1039: END IF
1040: IBEGIN = IEND + 1
1041: WBEGIN = WEND + 1
1042: 170 CONTINUE
1043: *
1044:
1045: RETURN
1046: *
1047: * End of ZLARRV
1048: *
1049: END
CVSweb interface <joel.bertrand@systella.fr>