LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ claqr2()

subroutine claqr2 ( logical  wantt,
logical  wantz,
integer  n,
integer  ktop,
integer  kbot,
integer  nw,
complex, dimension( ldh, * )  h,
integer  ldh,
integer  iloz,
integer  ihiz,
complex, dimension( ldz, * )  z,
integer  ldz,
integer  ns,
integer  nd,
complex, dimension( * )  sh,
complex, dimension( ldv, * )  v,
integer  ldv,
integer  nh,
complex, dimension( ldt, * )  t,
integer  ldt,
integer  nv,
complex, dimension( ldwv, * )  wv,
integer  ldwv,
complex, dimension( * )  work,
integer  lwork 
)

CLAQR2 performs the unitary similarity transformation of a Hessenberg matrix to detect and deflate fully converged eigenvalues from a trailing principal submatrix (aggressive early deflation).

Download CLAQR2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
    CLAQR2 is identical to CLAQR3 except that it avoids
    recursion by calling CLAHQR instead of CLAQR4.

    Aggressive early deflation:

    This subroutine accepts as input an upper Hessenberg matrix
    H and performs an unitary similarity transformation
    designed to detect and deflate fully converged eigenvalues from
    a trailing principal submatrix.  On output H has been over-
    written by a new Hessenberg matrix that is a perturbation of
    an unitary similarity transformation of H.  It is to be
    hoped that the final version of H has many zero subdiagonal
    entries.
Parameters
[in]WANTT
          WANTT is LOGICAL
          If .TRUE., then the Hessenberg matrix H is fully updated
          so that the triangular Schur factor may be
          computed (in cooperation with the calling subroutine).
          If .FALSE., then only enough of H is updated to preserve
          the eigenvalues.
[in]WANTZ
          WANTZ is LOGICAL
          If .TRUE., then the unitary matrix Z is updated so
          so that the unitary Schur factor may be computed
          (in cooperation with the calling subroutine).
          If .FALSE., then Z is not referenced.
[in]N
          N is INTEGER
          The order of the matrix H and (if WANTZ is .TRUE.) the
          order of the unitary matrix Z.
[in]KTOP
          KTOP is INTEGER
          It is assumed that either KTOP = 1 or H(KTOP,KTOP-1)=0.
          KBOT and KTOP together determine an isolated block
          along the diagonal of the Hessenberg matrix.
[in]KBOT
          KBOT is INTEGER
          It is assumed without a check that either
          KBOT = N or H(KBOT+1,KBOT)=0.  KBOT and KTOP together
          determine an isolated block along the diagonal of the
          Hessenberg matrix.
[in]NW
          NW is INTEGER
          Deflation window size.  1 <= NW <= (KBOT-KTOP+1).
[in,out]H
          H is COMPLEX array, dimension (LDH,N)
          On input the initial N-by-N section of H stores the
          Hessenberg matrix undergoing aggressive early deflation.
          On output H has been transformed by a unitary
          similarity transformation, perturbed, and the returned
          to Hessenberg form that (it is to be hoped) has some
          zero subdiagonal entries.
[in]LDH
          LDH is INTEGER
          Leading dimension of H just as declared in the calling
          subroutine.  N <= LDH
[in]ILOZ
          ILOZ is INTEGER
[in]IHIZ
          IHIZ is INTEGER
          Specify the rows of Z to which transformations must be
          applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N.
[in,out]Z
          Z is COMPLEX array, dimension (LDZ,N)
          IF WANTZ is .TRUE., then on output, the unitary
          similarity transformation mentioned above has been
          accumulated into Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.
          If WANTZ is .FALSE., then Z is unreferenced.
[in]LDZ
          LDZ is INTEGER
          The leading dimension of Z just as declared in the
          calling subroutine.  1 <= LDZ.
[out]NS
          NS is INTEGER
          The number of unconverged (ie approximate) eigenvalues
          returned in SR and SI that may be used as shifts by the
          calling subroutine.
[out]ND
          ND is INTEGER
          The number of converged eigenvalues uncovered by this
          subroutine.
[out]SH
          SH is COMPLEX array, dimension (KBOT)
          On output, approximate eigenvalues that may
          be used for shifts are stored in SH(KBOT-ND-NS+1)
          through SR(KBOT-ND).  Converged eigenvalues are
          stored in SH(KBOT-ND+1) through SH(KBOT).
[out]V
          V is COMPLEX array, dimension (LDV,NW)
          An NW-by-NW work array.
[in]LDV
          LDV is INTEGER
          The leading dimension of V just as declared in the
          calling subroutine.  NW <= LDV
