1: *> \brief \b DLARRV computes the eigenvectors of the tridiagonal matrix T = L D LT given L, D and the eigenvalues of L D LT.
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download DLARRV + dependencies
10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarrv.f">
11: *> [TGZ]</a>
12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarrv.f">
13: *> [ZIP]</a>
14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarrv.f">
15: *> [TXT]</a>
16: *> \endhtmlonly
17: *
18: * Definition:
19: * ===========
20: *
21: * SUBROUTINE DLARRV( 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: * DOUBLE PRECISION Z( LDZ, * )
37: * ..
38: *
39: *
40: *> \par Purpose:
41: * =============
42: *>
43: *> \verbatim
44: *>
45: *> DLARRV 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 DOUBLE PRECISION 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 DLARRV.
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 2015
267: *
268: *> \ingroup doubleOTHERauxiliary
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 DLARRV( 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.6.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 2015
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: DOUBLE PRECISION Z( LDZ, * )
301: * ..
302: *
303: * =====================================================================
304: *
305: * .. Parameters ..
306: INTEGER MAXITR
307: PARAMETER ( MAXITR = 10 )
308: DOUBLE PRECISION ZERO, ONE, TWO, THREE, FOUR, HALF
309: PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0,
310: $ TWO = 2.0D0, THREE = 3.0D0,
311: $ FOUR = 4.0D0, HALF = 0.5D0)
312: * ..
313: * .. Local Scalars ..
314: LOGICAL ESKIP, NEEDBS, STP2II, TRYRQC, USEDBS, USEDRQ
315: INTEGER DONE, I, IBEGIN, IDONE, IEND, II, IINDC1,
316: $ IINDC2, IINDR, IINDWK, IINFO, IM, IN, INDEIG,
317: $ INDLD, INDLLD, INDWRK, ISUPMN, ISUPMX, ITER,
318: $ ITMP1, J, JBLK, K, MINIWSIZE, MINWSIZE, NCLUS,
319: $ NDEPTH, NEGCNT, NEWCLS, NEWFST, NEWFTT, NEWLST,
320: $ NEWSIZ, OFFSET, OLDCLS, OLDFST, OLDIEN, OLDLST,
321: $ OLDNCL, P, PARITY, Q, WBEGIN, WEND, WINDEX,
322: $ WINDMN, WINDPL, ZFROM, ZTO, ZUSEDL, ZUSEDU,
323: $ ZUSEDW
324: DOUBLE PRECISION BSTRES, BSTW, EPS, FUDGE, GAP, GAPTOL, GL, GU,
325: $ LAMBDA, LEFT, LGAP, MINGMA, NRMINV, RESID,
326: $ RGAP, RIGHT, RQCORR, RQTOL, SAVGAP, SGNDEF,
327: $ SIGMA, SPDIAM, SSIGMA, TAU, TMP, TOL, ZTZ
328: * ..
329: * .. External Functions ..
330: DOUBLE PRECISION DLAMCH
331: EXTERNAL DLAMCH
332: * ..
333: * .. External Subroutines ..
334: EXTERNAL DCOPY, DLAR1V, DLARRB, DLARRF, DLASET,
335: $ DSCAL
336: * ..
337: * .. Intrinsic Functions ..
338: INTRINSIC ABS, DBLE, MAX, MIN
339: * ..
340: * .. Executable Statements ..
341: * ..
342:
343: INFO = 0
344: * The first N entries of WORK are reserved for the eigenvalues
345: INDLD = N+1
346: INDLLD= 2*N+1
347: INDWRK= 3*N+1
348: MINWSIZE = 12 * N
349:
350: DO 5 I= 1,MINWSIZE
351: WORK( I ) = ZERO
352: 5 CONTINUE
353:
354: * IWORK(IINDR+1:IINDR+N) hold the twist indices R for the
355: * factorization used to compute the FP vector
356: IINDR = 0
357: * IWORK(IINDC1+1:IINC2+N) are used to store the clusters of the current
358: * layer and the one above.
359: IINDC1 = N
360: IINDC2 = 2*N
361: IINDWK = 3*N + 1
362:
363: MINIWSIZE = 7 * N
364: DO 10 I= 1,MINIWSIZE
365: IWORK( I ) = 0
366: 10 CONTINUE
367:
368: ZUSEDL = 1
369: IF(DOL.GT.1) THEN
370: * Set lower bound for use of Z
371: ZUSEDL = DOL-1
372: ENDIF
373: ZUSEDU = M
374: IF(DOU.LT.M) THEN
375: * Set lower bound for use of Z
376: ZUSEDU = DOU+1
377: ENDIF
378: * The width of the part of Z that is used
379: ZUSEDW = ZUSEDU - ZUSEDL + 1
380:
381:
382: CALL DLASET( 'Full', N, ZUSEDW, ZERO, ZERO,
383: $ Z(1,ZUSEDL), LDZ )
384:
385: EPS = DLAMCH( 'Precision' )
386: RQTOL = TWO * EPS
387: *
388: * Set expert flags for standard code.
389: TRYRQC = .TRUE.
390:
391: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
392: ELSE
393: * Only selected eigenpairs are computed. Since the other evalues
394: * are not refined by RQ iteration, bisection has to compute to full
395: * accuracy.
396: RTOL1 = FOUR * EPS
397: RTOL2 = FOUR * EPS
398: ENDIF
399:
400: * The entries WBEGIN:WEND in W, WERR, WGAP correspond to the
401: * desired eigenvalues. The support of the nonzero eigenvector
402: * entries is contained in the interval IBEGIN:IEND.
403: * Remark that if k eigenpairs are desired, then the eigenvectors
404: * are stored in k contiguous columns of Z.
405:
406: * DONE is the number of eigenvectors already computed
407: DONE = 0
408: IBEGIN = 1
409: WBEGIN = 1
410: DO 170 JBLK = 1, IBLOCK( M )
411: IEND = ISPLIT( JBLK )
412: SIGMA = L( IEND )
413: * Find the eigenvectors of the submatrix indexed IBEGIN
414: * through IEND.
415: WEND = WBEGIN - 1
416: 15 CONTINUE
417: IF( WEND.LT.M ) THEN
418: IF( IBLOCK( WEND+1 ).EQ.JBLK ) THEN
419: WEND = WEND + 1
420: GO TO 15
421: END IF
422: END IF
423: IF( WEND.LT.WBEGIN ) THEN
424: IBEGIN = IEND + 1
425: GO TO 170
426: ELSEIF( (WEND.LT.DOL).OR.(WBEGIN.GT.DOU) ) THEN
427: IBEGIN = IEND + 1
428: WBEGIN = WEND + 1
429: GO TO 170
430: END IF
431:
432: * Find local spectral diameter of the block
433: GL = GERS( 2*IBEGIN-1 )
434: GU = GERS( 2*IBEGIN )
435: DO 20 I = IBEGIN+1 , IEND
436: GL = MIN( GERS( 2*I-1 ), GL )
437: GU = MAX( GERS( 2*I ), GU )
438: 20 CONTINUE
439: SPDIAM = GU - GL
440:
441: * OLDIEN is the last index of the previous block
442: OLDIEN = IBEGIN - 1
443: * Calculate the size of the current block
444: IN = IEND - IBEGIN + 1
445: * The number of eigenvalues in the current block
446: IM = WEND - WBEGIN + 1
447:
448: * This is for a 1x1 block
449: IF( IBEGIN.EQ.IEND ) THEN
450: DONE = DONE+1
451: Z( IBEGIN, WBEGIN ) = ONE
452: ISUPPZ( 2*WBEGIN-1 ) = IBEGIN
453: ISUPPZ( 2*WBEGIN ) = IBEGIN
454: W( WBEGIN ) = W( WBEGIN ) + SIGMA
455: WORK( WBEGIN ) = W( WBEGIN )
456: IBEGIN = IEND + 1
457: WBEGIN = WBEGIN + 1
458: GO TO 170
459: END IF
460:
461: * The desired (shifted) eigenvalues are stored in W(WBEGIN:WEND)
462: * Note that these can be approximations, in this case, the corresp.
463: * entries of WERR give the size of the uncertainty interval.
464: * The eigenvalue approximations will be refined when necessary as
465: * high relative accuracy is required for the computation of the
466: * corresponding eigenvectors.
467: CALL DCOPY( IM, W( WBEGIN ), 1,
468: $ WORK( WBEGIN ), 1 )
469:
470: * We store in W the eigenvalue approximations w.r.t. the original
471: * matrix T.
472: DO 30 I=1,IM
473: W(WBEGIN+I-1) = W(WBEGIN+I-1)+SIGMA
474: 30 CONTINUE
475:
476:
477: * NDEPTH is the current depth of the representation tree
478: NDEPTH = 0
479: * PARITY is either 1 or 0
480: PARITY = 1
481: * NCLUS is the number of clusters for the next level of the
482: * representation tree, we start with NCLUS = 1 for the root
483: NCLUS = 1
484: IWORK( IINDC1+1 ) = 1
485: IWORK( IINDC1+2 ) = IM
486:
487: * IDONE is the number of eigenvectors already computed in the current
488: * block
489: IDONE = 0
490: * loop while( IDONE.LT.IM )
491: * generate the representation tree for the current block and
492: * compute the eigenvectors
493: 40 CONTINUE
494: IF( IDONE.LT.IM ) THEN
495: * This is a crude protection against infinitely deep trees
496: IF( NDEPTH.GT.M ) THEN
497: INFO = -2
498: RETURN
499: ENDIF
500: * breadth first processing of the current level of the representation
501: * tree: OLDNCL = number of clusters on current level
502: OLDNCL = NCLUS
503: * reset NCLUS to count the number of child clusters
504: NCLUS = 0
505: *
506: PARITY = 1 - PARITY
507: IF( PARITY.EQ.0 ) THEN
508: OLDCLS = IINDC1
509: NEWCLS = IINDC2
510: ELSE
511: OLDCLS = IINDC2
512: NEWCLS = IINDC1
513: END IF
514: * Process the clusters on the current level
515: DO 150 I = 1, OLDNCL
516: J = OLDCLS + 2*I
517: * OLDFST, OLDLST = first, last index of current cluster.
518: * cluster indices start with 1 and are relative
519: * to WBEGIN when accessing W, WGAP, WERR, Z
520: OLDFST = IWORK( J-1 )
521: OLDLST = IWORK( J )
522: IF( NDEPTH.GT.0 ) THEN
523: * Retrieve relatively robust representation (RRR) of cluster
524: * that has been computed at the previous level
525: * The RRR is stored in Z and overwritten once the eigenvectors
526: * have been computed or when the cluster is refined
527:
528: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
529: * Get representation from location of the leftmost evalue
530: * of the cluster
531: J = WBEGIN + OLDFST - 1
532: ELSE
533: IF(WBEGIN+OLDFST-1.LT.DOL) THEN
534: * Get representation from the left end of Z array
535: J = DOL - 1
536: ELSEIF(WBEGIN+OLDFST-1.GT.DOU) THEN
537: * Get representation from the right end of Z array
538: J = DOU
539: ELSE
540: J = WBEGIN + OLDFST - 1
541: ENDIF
542: ENDIF
543: CALL DCOPY( IN, Z( IBEGIN, J ), 1, D( IBEGIN ), 1 )
544: CALL DCOPY( IN-1, Z( IBEGIN, J+1 ), 1, L( IBEGIN ),
545: $ 1 )
546: SIGMA = Z( IEND, J+1 )
547:
548: * Set the corresponding entries in Z to zero
549: CALL DLASET( 'Full', IN, 2, ZERO, ZERO,
550: $ Z( IBEGIN, J), LDZ )
551: END IF
552:
553: * Compute DL and DLL of current RRR
554: DO 50 J = IBEGIN, IEND-1
555: TMP = D( J )*L( J )
556: WORK( INDLD-1+J ) = TMP
557: WORK( INDLLD-1+J ) = TMP*L( J )
558: 50 CONTINUE
559:
560: IF( NDEPTH.GT.0 ) THEN
561: * P and Q are index of the first and last eigenvalue to compute
562: * within the current block
563: P = INDEXW( WBEGIN-1+OLDFST )
564: Q = INDEXW( WBEGIN-1+OLDLST )
565: * Offset for the arrays WORK, WGAP and WERR, i.e., the P-OFFSET
566: * through the Q-OFFSET elements of these arrays are to be used.
567: * OFFSET = P-OLDFST
568: OFFSET = INDEXW( WBEGIN ) - 1
569: * perform limited bisection (if necessary) to get approximate
570: * eigenvalues to the precision needed.
571: CALL DLARRB( IN, D( IBEGIN ),
572: $ WORK(INDLLD+IBEGIN-1),
573: $ P, Q, RTOL1, RTOL2, OFFSET,
574: $ WORK(WBEGIN),WGAP(WBEGIN),WERR(WBEGIN),
575: $ WORK( INDWRK ), IWORK( IINDWK ),
576: $ PIVMIN, SPDIAM, IN, IINFO )
577: IF( IINFO.NE.0 ) THEN
578: INFO = -1
579: RETURN
580: ENDIF
581: * We also recompute the extremal gaps. W holds all eigenvalues
582: * of the unshifted matrix and must be used for computation
583: * of WGAP, the entries of WORK might stem from RRRs with
584: * different shifts. The gaps from WBEGIN-1+OLDFST to
585: * WBEGIN-1+OLDLST are correctly computed in DLARRB.
586: * However, we only allow the gaps to become greater since
587: * this is what should happen when we decrease WERR
588: IF( OLDFST.GT.1) THEN
589: WGAP( WBEGIN+OLDFST-2 ) =
590: $ MAX(WGAP(WBEGIN+OLDFST-2),
591: $ W(WBEGIN+OLDFST-1)-WERR(WBEGIN+OLDFST-1)
592: $ - W(WBEGIN+OLDFST-2)-WERR(WBEGIN+OLDFST-2) )
593: ENDIF
594: IF( WBEGIN + OLDLST -1 .LT. WEND ) THEN
595: WGAP( WBEGIN+OLDLST-1 ) =
596: $ MAX(WGAP(WBEGIN+OLDLST-1),
597: $ W(WBEGIN+OLDLST)-WERR(WBEGIN+OLDLST)
598: $ - W(WBEGIN+OLDLST-1)-WERR(WBEGIN+OLDLST-1) )
599: ENDIF
600: * Each time the eigenvalues in WORK get refined, we store
601: * the newly found approximation with all shifts applied in W
602: DO 53 J=OLDFST,OLDLST
603: W(WBEGIN+J-1) = WORK(WBEGIN+J-1)+SIGMA
604: 53 CONTINUE
605: END IF
606:
607: * Process the current node.
608: NEWFST = OLDFST
609: DO 140 J = OLDFST, OLDLST
610: IF( J.EQ.OLDLST ) THEN
611: * we are at the right end of the cluster, this is also the
612: * boundary of the child cluster
613: NEWLST = J
614: ELSE IF ( WGAP( WBEGIN + J -1).GE.
615: $ MINRGP* ABS( WORK(WBEGIN + J -1) ) ) THEN
616: * the right relative gap is big enough, the child cluster
617: * (NEWFST,..,NEWLST) is well separated from the following
618: NEWLST = J
619: ELSE
620: * inside a child cluster, the relative gap is not
621: * big enough.
622: GOTO 140
623: END IF
624:
625: * Compute size of child cluster found
626: NEWSIZ = NEWLST - NEWFST + 1
627:
628: * NEWFTT is the place in Z where the new RRR or the computed
629: * eigenvector is to be stored
630: IF((DOL.EQ.1).AND.(DOU.EQ.M)) THEN
631: * Store representation at location of the leftmost evalue
632: * of the cluster
633: NEWFTT = WBEGIN + NEWFST - 1
634: ELSE
635: IF(WBEGIN+NEWFST-1.LT.DOL) THEN
636: * Store representation at the left end of Z array
637: NEWFTT = DOL - 1
638: ELSEIF(WBEGIN+NEWFST-1.GT.DOU) THEN
639: * Store representation at the right end of Z array
640: NEWFTT = DOU
641: ELSE
642: NEWFTT = WBEGIN + NEWFST - 1
643: ENDIF
644: ENDIF
645:
646: IF( NEWSIZ.GT.1) THEN
647: *
648: * Current child is not a singleton but a cluster.
649: * Compute and store new representation of child.
650: *
651: *
652: * Compute left and right cluster gap.
653: *
654: * LGAP and RGAP are not computed from WORK because
655: * the eigenvalue approximations may stem from RRRs
656: * different shifts. However, W hold all eigenvalues
657: * of the unshifted matrix. Still, the entries in WGAP
658: * have to be computed from WORK since the entries
659: * in W might be of the same order so that gaps are not
660: * exhibited correctly for very close eigenvalues.
661: IF( NEWFST.EQ.1 ) THEN
662: LGAP = MAX( ZERO,
663: $ W(WBEGIN)-WERR(WBEGIN) - VL )
664: ELSE
665: LGAP = WGAP( WBEGIN+NEWFST-2 )
666: ENDIF
667: RGAP = WGAP( WBEGIN+NEWLST-1 )
668: *
669: * Compute left- and rightmost eigenvalue of child
670: * to high precision in order to shift as close
671: * as possible and obtain as large relative gaps
672: * as possible
673: *
674: DO 55 K =1,2
675: IF(K.EQ.1) THEN
676: P = INDEXW( WBEGIN-1+NEWFST )
677: ELSE
678: P = INDEXW( WBEGIN-1+NEWLST )
679: ENDIF
680: OFFSET = INDEXW( WBEGIN ) - 1
681: CALL DLARRB( IN, D(IBEGIN),
682: $ WORK( INDLLD+IBEGIN-1 ),P,P,
683: $ RQTOL, RQTOL, OFFSET,
684: $ WORK(WBEGIN),WGAP(WBEGIN),
685: $ WERR(WBEGIN),WORK( INDWRK ),
686: $ IWORK( IINDWK ), PIVMIN, SPDIAM,
687: $ IN, IINFO )
688: 55 CONTINUE
689: *
690: IF((WBEGIN+NEWLST-1.LT.DOL).OR.
691: $ (WBEGIN+NEWFST-1.GT.DOU)) THEN
692: * if the cluster contains no desired eigenvalues
693: * skip the computation of that branch of the rep. tree
694: *
695: * We could skip before the refinement of the extremal
696: * eigenvalues of the child, but then the representation
697: * tree could be different from the one when nothing is
698: * skipped. For this reason we skip at this place.
699: IDONE = IDONE + NEWLST - NEWFST + 1
700: GOTO 139
701: ENDIF
702: *
703: * Compute RRR of child cluster.
704: * Note that the new RRR is stored in Z
705: *
706: * DLARRF needs LWORK = 2*N
707: CALL DLARRF( IN, D( IBEGIN ), L( IBEGIN ),
708: $ WORK(INDLD+IBEGIN-1),
709: $ NEWFST, NEWLST, WORK(WBEGIN),
710: $ WGAP(WBEGIN), WERR(WBEGIN),
711: $ SPDIAM, LGAP, RGAP, PIVMIN, TAU,
712: $ Z(IBEGIN, NEWFTT),Z(IBEGIN, NEWFTT+1),
713: $ WORK( INDWRK ), IINFO )
714: IF( IINFO.EQ.0 ) THEN
715: * a new RRR for the cluster was found by DLARRF
716: * update shift and store it
717: SSIGMA = SIGMA + TAU
718: Z( IEND, NEWFTT+1 ) = SSIGMA
719: * WORK() are the midpoints and WERR() the semi-width
720: * Note that the entries in W are unchanged.
721: DO 116 K = NEWFST, NEWLST
722: FUDGE =
723: $ THREE*EPS*ABS(WORK(WBEGIN+K-1))
724: WORK( WBEGIN + K - 1 ) =
725: $ WORK( WBEGIN + K - 1) - TAU
726: FUDGE = FUDGE +
727: $ FOUR*EPS*ABS(WORK(WBEGIN+K-1))
728: * Fudge errors
729: WERR( WBEGIN + K - 1 ) =
730: $ WERR( WBEGIN + K - 1 ) + FUDGE
731: * Gaps are not fudged. Provided that WERR is small
732: * when eigenvalues are close, a zero gap indicates
733: * that a new representation is needed for resolving
734: * the cluster. A fudge could lead to a wrong decision
735: * of judging eigenvalues 'separated' which in
736: * reality are not. This could have a negative impact
737: * on the orthogonality of the computed eigenvectors.
738: 116 CONTINUE
739:
740: NCLUS = NCLUS + 1
741: K = NEWCLS + 2*NCLUS
742: IWORK( K-1 ) = NEWFST
743: IWORK( K ) = NEWLST
744: ELSE
745: INFO = -2
746: RETURN
747: ENDIF
748: ELSE
749: *
750: * Compute eigenvector of singleton
751: *
752: ITER = 0
753: *
754: TOL = FOUR * LOG(DBLE(IN)) * EPS
755: *
756: K = NEWFST
757: WINDEX = WBEGIN + K - 1
758: WINDMN = MAX(WINDEX - 1,1)
759: WINDPL = MIN(WINDEX + 1,M)
760: LAMBDA = WORK( WINDEX )
761: DONE = DONE + 1
762: * Check if eigenvector computation is to be skipped
763: IF((WINDEX.LT.DOL).OR.
764: $ (WINDEX.GT.DOU)) THEN
765: ESKIP = .TRUE.
766: GOTO 125
767: ELSE
768: ESKIP = .FALSE.
769: ENDIF
770: LEFT = WORK( WINDEX ) - WERR( WINDEX )
771: RIGHT = WORK( WINDEX ) + WERR( WINDEX )
772: INDEIG = INDEXW( WINDEX )
773: * Note that since we compute the eigenpairs for a child,
774: * all eigenvalue approximations are w.r.t the same shift.
775: * In this case, the entries in WORK should be used for
776: * computing the gaps since they exhibit even very small
777: * differences in the eigenvalues, as opposed to the
778: * entries in W which might "look" the same.
779:
780: IF( K .EQ. 1) THEN
781: * In the case RANGE='I' and with not much initial
782: * accuracy in LAMBDA and VL, the formula
783: * LGAP = MAX( ZERO, (SIGMA - VL) + LAMBDA )
784: * can lead to an overestimation of the left gap and
785: * thus to inadequately early RQI 'convergence'.
786: * Prevent this by forcing a small left gap.
787: LGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
788: ELSE
789: LGAP = WGAP(WINDMN)
790: ENDIF
791: IF( K .EQ. IM) THEN
792: * In the case RANGE='I' and with not much initial
793: * accuracy in LAMBDA and VU, the formula
794: * can lead to an overestimation of the right gap and
795: * thus to inadequately early RQI 'convergence'.
796: * Prevent this by forcing a small right gap.
797: RGAP = EPS*MAX(ABS(LEFT),ABS(RIGHT))
798: ELSE
799: RGAP = WGAP(WINDEX)
800: ENDIF
801: GAP = MIN( LGAP, RGAP )
802: IF(( K .EQ. 1).OR.(K .EQ. IM)) THEN
803: * The eigenvector support can become wrong
804: * because significant entries could be cut off due to a
805: * large GAPTOL parameter in LAR1V. Prevent this.
806: GAPTOL = ZERO
807: ELSE
808: GAPTOL = GAP * EPS
809: ENDIF
810: ISUPMN = IN
811: ISUPMX = 1
812: * Update WGAP so that it holds the minimum gap
813: * to the left or the right. This is crucial in the
814: * case where bisection is used to ensure that the
815: * eigenvalue is refined up to the required precision.
816: * The correct value is restored afterwards.
817: SAVGAP = WGAP(WINDEX)
818: WGAP(WINDEX) = GAP
819: * We want to use the Rayleigh Quotient Correction
820: * as often as possible since it converges quadratically
821: * when we are close enough to the desired eigenvalue.
822: * However, the Rayleigh Quotient can have the wrong sign
823: * and lead us away from the desired eigenvalue. In this
824: * case, the best we can do is to use bisection.
825: USEDBS = .FALSE.
826: USEDRQ = .FALSE.
827: * Bisection is initially turned off unless it is forced
828: NEEDBS = .NOT.TRYRQC
829: 120 CONTINUE
830: * Check if bisection should be used to refine eigenvalue
831: IF(NEEDBS) THEN
832: * Take the bisection as new iterate
833: USEDBS = .TRUE.
834: ITMP1 = IWORK( IINDR+WINDEX )
835: OFFSET = INDEXW( WBEGIN ) - 1
836: CALL DLARRB( IN, D(IBEGIN),
837: $ WORK(INDLLD+IBEGIN-1),INDEIG,INDEIG,
838: $ ZERO, TWO*EPS, OFFSET,
839: $ WORK(WBEGIN),WGAP(WBEGIN),
840: $ WERR(WBEGIN),WORK( INDWRK ),
841: $ IWORK( IINDWK ), PIVMIN, SPDIAM,
842: $ ITMP1, IINFO )
843: IF( IINFO.NE.0 ) THEN
844: INFO = -3
845: RETURN
846: ENDIF
847: LAMBDA = WORK( WINDEX )
848: * Reset twist index from inaccurate LAMBDA to
849: * force computation of true MINGMA
850: IWORK( IINDR+WINDEX ) = 0
851: ENDIF
852: * Given LAMBDA, compute the eigenvector.
853: CALL DLAR1V( IN, 1, IN, LAMBDA, D( IBEGIN ),
854: $ L( IBEGIN ), WORK(INDLD+IBEGIN-1),
855: $ WORK(INDLLD+IBEGIN-1),
856: $ PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
857: $ .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
858: $ IWORK( IINDR+WINDEX ), ISUPPZ( 2*WINDEX-1 ),
859: $ NRMINV, RESID, RQCORR, WORK( INDWRK ) )
860: IF(ITER .EQ. 0) THEN
861: BSTRES = RESID
862: BSTW = LAMBDA
863: ELSEIF(RESID.LT.BSTRES) THEN
864: BSTRES = RESID
865: BSTW = LAMBDA
866: ENDIF
867: ISUPMN = MIN(ISUPMN,ISUPPZ( 2*WINDEX-1 ))
868: ISUPMX = MAX(ISUPMX,ISUPPZ( 2*WINDEX ))
869: ITER = ITER + 1
870:
871: * sin alpha <= |resid|/gap
872: * Note that both the residual and the gap are
873: * proportional to the matrix, so ||T|| doesn't play
874: * a role in the quotient
875:
876: *
877: * Convergence test for Rayleigh-Quotient iteration
878: * (omitted when Bisection has been used)
879: *
880: IF( RESID.GT.TOL*GAP .AND. ABS( RQCORR ).GT.
881: $ RQTOL*ABS( LAMBDA ) .AND. .NOT. USEDBS)
882: $ THEN
883: * We need to check that the RQCORR update doesn't
884: * move the eigenvalue away from the desired one and
885: * towards a neighbor. -> protection with bisection
886: IF(INDEIG.LE.NEGCNT) THEN
887: * The wanted eigenvalue lies to the left
888: SGNDEF = -ONE
889: ELSE
890: * The wanted eigenvalue lies to the right
891: SGNDEF = ONE
892: ENDIF
893: * We only use the RQCORR if it improves the
894: * the iterate reasonably.
895: IF( ( RQCORR*SGNDEF.GE.ZERO )
896: $ .AND.( LAMBDA + RQCORR.LE. RIGHT)
897: $ .AND.( LAMBDA + RQCORR.GE. LEFT)
898: $ ) THEN
899: USEDRQ = .TRUE.
900: * Store new midpoint of bisection interval in WORK
901: IF(SGNDEF.EQ.ONE) THEN
902: * The current LAMBDA is on the left of the true
903: * eigenvalue
904: LEFT = LAMBDA
905: * We prefer to assume that the error estimate
906: * is correct. We could make the interval not
907: * as a bracket but to be modified if the RQCORR
908: * chooses to. In this case, the RIGHT side should
909: * be modified as follows:
910: * RIGHT = MAX(RIGHT, LAMBDA + RQCORR)
911: ELSE
912: * The current LAMBDA is on the right of the true
913: * eigenvalue
914: RIGHT = LAMBDA
915: * See comment about assuming the error estimate is
916: * correct above.
917: * LEFT = MIN(LEFT, LAMBDA + RQCORR)
918: ENDIF
919: WORK( WINDEX ) =
920: $ HALF * (RIGHT + LEFT)
921: * Take RQCORR since it has the correct sign and
922: * improves the iterate reasonably
923: LAMBDA = LAMBDA + RQCORR
924: * Update width of error interval
925: WERR( WINDEX ) =
926: $ HALF * (RIGHT-LEFT)
927: ELSE
928: NEEDBS = .TRUE.
929: ENDIF
930: IF(RIGHT-LEFT.LT.RQTOL*ABS(LAMBDA)) THEN
931: * The eigenvalue is computed to bisection accuracy
932: * compute eigenvector and stop
933: USEDBS = .TRUE.
934: GOTO 120
935: ELSEIF( ITER.LT.MAXITR ) THEN
936: GOTO 120
937: ELSEIF( ITER.EQ.MAXITR ) THEN
938: NEEDBS = .TRUE.
939: GOTO 120
940: ELSE
941: INFO = 5
942: RETURN
943: END IF
944: ELSE
945: STP2II = .FALSE.
946: IF(USEDRQ .AND. USEDBS .AND.
947: $ BSTRES.LE.RESID) THEN
948: LAMBDA = BSTW
949: STP2II = .TRUE.
950: ENDIF
951: IF (STP2II) THEN
952: * improve error angle by second step
953: CALL DLAR1V( IN, 1, IN, LAMBDA,
954: $ D( IBEGIN ), L( IBEGIN ),
955: $ WORK(INDLD+IBEGIN-1),
956: $ WORK(INDLLD+IBEGIN-1),
957: $ PIVMIN, GAPTOL, Z( IBEGIN, WINDEX ),
958: $ .NOT.USEDBS, NEGCNT, ZTZ, MINGMA,
959: $ IWORK( IINDR+WINDEX ),
960: $ ISUPPZ( 2*WINDEX-1 ),
961: $ NRMINV, RESID, RQCORR, WORK( INDWRK ) )
962: ENDIF
963: WORK( WINDEX ) = LAMBDA
964: END IF
965: *
966: * Compute FP-vector support w.r.t. whole matrix
967: *
968: ISUPPZ( 2*WINDEX-1 ) = ISUPPZ( 2*WINDEX-1 )+OLDIEN
969: ISUPPZ( 2*WINDEX ) = ISUPPZ( 2*WINDEX )+OLDIEN
970: ZFROM = ISUPPZ( 2*WINDEX-1 )
971: ZTO = ISUPPZ( 2*WINDEX )
972: ISUPMN = ISUPMN + OLDIEN
973: ISUPMX = ISUPMX + OLDIEN
974: * Ensure vector is ok if support in the RQI has changed
975: IF(ISUPMN.LT.ZFROM) THEN
976: DO 122 II = ISUPMN,ZFROM-1
977: Z( II, WINDEX ) = ZERO
978: 122 CONTINUE
979: ENDIF
980: IF(ISUPMX.GT.ZTO) THEN
981: DO 123 II = ZTO+1,ISUPMX
982: Z( II, WINDEX ) = ZERO
983: 123 CONTINUE
984: ENDIF
985: CALL DSCAL( ZTO-ZFROM+1, NRMINV,
986: $ Z( ZFROM, WINDEX ), 1 )
987: 125 CONTINUE
988: * Update W
989: W( WINDEX ) = LAMBDA+SIGMA
990: * Recompute the gaps on the left and right
991: * But only allow them to become larger and not
992: * smaller (which can only happen through "bad"
993: * cancellation and doesn't reflect the theory
994: * where the initial gaps are underestimated due
995: * to WERR being too crude.)
996: IF(.NOT.ESKIP) THEN
997: IF( K.GT.1) THEN
998: WGAP( WINDMN ) = MAX( WGAP(WINDMN),
999: $ W(WINDEX)-WERR(WINDEX)
1000: $ - W(WINDMN)-WERR(WINDMN) )
1001: ENDIF
1002: IF( WINDEX.LT.WEND ) THEN
1003: WGAP( WINDEX ) = MAX( SAVGAP,
1004: $ W( WINDPL )-WERR( WINDPL )
1005: $ - W( WINDEX )-WERR( WINDEX) )
1006: ENDIF
1007: ENDIF
1008: IDONE = IDONE + 1
1009: ENDIF
1010: * here ends the code for the current child
1011: *
1012: 139 CONTINUE
1013: * Proceed to any remaining child nodes
1014: NEWFST = J + 1
1015: 140 CONTINUE
1016: 150 CONTINUE
1017: NDEPTH = NDEPTH + 1
1018: GO TO 40
1019: END IF
1020: IBEGIN = IEND + 1
1021: WBEGIN = WEND + 1
1022: 170 CONTINUE
1023: *
1024:
1025: RETURN
1026: *
1027: * End of DLARRV
1028: *
1029: END
CVSweb interface <joel.bertrand@systella.fr>