LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
claqr3.f
Go to the documentation of this file.
1*> \brief \b CLAQR3 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fully converged eigenvalues from a trailing principal submatrix (aggressive early deflation).
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CLAQR3 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/claqr3.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/claqr3.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/claqr3.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,
20* IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,
21* NV, WV, LDWV, WORK, LWORK )
22*
23* .. Scalar Arguments ..
24* INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
25* $ LDZ, LWORK, N, ND, NH, NS, NV, NW
26* LOGICAL WANTT, WANTZ
27* ..
28* .. Array Arguments ..
29* COMPLEX H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
30* $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )
31* ..
32*
33*
34*> \par Purpose:
35* =============
36*>
37*> \verbatim
38*>
39*> Aggressive early deflation:
40*>
41*> CLAQR3 accepts as input an upper Hessenberg matrix
42*> H and performs an unitary similarity transformation
43*> designed to detect and deflate fully converged eigenvalues from
44*> a trailing principal submatrix. On output H has been over-
45*> written by a new Hessenberg matrix that is a perturbation of
46*> an unitary similarity transformation of H. It is to be
47*> hoped that the final version of H has many zero subdiagonal
48*> entries.
49*> \endverbatim
50*
51* Arguments:
52* ==========
53*
54*> \param[in] WANTT
55*> \verbatim
56*> WANTT is LOGICAL
57*> If .TRUE., then the Hessenberg matrix H is fully updated
58*> so that the triangular Schur factor may be
59*> computed (in cooperation with the calling subroutine).
60*> If .FALSE., then only enough of H is updated to preserve
61*> the eigenvalues.
62*> \endverbatim
63*>
64*> \param[in] WANTZ
65*> \verbatim
66*> WANTZ is LOGICAL
67*> If .TRUE., then the unitary matrix Z is updated so
68*> so that the unitary Schur factor may be computed
69*> (in cooperation with the calling subroutine).
70*> If .FALSE., then Z is not referenced.
71*> \endverbatim
72*>
73*> \param[in] N
74*> \verbatim
75*> N is INTEGER
76*> The order of the matrix H and (if WANTZ is .TRUE.) the
77*> order of the unitary matrix Z.
78*> \endverbatim
79*>
80*> \param[in] KTOP
81*> \verbatim
82*> KTOP is INTEGER
83*> It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0.
84*> KBOT and KTOP together determine an isolated block
85*> along the diagonal of the Hessenberg matrix.
86*> \endverbatim
87*>
88*> \param[in] KBOT
89*> \verbatim
90*> KBOT is INTEGER
91*> It is assumed without a check that either
92*> KBOT = N or H(KBOT+1,KBOT)=0. KBOT and KTOP together
93*> determine an isolated block along the diagonal of the
94*> Hessenberg matrix.
95*> \endverbatim
96*>
97*> \param[in] NW
98*> \verbatim
99*> NW is INTEGER
100*> Deflation window size. 1 <= NW <= (KBOT-KTOP+1).
101*> \endverbatim
102*>
103*> \param[in,out] H
104*> \verbatim
105*> H is COMPLEX array, dimension (LDH,N)
106*> On input the initial N-by-N section of H stores the
107*> Hessenberg matrix undergoing aggressive early deflation.
108*> On output H has been transformed by a unitary
109*> similarity transformation, perturbed, and the returned
110*> to Hessenberg form that (it is to be hoped) has some
111*> zero subdiagonal entries.
112*> \endverbatim
113*>
114*> \param[in] LDH
115*> \verbatim
116*> LDH is INTEGER
117*> Leading dimension of H just as declared in the calling
118*> subroutine. N <= LDH
119*> \endverbatim
120*>
121*> \param[in] ILOZ
122*> \verbatim
123*> ILOZ is INTEGER
124*> \endverbatim
125*>
126*> \param[in] IHIZ
127*> \verbatim
128*> IHIZ is INTEGER
129*> Specify the rows of Z to which transformations must be
130*> applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N.
131*> \endverbatim
132*>
133*> \param[in,out] Z
134*> \verbatim
135*> Z is COMPLEX array, dimension (LDZ,N)
136*> IF WANTZ is .TRUE., then on output, the unitary
137*> similarity transformation mentioned above has been
138*> accumulated into Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.
139*> If WANTZ is .FALSE., then Z is unreferenced.
140*> \endverbatim
141*>
142*> \param[in] LDZ
143*> \verbatim
144*> LDZ is INTEGER
145*> The leading dimension of Z just as declared in the
146*> calling subroutine. 1 <= LDZ.
147*> \endverbatim
148*>
149*> \param[out] NS
150*> \verbatim
151*> NS is INTEGER
152*> The number of unconverged (ie approximate) eigenvalues
153*> returned in SR and SI that may be used as shifts by the
154*> calling subroutine.
155*> \endverbatim
156*>
157*> \param[out] ND
158*> \verbatim
159*> ND is INTEGER
160*> The number of converged eigenvalues uncovered by this
161*> subroutine.
162*> \endverbatim
163*>
164*> \param[out] SH
165*> \verbatim
166*> SH is COMPLEX array, dimension (KBOT)
167*> On output, approximate eigenvalues that may
168*> be used for shifts are stored in SH(KBOT-ND-NS+1)
169*> through SR(KBOT-ND). Converged eigenvalues are
170*> stored in SH(KBOT-ND+1) through SH(KBOT).
171*> \endverbatim
172*>
173*> \param[out] V
174*> \verbatim
175*> V is COMPLEX array, dimension (LDV,NW)
176*> An NW-by-NW work array.
177*> \endverbatim
178*>
179*> \param[in] LDV
180*> \verbatim
181*> LDV is INTEGER
182*> The leading dimension of V just as declared in the
183*> calling subroutine. NW <= LDV
184*> \endverbatim
185*>
186*> \param[in] NH
187*> \verbatim
188*> NH is INTEGER
189*> The number of columns of T. NH >= NW.
190*> \endverbatim
191*>
192*> \param[out] T
193*> \verbatim
194*> T is COMPLEX array, dimension (LDT,NW)
195*> \endverbatim
196*>
197*> \param[in] LDT
198*> \verbatim
199*> LDT is INTEGER
200*> The leading dimension of T just as declared in the
201*> calling subroutine. NW <= LDT
202*> \endverbatim
203*>
204*> \param[in] NV
205*> \verbatim
206*> NV is INTEGER
207*> The number of rows of work array WV available for
208*> workspace. NV >= NW.
209*> \endverbatim
210*>
211*> \param[out] WV
212*> \verbatim
213*> WV is COMPLEX array, dimension (LDWV,NW)
214*> \endverbatim
215*>
216*> \param[in] LDWV
217*> \verbatim
218*> LDWV is INTEGER
219*> The leading dimension of W just as declared in the
220*> calling subroutine. NW <= LDV
221*> \endverbatim
222*>
223*> \param[out] WORK
224*> \verbatim
225*> WORK is COMPLEX array, dimension (LWORK)
226*> On exit, WORK(1) is set to an estimate of the optimal value
227*> of LWORK for the given values of N, NW, KTOP and KBOT.
228*> \endverbatim
229*>
230*> \param[in] LWORK
231*> \verbatim
232*> LWORK is INTEGER
233*> The dimension of the work array WORK. LWORK = 2*NW
234*> suffices, but greater efficiency may result from larger
235*> values of LWORK.
236*>
237*> If LWORK = -1, then a workspace query is assumed; CLAQR3
238*> only estimates the optimal workspace size for the given
239*> values of N, NW, KTOP and KBOT. The estimate is returned
240*> in WORK(1). No error message related to LWORK is issued
241*> by XERBLA. Neither H nor Z are accessed.
242*> \endverbatim
243*
244* Authors:
245* ========
246*
247*> \author Univ. of Tennessee
248*> \author Univ. of California Berkeley
249*> \author Univ. of Colorado Denver
250*> \author NAG Ltd.
251*
252*> \ingroup laqr3
253*
254*> \par Contributors:
255* ==================
256*>
257*> Karen Braman and Ralph Byers, Department of Mathematics,
258*> University of Kansas, USA
259*>
260* =====================================================================
261 SUBROUTINE claqr3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH,
262 $ ILOZ,
263 $ IHIZ, Z, LDZ, NS, ND, SH, V, LDV, NH, T, LDT,
264 $ NV, WV, LDWV, WORK, LWORK )
265*
266* -- LAPACK auxiliary routine --
267* -- LAPACK is a software package provided by Univ. of Tennessee, --
268* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
269*
270* .. Scalar Arguments ..
271 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
272 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
273 LOGICAL WANTT, WANTZ
274* ..
275* .. Array Arguments ..
276 COMPLEX H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
277 $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )
278* ..
279*
280* ================================================================
281*
282* .. Parameters ..
283 COMPLEX ZERO, ONE
284 PARAMETER ( ZERO = ( 0.0e0, 0.0e0 ),
285 $ one = ( 1.0e0, 0.0e0 ) )
286 REAL RZERO, RONE
287 parameter( rzero = 0.0e0, rone = 1.0e0 )
288* ..
289* .. Local Scalars ..
290 COMPLEX CDUM, S, TAU
291 REAL FOO, SAFMAX, SAFMIN, SMLNUM, ULP
292 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,
293 $ knt, krow, kwtop, ltop, lwk1, lwk2, lwk3,
294 $ lwkopt, nmin
295* ..
296* .. External Functions ..
297 REAL SLAMCH
298 INTEGER ILAENV
299 EXTERNAL SLAMCH, ILAENV
300* ..
301* .. External Subroutines ..
302 EXTERNAL ccopy, cgehrd, cgemm, clacpy, clahqr,
303 $ claqr4,
305* ..
306* .. Intrinsic Functions ..
307 INTRINSIC abs, aimag, cmplx, conjg, int, max, min, real
308* ..
309* .. Statement Functions ..
310 REAL CABS1
311* ..
312* .. Statement Function definitions ..
313 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
314* ..
315* .. Executable Statements ..
316*
317* ==== Estimate optimal workspace. ====
318*
319 jw = min( nw, kbot-ktop+1 )
320 IF( jw.LE.2 ) THEN
321 lwkopt = 1
322 ELSE
323*
324* ==== Workspace query call to CGEHRD ====
325*
326 CALL cgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
327 lwk1 = int( work( 1 ) )
328*
329* ==== Workspace query call to CUNMHR ====
330*
331 CALL cunmhr( 'R', 'N', jw, jw, 1, jw-1, t, ldt, work, v,
332 $ ldv,
333 $ work, -1, info )
334 lwk2 = int( work( 1 ) )
335*
336* ==== Workspace query call to CLAQR4 ====
337*
338 CALL claqr4( .true., .true., jw, 1, jw, t, ldt, sh, 1, jw,
339 $ v,
340 $ ldv, work, -1, infqr )
341 lwk3 = int( work( 1 ) )
342*
343* ==== Optimal workspace ====
344*
345 lwkopt = max( jw+max( lwk1, lwk2 ), lwk3 )
346 END IF
347*
348* ==== Quick return in case of workspace query. ====
349*
350 IF( lwork.EQ.-1 ) THEN
351 work( 1 ) = cmplx( lwkopt, 0 )
352 RETURN
353 END IF
354*
355* ==== Nothing to do ...
356* ... for an empty active block ... ====
357 ns = 0
358 nd = 0
359 work( 1 ) = one
360 IF( ktop.GT.kbot )
361 $ RETURN
362* ... nor for an empty deflation window. ====
363 IF( nw.LT.1 )
364 $ RETURN
365*
366* ==== Machine constants ====
367*
368 safmin = slamch( 'SAFE MINIMUM' )
369 safmax = rone / safmin
370 ulp = slamch( 'PRECISION' )
371 smlnum = safmin*( real( n ) / ulp )
372*
373* ==== Setup deflation window ====
374*
375 jw = min( nw, kbot-ktop+1 )
376 kwtop = kbot - jw + 1
377 IF( kwtop.EQ.ktop ) THEN
378 s = zero
379 ELSE
380 s = h( kwtop, kwtop-1 )
381 END IF
382*
383 IF( kbot.EQ.kwtop ) THEN
384*
385* ==== 1-by-1 deflation window: not much to do ====
386*
387 sh( kwtop ) = h( kwtop, kwtop )
388 ns = 1
389 nd = 0
390 IF( cabs1( s ).LE.max( smlnum, ulp*cabs1( h( kwtop,
391 $ kwtop ) ) ) ) THEN
392 ns = 0
393 nd = 1
394 IF( kwtop.GT.ktop )
395 $ h( kwtop, kwtop-1 ) = zero
396 END IF
397 work( 1 ) = one
398 RETURN
399 END IF
400*
401* ==== Convert to spike-triangular form. (In case of a
402* . rare QR failure, this routine continues to do
403* . aggressive early deflation using that part of
404* . the deflation window that converged using INFQR
405* . here and there to keep track.) ====
406*
407 CALL clacpy( 'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
408 CALL ccopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ),
409 $ ldt+1 )
410*
411 CALL claset( 'A', jw, jw, zero, one, v, ldv )
412 nmin = ilaenv( 12, 'CLAQR3', 'SV', jw, 1, jw, lwork )
413 IF( jw.GT.nmin ) THEN
414 CALL claqr4( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ),
415 $ 1,
416 $ jw, v, ldv, work, lwork, infqr )
417 ELSE
418 CALL clahqr( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ),
419 $ 1,
420 $ jw, v, ldv, infqr )
421 END IF
422*
423* ==== Deflation detection loop ====
424*
425 ns = jw
426 ilst = infqr + 1
427 DO 10 knt = infqr + 1, jw
428*
429* ==== Small spike tip deflation test ====
430*
431 foo = cabs1( t( ns, ns ) )
432 IF( foo.EQ.rzero )
433 $ foo = cabs1( s )
434 IF( cabs1( s )*cabs1( v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
435 $ THEN
436*
437* ==== One more converged eigenvalue ====
438*
439 ns = ns - 1
440 ELSE
441*
442* ==== One undeflatable eigenvalue. Move it up out of the
443* . way. (CTREXC can not fail in this case.) ====
444*
445 ifst = ns
446 CALL ctrexc( 'V', jw, t, ldt, v, ldv, ifst, ilst, info )
447 ilst = ilst + 1
448 END IF
449 10 CONTINUE
450*
451* ==== Return to Hessenberg form ====
452*
453 IF( ns.EQ.0 )
454 $ s = zero
455*
456 IF( ns.LT.jw ) THEN
457*
458* ==== sorting the diagonal of T improves accuracy for
459* . graded matrices. ====
460*
461 DO 30 i = infqr + 1, ns
462 ifst = i
463 DO 20 j = i + 1, ns
464 IF( cabs1( t( j, j ) ).GT.cabs1( t( ifst, ifst ) ) )
465 $ ifst = j
466 20 CONTINUE
467 ilst = i
468 IF( ifst.NE.ilst )
469 $ CALL ctrexc( 'V', jw, t, ldt, v, ldv, ifst, ilst,
470 $ info )
471 30 CONTINUE
472 END IF
473*
474* ==== Restore shift/eigenvalue array from T ====
475*
476 DO 40 i = infqr + 1, jw
477 sh( kwtop+i-1 ) = t( i, i )
478 40 CONTINUE
479*
480*
481 IF( ns.LT.jw .OR. s.EQ.zero ) THEN
482 IF( ns.GT.1 .AND. s.NE.zero ) THEN
483*
484* ==== Reflect spike back into lower triangle ====
485*
486 CALL ccopy( ns, v, ldv, work, 1 )
487 DO 50 i = 1, ns
488 work( i ) = conjg( work( i ) )
489 50 CONTINUE
490 CALL clarfg( ns, work( 1 ), work( 2 ), 1, tau )
491*
492 CALL claset( 'L', jw-2, jw-2, zero, zero, t( 3, 1 ),
493 $ ldt )
494*
495 CALL clarf1f( 'L', ns, jw, work, 1, conjg( tau ), t, ldt,
496 $ work( jw+1 ) )
497 CALL clarf1f( 'R', ns, ns, work, 1, tau, t, ldt,
498 $ work( jw+1 ) )
499 CALL clarf1f( 'R', jw, ns, work, 1, tau, v, ldv,
500 $ work( jw+1 ) )
501*
502 CALL cgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
503 $ lwork-jw, info )
504 END IF
505*
506* ==== Copy updated reduced window into place ====
507*
508 IF( kwtop.GT.1 )
509 $ h( kwtop, kwtop-1 ) = s*conjg( v( 1, 1 ) )
510 CALL clacpy( 'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
511 CALL ccopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
512 $ ldh+1 )
513*
514* ==== Accumulate orthogonal matrix in order update
515* . H and Z, if requested. ====
516*
517 IF( ns.GT.1 .AND. s.NE.zero )
518 $ CALL cunmhr( 'R', 'N', jw, ns, 1, ns, t, ldt, work, v,
519 $ ldv,
520 $ work( jw+1 ), lwork-jw, info )
521*
522* ==== Update vertical slab in H ====
523*
524 IF( wantt ) THEN
525 ltop = 1
526 ELSE
527 ltop = ktop
528 END IF
529 DO 60 krow = ltop, kwtop - 1, nv
530 kln = min( nv, kwtop-krow )
531 CALL cgemm( 'N', 'N', kln, jw, jw, one, h( krow, kwtop ),
532 $ ldh, v, ldv, zero, wv, ldwv )
533 CALL clacpy( 'A', kln, jw, wv, ldwv, h( krow, kwtop ),
534 $ ldh )
535 60 CONTINUE
536*
537* ==== Update horizontal slab in H ====
538*
539 IF( wantt ) THEN
540 DO 70 kcol = kbot + 1, n, nh
541 kln = min( nh, n-kcol+1 )
542 CALL cgemm( 'C', 'N', jw, kln, jw, one, v, ldv,
543 $ h( kwtop, kcol ), ldh, zero, t, ldt )
544 CALL clacpy( 'A', jw, kln, t, ldt, h( kwtop, kcol ),
545 $ ldh )
546 70 CONTINUE
547 END IF
548*
549* ==== Update vertical slab in Z ====
550*
551 IF( wantz ) THEN
552 DO 80 krow = iloz, ihiz, nv
553 kln = min( nv, ihiz-krow+1 )
554 CALL cgemm( 'N', 'N', kln, jw, jw, one, z( krow,
555 $ kwtop ),
556 $ ldz, v, ldv, zero, wv, ldwv )
557 CALL clacpy( 'A', kln, jw, wv, ldwv, z( krow, kwtop ),
558 $ ldz )
559 80 CONTINUE
560 END IF
561 END IF
562*
563* ==== Return the number of deflations ... ====
564*
565 nd = jw - ns
566*
567* ==== ... and the number of shifts. (Subtracting
568* . INFQR from the spike length takes care
569* . of the case of a rare QR failure while
570* . calculating eigenvalues of the deflation
571* . window.) ====
572*
573 ns = ns - infqr
574*
575* ==== Return optimal workspace. ====
576*
577 work( 1 ) = cmplx( lwkopt, 0 )
578*
579* ==== End of CLAQR3 ====
580*
581 END
subroutine clarf1f(side, m, n, v, incv, tau, c, ldc, work)
CLARF1F applies an elementary reflector to a general rectangular
Definition clarf1f.f:126
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
Definition ccopy.f:81
subroutine cgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
CGEHRD
Definition cgehrd.f:166
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
Definition cgemm.f:188
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:101
subroutine clahqr(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, info)
CLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
Definition clahqr.f:193
subroutine claqr3(wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz, ihiz, z, ldz, ns, nd, sh, v, ldv, nh, t, ldt, nv, wv, ldwv, work, lwork)
CLAQR3 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fu...
Definition claqr3.f:265
subroutine claqr4(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, work, lwork, info)
CLAQR4 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
Definition claqr4.f:246
subroutine clarfg(n, alpha, x, incx, tau)
CLARFG generates an elementary reflector (Householder matrix).
Definition clarfg.f:104
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition claset.f:104
subroutine ctrexc(compq, n, t, ldt, q, ldq, ifst, ilst, info)
CTREXC
Definition ctrexc.f:124
subroutine cunmhr(side, trans, m, n, ilo, ihi, a, lda, tau, c, ldc, work, lwork, info)
CUNMHR
Definition cunmhr.f:177