[in]NH
          NH is INTEGER
          The number of columns of T.  NH >= NW.
[out]T
          T is COMPLEX array, dimension (LDT,NW)
[in]LDT
          LDT is INTEGER
          The leading dimension of T just as declared in the
          calling subroutine.  NW <= LDT
[in]NV
          NV is INTEGER
          The number of rows of work array WV available for
          workspace.  NV >= NW.
[out]WV
          WV is COMPLEX array, dimension (LDWV,NW)
[in]LDWV
          LDWV is INTEGER
          The leading dimension of W just as declared in the
          calling subroutine.  NW <= LDV
[out]WORK
          WORK is COMPLEX array, dimension (LWORK)
          On exit, WORK(1) is set to an estimate of the optimal value
          of LWORK for the given values of N, NW, KTOP and KBOT.
[in]LWORK
          LWORK is INTEGER
          The dimension of the work array WORK.  LWORK = 2*NW
          suffices, but greater efficiency may result from larger
          values of LWORK.

          If LWORK = -1, then a workspace query is assumed; CLAQR2
          only estimates the optimal workspace size for the given
          values of N, NW, KTOP and KBOT.  The estimate is returned
          in WORK(1).  No error message related to LWORK is issued
          by XERBLA.  Neither H nor Z are accessed.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Contributors:
Karen Braman and Ralph Byers, Department of Mathematics, University of Kansas, USA

Definition at line 266 of file claqr2.f.

