LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlar1v.f
Go to the documentation of this file.
1*> \brief \b DLAR1V computes the (scaled) r-th column of the inverse of the submatrix in rows b1 through bn of the tridiagonal matrix LDLT - λI.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DLAR1V + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlar1v.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlar1v.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlar1v.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DLAR1V( N, B1, BN, LAMBDA, D, L, LD, LLD,
20* PIVMIN, GAPTOL, Z, WANTNC, NEGCNT, ZTZ, MINGMA,
21* R, ISUPPZ, NRMINV, RESID, RQCORR, WORK )
22*
23* .. Scalar Arguments ..
24* LOGICAL WANTNC
25* INTEGER B1, BN, N, NEGCNT, R
26* DOUBLE PRECISION GAPTOL, LAMBDA, MINGMA, NRMINV, PIVMIN, RESID,
27* $ RQCORR, ZTZ
28* ..
29* .. Array Arguments ..
30* INTEGER ISUPPZ( * )
31* DOUBLE PRECISION D( * ), L( * ), LD( * ), LLD( * ),
32* $ WORK( * )
33* DOUBLE PRECISION Z( * )
34* ..
35*
36*
37*> \par Purpose:
38* =============
39*>
40*> \verbatim
41*>
42*> DLAR1V computes the (scaled) r-th column of the inverse of
43*> the sumbmatrix in rows B1 through BN of the tridiagonal matrix
44*> L D L**T - sigma I. When sigma is close to an eigenvalue, the
45*> computed vector is an accurate eigenvector. Usually, r corresponds
46*> to the index where the eigenvector is largest in magnitude.
47*> The following steps accomplish this computation :
48*> (a) Stationary qd transform, L D L**T - sigma I = L(+) D(+) L(+)**T,
49*> (b) Progressive qd transform, L D L**T - sigma I = U(-) D(-) U(-)**T,
50*> (c) Computation of the diagonal elements of the inverse of
51*> L D L**T - sigma I by combining the above transforms, and choosing
52*> r as the index where the diagonal of the inverse is (one of the)
53*> largest in magnitude.
54*> (d) Computation of the (scaled) r-th column of the inverse using the
55*> twisted factorization obtained by combining the top part of the
56*> the stationary and the bottom part of the progressive transform.
57*> \endverbatim
58*
59* Arguments:
60* ==========
61*
62*> \param[in] N
63*> \verbatim
64*> N is INTEGER
65*> The order of the matrix L D L**T.
66*> \endverbatim
67*>
68*> \param[in] B1
69*> \verbatim
70*> B1 is INTEGER
71*> First index of the submatrix of L D L**T.
72*> \endverbatim
73*>
74*> \param[in] BN
75*> \verbatim
76*> BN is INTEGER
77*> Last index of the submatrix of L D L**T.
78*> \endverbatim
79*>
80*> \param[in] LAMBDA
81*> \verbatim
82*> LAMBDA is DOUBLE PRECISION
83*> The shift. In order to compute an accurate eigenvector,
84*> LAMBDA should be a good approximation to an eigenvalue
85*> of L D L**T.
86*> \endverbatim
87*>
88*> \param[in] L
89*> \verbatim
90*> L is DOUBLE PRECISION array, dimension (N-1)
91*> The (n-1) subdiagonal elements of the unit bidiagonal matrix
92*> L, in elements 1 to N-1.
93*> \endverbatim
94*>
95*> \param[in] D
96*> \verbatim
97*> D is DOUBLE PRECISION array, dimension (N)
98*> The n diagonal elements of the diagonal matrix D.
99*> \endverbatim
100*>
101*> \param[in] LD
102*> \verbatim
103*> LD is DOUBLE PRECISION array, dimension (N-1)
104*> The n-1 elements L(i)*D(i).
105*> \endverbatim
106*>
107*> \param[in] LLD
108*> \verbatim
109*> LLD is DOUBLE PRECISION array, dimension (N-1)
110*> The n-1 elements L(i)*L(i)*D(i).
111*> \endverbatim
112*>
113*> \param[in] PIVMIN
114*> \verbatim
115*> PIVMIN is DOUBLE PRECISION
116*> The minimum pivot in the Sturm sequence.
117*> \endverbatim
118*>
119*> \param[in] GAPTOL
120*> \verbatim
121*> GAPTOL is DOUBLE PRECISION
122*> Tolerance that indicates when eigenvector entries are negligible
123*> w.r.t. their contribution to the residual.
124*> \endverbatim
125*>
126*> \param[in,out] Z
127*> \verbatim
128*> Z is DOUBLE PRECISION array, dimension (N)
129*> On input, all entries of Z must be set to 0.
130*> On output, Z contains the (scaled) r-th column of the
131*> inverse. The scaling is such that Z(R) equals 1.
132*> \endverbatim
133*>
134*> \param[in] WANTNC
135*> \verbatim
136*> WANTNC is LOGICAL
137*> Specifies whether NEGCNT has to be computed.
138*> \endverbatim
139*>
140*> \param[out] NEGCNT
141*> \verbatim
142*> NEGCNT is INTEGER
143*> If WANTNC is .TRUE. then NEGCNT = the number of pivots < pivmin
144*> in the matrix factorization L D L**T, and NEGCNT = -1 otherwise.
145*> \endverbatim
146*>
147*> \param[out] ZTZ
148*> \verbatim
149*> ZTZ is DOUBLE PRECISION
150*> The square of the 2-norm of Z.
151*> \endverbatim
152*>
153*> \param[out] MINGMA
154*> \verbatim
155*> MINGMA is DOUBLE PRECISION
156*> The reciprocal of the largest (in magnitude) diagonal
157*> element of the inverse of L D L**T - sigma I.
158*> \endverbatim
159*>
160*> \param[in,out] R
161*> \verbatim
162*> R is INTEGER
163*> The twist index for the twisted factorization used to
164*> compute Z.
165*> On input, 0 <= R <= N. If R is input as 0, R is set to
166*> the index where (L D L**T - sigma I)^{-1} is largest
167*> in magnitude. If 1 <= R <= N, R is unchanged.
168*> On output, R contains the twist index used to compute Z.
169*> Ideally, R designates the position of the maximum entry in the
170*> eigenvector.
171*> \endverbatim
172*>
173*> \param[out] ISUPPZ
174*> \verbatim
175*> ISUPPZ is INTEGER array, dimension (2)
176*> The support of the vector in Z, i.e., the vector Z is
177*> nonzero only in elements ISUPPZ(1) through ISUPPZ( 2 ).
178*> \endverbatim
179*>
180*> \param[out] NRMINV
181*> \verbatim
182*> NRMINV is DOUBLE PRECISION
183*> NRMINV = 1/SQRT( ZTZ )
184*> \endverbatim
185*>
186*> \param[out] RESID
187*> \verbatim
188*> RESID is DOUBLE PRECISION
189*> The residual of the FP vector.
190*> RESID = ABS( MINGMA )/SQRT( ZTZ )
191*> \endverbatim
192*>
193*> \param[out] RQCORR
194*> \verbatim
195*> RQCORR is DOUBLE PRECISION
196*> The Rayleigh Quotient correction to LAMBDA.
197*> RQCORR = MINGMA*TMP
198*> \endverbatim
199*>
200*> \param[out] WORK
201*> \verbatim
202*> WORK is DOUBLE PRECISION array, dimension (4*N)
203*> \endverbatim
204*
205* Authors:
206* ========
207*
208*> \author Univ. of Tennessee
209*> \author Univ. of California Berkeley
210*> \author Univ. of Colorado Denver
211*> \author NAG Ltd.
212*
213*> \ingroup lar1v
214*
215*> \par Contributors:
216* ==================
217*>
218*> Beresford Parlett, University of California, Berkeley, USA \n
219*> Jim Demmel, University of California, Berkeley, USA \n
220*> Inderjit Dhillon, University of Texas, Austin, USA \n
221*> Osni Marques, LBNL/NERSC, USA \n
222*> Christof Voemel, University of California, Berkeley, USA
223*
224* =====================================================================
225 SUBROUTINE dlar1v( N, B1, BN, LAMBDA, D, L, LD, LLD,
226 $ PIVMIN, GAPTOL, Z, WANTNC, NEGCNT, ZTZ, MINGMA,
227 $ R, ISUPPZ, NRMINV, RESID, RQCORR, WORK )
228*
229* -- LAPACK auxiliary routine --
230* -- LAPACK is a software package provided by Univ. of Tennessee, --
231* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
232*
233* .. Scalar Arguments ..
234 LOGICAL WANTNC
235 INTEGER B1, BN, N, NEGCNT, R
236 DOUBLE PRECISION GAPTOL, LAMBDA, MINGMA, NRMINV, PIVMIN, RESID,
237 $ rqcorr, ztz
238* ..
239* .. Array Arguments ..
240 INTEGER ISUPPZ( * )
241 DOUBLE PRECISION D( * ), L( * ), LD( * ), LLD( * ),
242 $ work( * )
243 DOUBLE PRECISION Z( * )
244* ..
245*
246* =====================================================================
247*
248* .. Parameters ..
249 DOUBLE PRECISION ZERO, ONE
250 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
251
252* ..
253* .. Local Scalars ..
254 LOGICAL SAWNAN1, SAWNAN2
255 INTEGER I, INDLPL, INDP, INDS, INDUMN, NEG1, NEG2, R1,
256 $ r2
257 DOUBLE PRECISION DMINUS, DPLUS, EPS, S, TMP
258* ..
259* .. External Functions ..
260 LOGICAL DISNAN
261 DOUBLE PRECISION DLAMCH
262 EXTERNAL disnan, dlamch
263* ..
264* .. Intrinsic Functions ..
265 INTRINSIC abs
266* ..
267* .. Executable Statements ..
268*
269 eps = dlamch( 'Precision' )
270
271
272 IF( r.EQ.0 ) THEN
273 r1 = b1
274 r2 = bn
275 ELSE
276 r1 = r
277 r2 = r
278 END IF
279
280* Storage for LPLUS
281 indlpl = 0
282* Storage for UMINUS
283 indumn = n
284 inds = 2*n + 1
285 indp = 3*n + 1
286
287 IF( b1.EQ.1 ) THEN
288 work( inds ) = zero
289 ELSE
290 work( inds+b1-1 ) = lld( b1-1 )
291 END IF
292
293*
294* Compute the stationary transform (using the differential form)
295* until the index R2.
296*
297 sawnan1 = .false.
298 neg1 = 0
299 s = work( inds+b1-1 ) - lambda
300 DO 50 i = b1, r1 - 1
301 dplus = d( i ) + s
302 work( indlpl+i ) = ld( i ) / dplus
303 IF(dplus.LT.zero) neg1 = neg1 + 1
304 work( inds+i ) = s*work( indlpl+i )*l( i )
305 s = work( inds+i ) - lambda
306 50 CONTINUE
307 sawnan1 = disnan( s )
308 IF( sawnan1 ) GOTO 60
309 DO 51 i = r1, r2 - 1
310 dplus = d( i ) + s
311 work( indlpl+i ) = ld( i ) / dplus
312 work( inds+i ) = s*work( indlpl+i )*l( i )
313 s = work( inds+i ) - lambda
314 51 CONTINUE
315 sawnan1 = disnan( s )
316*
317 60 CONTINUE
318 IF( sawnan1 ) THEN
319* Runs a slower version of the above loop if a NaN is detected
320 neg1 = 0
321 s = work( inds+b1-1 ) - lambda
322 DO 70 i = b1, r1 - 1
323 dplus = d( i ) + s
324 IF(abs(dplus).LT.pivmin) dplus = -pivmin
325 work( indlpl+i ) = ld( i ) / dplus
326 IF(dplus.LT.zero) neg1 = neg1 + 1
327 work( inds+i ) = s*work( indlpl+i )*l( i )
328 IF( work( indlpl+i ).EQ.zero )
329 $ work( inds+i ) = lld( i )
330 s = work( inds+i ) - lambda
331 70 CONTINUE
332 DO 71 i = r1, r2 - 1
333 dplus = d( i ) + s
334 IF(abs(dplus).LT.pivmin) dplus = -pivmin
335 work( indlpl+i ) = ld( i ) / dplus
336 work( inds+i ) = s*work( indlpl+i )*l( i )
337 IF( work( indlpl+i ).EQ.zero )
338 $ work( inds+i ) = lld( i )
339 s = work( inds+i ) - lambda
340 71 CONTINUE
341 END IF
342*
343* Compute the progressive transform (using the differential form)
344* until the index R1
345*
346 sawnan2 = .false.
347 neg2 = 0
348 work( indp+bn-1 ) = d( bn ) - lambda
349 DO 80 i = bn - 1, r1, -1
350 dminus = lld( i ) + work( indp+i )
351 tmp = d( i ) / dminus
352 IF(dminus.LT.zero) neg2 = neg2 + 1
353 work( indumn+i ) = l( i )*tmp
354 work( indp+i-1 ) = work( indp+i )*tmp - lambda
355 80 CONTINUE
356 tmp = work( indp+r1-1 )
357 sawnan2 = disnan( tmp )
358
359 IF( sawnan2 ) THEN
360* Runs a slower version of the above loop if a NaN is detected
361 neg2 = 0
362 DO 100 i = bn-1, r1, -1
363 dminus = lld( i ) + work( indp+i )
364 IF(abs(dminus).LT.pivmin) dminus = -pivmin
365 tmp = d( i ) / dminus
366 IF(dminus.LT.zero) neg2 = neg2 + 1
367 work( indumn+i ) = l( i )*tmp
368 work( indp+i-1 ) = work( indp+i )*tmp - lambda
369 IF( tmp.EQ.zero )
370 $ work( indp+i-1 ) = d( i ) - lambda
371 100 CONTINUE
372 END IF
373*
374* Find the index (from R1 to R2) of the largest (in magnitude)
375* diagonal element of the inverse
376*
377 mingma = work( inds+r1-1 ) + work( indp+r1-1 )
378 IF( mingma.LT.zero ) neg1 = neg1 + 1
379 IF( wantnc ) THEN
380 negcnt = neg1 + neg2
381 ELSE
382 negcnt = -1
383 ENDIF
384 IF( abs(mingma).EQ.zero )
385 $ mingma = eps*work( inds+r1-1 )
386 r = r1
387 DO 110 i = r1, r2 - 1
388 tmp = work( inds+i ) + work( indp+i )
389 IF( tmp.EQ.zero )
390 $ tmp = eps*work( inds+i )
391 IF( abs( tmp ).LE.abs( mingma ) ) THEN
392 mingma = tmp
393 r = i + 1
394 END IF
395 110 CONTINUE
396*
397* Compute the FP vector: solve N^T v = e_r
398*
399 isuppz( 1 ) = b1
400 isuppz( 2 ) = bn
401 z( r ) = one
402 ztz = one
403*
404* Compute the FP vector upwards from R
405*
406 IF( .NOT.sawnan1 .AND. .NOT.sawnan2 ) THEN
407 DO 210 i = r-1, b1, -1
408 z( i ) = -( work( indlpl+i )*z( i+1 ) )
409 IF( (abs(z(i))+abs(z(i+1)))* abs(ld(i)).LT.gaptol )
410 $ THEN
411 z( i ) = zero
412 isuppz( 1 ) = i + 1
413 GOTO 220
414 ENDIF
415 ztz = ztz + z( i )*z( i )
416 210 CONTINUE
417 220 CONTINUE
418 ELSE
419* Run slower loop if NaN occurred.
420 DO 230 i = r - 1, b1, -1
421 IF( z( i+1 ).EQ.zero ) THEN
422 z( i ) = -( ld( i+1 ) / ld( i ) )*z( i+2 )
423 ELSE
424 z( i ) = -( work( indlpl+i )*z( i+1 ) )
425 END IF
426 IF( (abs(z(i))+abs(z(i+1)))* abs(ld(i)).LT.gaptol )
427 $ THEN
428 z( i ) = zero
429 isuppz( 1 ) = i + 1
430 GO TO 240
431 END IF
432 ztz = ztz + z( i )*z( i )
433 230 CONTINUE
434 240 CONTINUE
435 ENDIF
436
437* Compute the FP vector downwards from R in blocks of size BLKSIZ
438 IF( .NOT.sawnan1 .AND. .NOT.sawnan2 ) THEN
439 DO 250 i = r, bn-1
440 z( i+1 ) = -( work( indumn+i )*z( i ) )
441 IF( (abs(z(i))+abs(z(i+1)))* abs(ld(i)).LT.gaptol )
442 $ THEN
443 z( i+1 ) = zero
444 isuppz( 2 ) = i
445 GO TO 260
446 END IF
447 ztz = ztz + z( i+1 )*z( i+1 )
448 250 CONTINUE
449 260 CONTINUE
450 ELSE
451* Run slower loop if NaN occurred.
452 DO 270 i = r, bn - 1
453 IF( z( i ).EQ.zero ) THEN
454 z( i+1 ) = -( ld( i-1 ) / ld( i ) )*z( i-1 )
455 ELSE
456 z( i+1 ) = -( work( indumn+i )*z( i ) )
457 END IF
458 IF( (abs(z(i))+abs(z(i+1)))* abs(ld(i)).LT.gaptol )
459 $ THEN
460 z( i+1 ) = zero
461 isuppz( 2 ) = i
462 GO TO 280
463 END IF
464 ztz = ztz + z( i+1 )*z( i+1 )
465 270 CONTINUE
466 280 CONTINUE
467 END IF
468*
469* Compute quantities for convergence test
470*
471 tmp = one / ztz
472 nrminv = sqrt( tmp )
473 resid = abs( mingma )*nrminv
474 rqcorr = mingma*tmp
475*
476*
477 RETURN
478*
479* End of DLAR1V
480*
481 END
subroutine dlar1v(n, b1, bn, lambda, d, l, ld, lld, pivmin, gaptol, z, wantnc, negcnt, ztz, mingma, r, isuppz, nrminv, resid, rqcorr, work)
DLAR1V computes the (scaled) r-th column of the inverse of the submatrix in rows b1 through bn of the...
Definition dlar1v.f:228