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