269*
270* -- LAPACK auxiliary routine --
271* -- LAPACK is a software package provided by Univ. of Tennessee, --
272* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
273*
274* .. Scalar Arguments ..
275 INTEGER IHIZ, ILOZ, KBOT, KTOP, LDH, LDT, LDV, LDWV,
276 $ LDZ, LWORK, N, ND, NH, NS, NV, NW
277 LOGICAL WANTT, WANTZ
278* ..
279* .. Array Arguments ..
280 COMPLEX H( LDH, * ), SH( * ), T( LDT, * ), V( LDV, * ),
281 $ WORK( * ), WV( LDWV, * ), Z( LDZ, * )
282* ..
283*
284* ================================================================
285*
286* .. Parameters ..
287 COMPLEX ZERO, ONE
288 parameter( zero = ( 0.0e0, 0.0e0 ),
289 $ one = ( 1.0e0, 0.0e0 ) )
290 REAL RZERO, RONE
291 parameter( rzero = 0.0e0, rone = 1.0e0 )
292* ..
293* .. Local Scalars ..
294 COMPLEX BETA, CDUM, S, TAU
295 REAL FOO, SAFMAX, SAFMIN, SMLNUM, ULP
296 INTEGER I, IFST, ILST, INFO, INFQR, J, JW, KCOL, KLN,
297 $ KNT, KROW, KWTOP, LTOP, LWK1, LWK2, LWKOPT
298* ..
299* .. External Functions ..
300 REAL SLAMCH
301 EXTERNAL slamch
302* ..
303* .. External Subroutines ..
304 EXTERNAL ccopy, cgehrd, cgemm, clacpy, clahqr, clarf,
306* ..
307* .. Intrinsic Functions ..
308 INTRINSIC abs, aimag, cmplx, conjg, int, max, min, real
309* ..
310* .. Statement Functions ..
311 REAL CABS1
312* ..
313* .. Statement Function definitions ..
314 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
315* ..
316* .. Executable Statements ..
317*
318* ==== Estimate optimal workspace. ====
319*
320 jw = min( nw, kbot-ktop+1 )
321 IF( jw.LE.2 ) THEN
322 lwkopt = 1
323 ELSE
324*
325* ==== Workspace query call to CGEHRD ====
326*
327 CALL cgehrd( jw, 1, jw-1, t, ldt, work, work, -1, info )
328 lwk1 = int( work( 1 ) )
329*
330* ==== Workspace query call to CUNMHR ====
331*
332 CALL cunmhr( 'R', 'N', jw, jw, 1, jw-1, t, ldt, work, v, ldv,
333 $ work, -1, info )
334 lwk2 = int( work( 1 ) )
335*
336* ==== Optimal workspace ====
337*
338 lwkopt = jw + max( lwk1, lwk2 )
339 END IF
340*
341* ==== Quick return in case of workspace query. ====
342*
343 IF( lwork.EQ.-1 ) THEN
344 work( 1 ) = cmplx( lwkopt, 0 )
345 RETURN
346 END IF
347*
348* ==== Nothing to do ...
349* ... for an empty active block ... ====
350 ns = 0
351 nd = 0
352 work( 1 ) = one
353 IF( ktop.GT.kbot )
354 $ RETURN
355* ... nor for an empty deflation window. ====
356 IF( nw.LT.1 )
357 $ RETURN
358*
359* ==== Machine constants ====
360*
361 safmin = slamch( 'SAFE MINIMUM' )
362 safmax = rone / safmin
363 ulp = slamch( 'PRECISION' )
364 smlnum = safmin*( real( n ) / ulp )
365*
366* ==== Setup deflation window ====
367*
368 jw = min( nw, kbot-ktop+1 )
369 kwtop = kbot - jw + 1
370 IF( kwtop.EQ.ktop ) THEN
371 s = zero
372 ELSE
373 s = h( kwtop, kwtop-1 )
374 END IF
375*
376 IF( kbot.EQ.kwtop ) THEN
377*
378* ==== 1-by-1 deflation window: not much to do ====
379*
380 sh( kwtop ) = h( kwtop, kwtop )
381 ns = 1
382 nd = 0
383 IF( cabs1( s ).LE.max( smlnum, ulp*cabs1( h( kwtop,
384 $ kwtop ) ) ) ) THEN
385 ns = 0
386 nd = 1
387 IF( kwtop.GT.ktop )
388 $ h( kwtop, kwtop-1 ) = zero
389 END IF
390 work( 1 ) = one
391 RETURN
392 END IF
393*
394* ==== Convert to spike-triangular form. (In case of a
395* . rare QR failure, this routine continues to do
396* . aggressive early deflation using that part of
397* . the deflation window that converged using INFQR
398* . here and there to keep track.) ====
399*
400 CALL clacpy( 'U', jw, jw, h( kwtop, kwtop ), ldh, t, ldt )
401 CALL ccopy( jw-1, h( kwtop+1, kwtop ), ldh+1, t( 2, 1 ), ldt+1 )
402*
403 CALL claset( 'A', jw, jw, zero, one, v, ldv )
404 CALL clahqr( .true., .true., jw, 1, jw, t, ldt, sh( kwtop ), 1,
405 $ jw, v, ldv, infqr )
406*
407* ==== Deflation detection loop ====
408*
409 ns = jw
410 ilst = infqr + 1
411 DO 10 knt = infqr + 1, jw
412*
413* ==== Small spike tip deflation test ====
414*
415 foo = cabs1( t( ns, ns ) )
416 IF( foo.EQ.rzero )
417 $ foo = cabs1( s )
418 IF( cabs1( s )*cabs1( v( 1, ns ) ).LE.max( smlnum, ulp*foo ) )
419 $ THEN
420*
421* ==== One more converged eigenvalue ====
422*
423 ns = ns - 1
424 ELSE
425*
426* ==== One undeflatable eigenvalue. Move it up out of the
427* . way. (CTREXC can not fail in this case.) ====
428*
429 ifst = ns
430 CALL ctrexc( 'V', jw, t, ldt, v, ldv, ifst, ilst, info )
431 ilst = ilst + 1
432 END IF
433 10 CONTINUE
434*
435* ==== Return to Hessenberg form ====
436*
437 IF( ns.EQ.0 )
438 $ s = zero
439*
440 IF( ns.LT.jw ) THEN
441*
442* ==== sorting the diagonal of T improves accuracy for
443* . graded matrices. ====
444*
445 DO 30 i = infqr + 1, ns
446 ifst = i
447 DO 20 j = i + 1, ns
448 IF( cabs1( t( j, j ) ).GT.cabs1( t( ifst, ifst ) ) )
449 $ ifst = j
450 20 CONTINUE
451 ilst = i
452 IF( ifst.NE.ilst )
453 $ CALL ctrexc( 'V', jw, t, ldt, v, ldv, ifst, ilst, info )
454 30 CONTINUE
455 END IF
456*
457* ==== Restore shift/eigenvalue array from T ====
458*
459 DO 40 i = infqr + 1, jw
460 sh( kwtop+i-1 ) = t( i, i )
461 40 CONTINUE
462*
463*
464 IF( ns.LT.jw .OR. s.EQ.zero ) THEN
465 IF( ns.GT.1 .AND. s.NE.zero ) THEN
466*
467* ==== Reflect spike back into lower triangle ====
468*
469 CALL ccopy( ns, v, ldv, work, 1 )
470 DO 50 i = 1, ns
471 work( i ) = conjg( work( i ) )
472 50 CONTINUE
473 beta = work( 1 )
474 CALL clarfg( ns, beta, work( 2 ), 1, tau )
475 work( 1 ) = one
476*
477 CALL claset( 'L', jw-2, jw-2, zero, zero, t( 3, 1 ), ldt )
478*
479 CALL clarf( 'L', ns, jw, work, 1, conjg( tau ), t, ldt,
480 $ work( jw+1 ) )
481 CALL clarf( 'R', ns, ns, work, 1, tau, t, ldt,
482 $ work( jw+1 ) )
483 CALL clarf( 'R', jw, ns, work, 1, tau, v, ldv,
484 $ work( jw+1 ) )
485*
486 CALL cgehrd( jw, 1, ns, t, ldt, work, work( jw+1 ),
487 $ lwork-jw, info )
488 END IF
489*
490* ==== Copy updated reduced window into place ====
491*
492 IF( kwtop.GT.1 )
493 $ h( kwtop, kwtop-1 ) = s*conjg( v( 1, 1 ) )
494 CALL clacpy( 'U', jw, jw, t, ldt, h( kwtop, kwtop ), ldh )
495 CALL ccopy( jw-1, t( 2, 1 ), ldt+1, h( kwtop+1, kwtop ),
496 $ ldh+1 )
497*
498* ==== Accumulate orthogonal matrix in order update
499* . H and Z, if requested. ====
500*
501 IF( ns.GT.1 .AND. s.NE.zero )
502 $ CALL cunmhr( 'R', 'N', jw, ns, 1, ns, t, ldt, work, v, ldv,
503 $ work( jw+1 ), lwork-jw, info )
504*
505* ==== Update vertical slab in H ====
506*
507 IF( wantt ) THEN
508 ltop = 1
509 ELSE
510 ltop = ktop
511 END IF
512 DO 60 krow = ltop, kwtop - 1, nv
513 kln = min( nv, kwtop-krow )
514 CALL cgemm( 'N', 'N', kln, jw, jw, one, h( krow, kwtop ),
515 $ ldh, v, ldv, zero, wv, ldwv )
516 CALL clacpy( 'A', kln, jw, wv, ldwv, h( krow, kwtop ), ldh )
517 60 CONTINUE
518*
519* ==== Update horizontal slab in H ====
520*
521 IF( wantt ) THEN
522 DO 70 kcol = kbot + 1, n, nh
523 kln = min( nh, n-kcol+1 )
524 CALL cgemm( 'C', 'N', jw, kln, jw, one, v, ldv,
525 $ h( kwtop, kcol ), ldh, zero, t, ldt )
526 CALL clacpy( 'A', jw, kln, t, ldt, h( kwtop, kcol ),
527 $ ldh )
528 70 CONTINUE
529 END IF
530*
531* ==== Update vertical slab in Z ====
532*
533 IF( wantz ) THEN
534 DO 80 krow = iloz, ihiz, nv
535 kln = min( nv, ihiz-krow+1 )
536 CALL cgemm( 'N', 'N', kln, jw, jw, one, z( krow, kwtop ),
537 $ ldz, v, ldv, zero, wv, ldwv )
538 CALL clacpy( 'A', kln, jw, wv, ldwv, z( krow, kwtop ),
539 $ ldz )
540 80 CONTINUE
541 END IF
542 END IF
543*
544* ==== Return the number of deflations ... ====
545*
546 nd = jw - ns
547*
548* ==== ... and the number of shifts. (Subtracting
549* . INFQR from the spike length takes care
550* . of the case of a rare QR failure while
551* . calculating eigenvalues of the deflation
552* . window.) ====
553*
554 ns = ns - infqr
555*
556* ==== Return optimal workspace. ====
557*
558 work( 1 ) = cmplx( lwkopt, 0 )
559*
560* ==== End of CLAQR2 ====
561*
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:167
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:103
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:195
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
subroutine clarf(side, m, n, v, incv, tau, c, ldc, work)
CLARF applies an elementary reflector to a general rectangular matrix.
Definition clarf.f:128
subroutine clarfg(n, alpha, x, incx, tau)
CLARFG generates an elementary reflector (Householder matrix).
Definition clarfg.f:106
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:106
subroutine ctrexc(compq, n, t, ldt, q, ldq, ifst, ilst, info)
CTREXC
Definition ctrexc.f:126
subroutine cunmhr(side, trans, m, n, ilo, ihi, a, lda, tau, c, ldc, work, lwork, info)
CUNMHR
Definition cunmhr.f:179
Here is the call graph for this function:
Here is the caller graph for this function: