Annotation of rpl/lapack/lapack/zlaqr4.f, revision 1.1
1.1 ! bertrand 1: SUBROUTINE ZLAQR4( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
! 2: $ IHIZ, Z, LDZ, WORK, LWORK, INFO )
! 3: *
! 4: * -- LAPACK auxiliary routine (version 3.2) --
! 5: * Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..
! 6: * November 2006
! 7: *
! 8: * .. Scalar Arguments ..
! 9: INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
! 10: LOGICAL WANTT, WANTZ
! 11: * ..
! 12: * .. Array Arguments ..
! 13: COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )
! 14: * ..
! 15: *
! 16: * This subroutine implements one level of recursion for ZLAQR0.
! 17: * It is a complete implementation of the small bulge multi-shift
! 18: * QR algorithm. It may be called by ZLAQR0 and, for large enough
! 19: * deflation window size, it may be called by ZLAQR3. This
! 20: * subroutine is identical to ZLAQR0 except that it calls ZLAQR2
! 21: * instead of ZLAQR3.
! 22: *
! 23: * Purpose
! 24: * =======
! 25: *
! 26: * ZLAQR4 computes the eigenvalues of a Hessenberg matrix H
! 27: * and, optionally, the matrices T and Z from the Schur decomposition
! 28: * H = Z T Z**H, where T is an upper triangular matrix (the
! 29: * Schur form), and Z is the unitary matrix of Schur vectors.
! 30: *
! 31: * Optionally Z may be postmultiplied into an input unitary
! 32: * matrix Q so that this routine can give the Schur factorization
! 33: * of a matrix A which has been reduced to the Hessenberg form H
! 34: * by the unitary matrix Q: A = Q*H*Q**H = (QZ)*H*(QZ)**H.
! 35: *
! 36: * Arguments
! 37: * =========
! 38: *
! 39: * WANTT (input) LOGICAL
! 40: * = .TRUE. : the full Schur form T is required;
! 41: * = .FALSE.: only eigenvalues are required.
! 42: *
! 43: * WANTZ (input) LOGICAL
! 44: * = .TRUE. : the matrix of Schur vectors Z is required;
! 45: * = .FALSE.: Schur vectors are not required.
! 46: *
! 47: * N (input) INTEGER
! 48: * The order of the matrix H. N .GE. 0.
! 49: *
! 50: * ILO (input) INTEGER
! 51: * IHI (input) INTEGER
! 52: * It is assumed that H is already upper triangular in rows
! 53: * and columns 1:ILO-1 and IHI+1:N and, if ILO.GT.1,
! 54: * H(ILO,ILO-1) is zero. ILO and IHI are normally set by a
! 55: * previous call to ZGEBAL, and then passed to ZGEHRD when the
! 56: * matrix output by ZGEBAL is reduced to Hessenberg form.
! 57: * Otherwise, ILO and IHI should be set to 1 and N,
! 58: * respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N.
! 59: * If N = 0, then ILO = 1 and IHI = 0.
! 60: *
! 61: * H (input/output) COMPLEX*16 array, dimension (LDH,N)
! 62: * On entry, the upper Hessenberg matrix H.
! 63: * On exit, if INFO = 0 and WANTT is .TRUE., then H
! 64: * contains the upper triangular matrix T from the Schur
! 65: * decomposition (the Schur form). If INFO = 0 and WANT is
! 66: * .FALSE., then the contents of H are unspecified on exit.
! 67: * (The output value of H when INFO.GT.0 is given under the
! 68: * description of INFO below.)
! 69: *
! 70: * This subroutine may explicitly set H(i,j) = 0 for i.GT.j and
! 71: * j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N.
! 72: *
! 73: * LDH (input) INTEGER
! 74: * The leading dimension of the array H. LDH .GE. max(1,N).
! 75: *
! 76: * W (output) COMPLEX*16 array, dimension (N)
! 77: * The computed eigenvalues of H(ILO:IHI,ILO:IHI) are stored
! 78: * in W(ILO:IHI). If WANTT is .TRUE., then the eigenvalues are
! 79: * stored in the same order as on the diagonal of the Schur
! 80: * form returned in H, with W(i) = H(i,i).
! 81: *
! 82: * Z (input/output) COMPLEX*16 array, dimension (LDZ,IHI)
! 83: * If WANTZ is .FALSE., then Z is not referenced.
! 84: * If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is
! 85: * replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the
! 86: * orthogonal Schur factor of H(ILO:IHI,ILO:IHI).
! 87: * (The output value of Z when INFO.GT.0 is given under
! 88: * the description of INFO below.)
! 89: *
! 90: * LDZ (input) INTEGER
! 91: * The leading dimension of the array Z. if WANTZ is .TRUE.
! 92: * then LDZ.GE.MAX(1,IHIZ). Otherwize, LDZ.GE.1.
! 93: *
! 94: * WORK (workspace/output) COMPLEX*16 array, dimension LWORK
! 95: * On exit, if LWORK = -1, WORK(1) returns an estimate of
! 96: * the optimal value for LWORK.
! 97: *
! 98: * LWORK (input) INTEGER
! 99: * The dimension of the array WORK. LWORK .GE. max(1,N)
! 100: * is sufficient, but LWORK typically as large as 6*N may
! 101: * be required for optimal performance. A workspace query
! 102: * to determine the optimal workspace size is recommended.
! 103: *
! 104: * If LWORK = -1, then ZLAQR4 does a workspace query.
! 105: * In this case, ZLAQR4 checks the input parameters and
! 106: * estimates the optimal workspace size for the given
! 107: * values of N, ILO and IHI. The estimate is returned
! 108: * in WORK(1). No error message related to LWORK is
! 109: * issued by XERBLA. Neither H nor Z are accessed.
! 110: *
! 111: *
! 112: * INFO (output) INTEGER
! 113: * = 0: successful exit
! 114: * .GT. 0: if INFO = i, ZLAQR4 failed to compute all of
! 115: * the eigenvalues. Elements 1:ilo-1 and i+1:n of WR
! 116: * and WI contain those eigenvalues which have been
! 117: * successfully computed. (Failures are rare.)
! 118: *
! 119: * If INFO .GT. 0 and WANT is .FALSE., then on exit,
! 120: * the remaining unconverged eigenvalues are the eigen-
! 121: * values of the upper Hessenberg matrix rows and
! 122: * columns ILO through INFO of the final, output
! 123: * value of H.
! 124: *
! 125: * If INFO .GT. 0 and WANTT is .TRUE., then on exit
! 126: *
! 127: * (*) (initial value of H)*U = U*(final value of H)
! 128: *
! 129: * where U is a unitary matrix. The final
! 130: * value of H is upper Hessenberg and triangular in
! 131: * rows and columns INFO+1 through IHI.
! 132: *
! 133: * If INFO .GT. 0 and WANTZ is .TRUE., then on exit
! 134: *
! 135: * (final value of Z(ILO:IHI,ILOZ:IHIZ)
! 136: * = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U
! 137: *
! 138: * where U is the unitary matrix in (*) (regard-
! 139: * less of the value of WANTT.)
! 140: *
! 141: * If INFO .GT. 0 and WANTZ is .FALSE., then Z is not
! 142: * accessed.
! 143: *
! 144: * ================================================================
! 145: * Based on contributions by
! 146: * Karen Braman and Ralph Byers, Department of Mathematics,
! 147: * University of Kansas, USA
! 148: *
! 149: * ================================================================
! 150: * References:
! 151: * K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
! 152: * Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
! 153: * Performance, SIAM Journal of Matrix Analysis, volume 23, pages
! 154: * 929--947, 2002.
! 155: *
! 156: * K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
! 157: * Algorithm Part II: Aggressive Early Deflation, SIAM Journal
! 158: * of Matrix Analysis, volume 23, pages 948--973, 2002.
! 159: *
! 160: * ================================================================
! 161: * .. Parameters ..
! 162: *
! 163: * ==== Matrices of order NTINY or smaller must be processed by
! 164: * . ZLAHQR because of insufficient subdiagonal scratch space.
! 165: * . (This is a hard limit.) ====
! 166: INTEGER NTINY
! 167: PARAMETER ( NTINY = 11 )
! 168: *
! 169: * ==== Exceptional deflation windows: try to cure rare
! 170: * . slow convergence by varying the size of the
! 171: * . deflation window after KEXNW iterations. ====
! 172: INTEGER KEXNW
! 173: PARAMETER ( KEXNW = 5 )
! 174: *
! 175: * ==== Exceptional shifts: try to cure rare slow convergence
! 176: * . with ad-hoc exceptional shifts every KEXSH iterations.
! 177: * . ====
! 178: INTEGER KEXSH
! 179: PARAMETER ( KEXSH = 6 )
! 180: *
! 181: * ==== The constant WILK1 is used to form the exceptional
! 182: * . shifts. ====
! 183: DOUBLE PRECISION WILK1
! 184: PARAMETER ( WILK1 = 0.75d0 )
! 185: COMPLEX*16 ZERO, ONE
! 186: PARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),
! 187: $ ONE = ( 1.0d0, 0.0d0 ) )
! 188: DOUBLE PRECISION TWO
! 189: PARAMETER ( TWO = 2.0d0 )
! 190: * ..
! 191: * .. Local Scalars ..
! 192: COMPLEX*16 AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2
! 193: DOUBLE PRECISION S
! 194: INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
! 195: $ KT, KTOP, KU, KV, KWH, KWTOP, KWV, LD, LS,
! 196: $ LWKOPT, NDEC, NDFL, NH, NHO, NIBBLE, NMIN, NS,
! 197: $ NSMAX, NSR, NVE, NW, NWMAX, NWR, NWUPBD
! 198: LOGICAL SORTED
! 199: CHARACTER JBCMPZ*2
! 200: * ..
! 201: * .. External Functions ..
! 202: INTEGER ILAENV
! 203: EXTERNAL ILAENV
! 204: * ..
! 205: * .. Local Arrays ..
! 206: COMPLEX*16 ZDUM( 1, 1 )
! 207: * ..
! 208: * .. External Subroutines ..
! 209: EXTERNAL ZLACPY, ZLAHQR, ZLAQR2, ZLAQR5
! 210: * ..
! 211: * .. Intrinsic Functions ..
! 212: INTRINSIC ABS, DBLE, DCMPLX, DIMAG, INT, MAX, MIN, MOD,
! 213: $ SQRT
! 214: * ..
! 215: * .. Statement Functions ..
! 216: DOUBLE PRECISION CABS1
! 217: * ..
! 218: * .. Statement Function definitions ..
! 219: CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
! 220: * ..
! 221: * .. Executable Statements ..
! 222: INFO = 0
! 223: *
! 224: * ==== Quick return for N = 0: nothing to do. ====
! 225: *
! 226: IF( N.EQ.0 ) THEN
! 227: WORK( 1 ) = ONE
! 228: RETURN
! 229: END IF
! 230: *
! 231: IF( N.LE.NTINY ) THEN
! 232: *
! 233: * ==== Tiny matrices must use ZLAHQR. ====
! 234: *
! 235: LWKOPT = 1
! 236: IF( LWORK.NE.-1 )
! 237: $ CALL ZLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
! 238: $ IHIZ, Z, LDZ, INFO )
! 239: ELSE
! 240: *
! 241: * ==== Use small bulge multi-shift QR with aggressive early
! 242: * . deflation on larger-than-tiny matrices. ====
! 243: *
! 244: * ==== Hope for the best. ====
! 245: *
! 246: INFO = 0
! 247: *
! 248: * ==== Set up job flags for ILAENV. ====
! 249: *
! 250: IF( WANTT ) THEN
! 251: JBCMPZ( 1: 1 ) = 'S'
! 252: ELSE
! 253: JBCMPZ( 1: 1 ) = 'E'
! 254: END IF
! 255: IF( WANTZ ) THEN
! 256: JBCMPZ( 2: 2 ) = 'V'
! 257: ELSE
! 258: JBCMPZ( 2: 2 ) = 'N'
! 259: END IF
! 260: *
! 261: * ==== NWR = recommended deflation window size. At this
! 262: * . point, N .GT. NTINY = 11, so there is enough
! 263: * . subdiagonal workspace for NWR.GE.2 as required.
! 264: * . (In fact, there is enough subdiagonal space for
! 265: * . NWR.GE.3.) ====
! 266: *
! 267: NWR = ILAENV( 13, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )
! 268: NWR = MAX( 2, NWR )
! 269: NWR = MIN( IHI-ILO+1, ( N-1 ) / 3, NWR )
! 270: *
! 271: * ==== NSR = recommended number of simultaneous shifts.
! 272: * . At this point N .GT. NTINY = 11, so there is at
! 273: * . enough subdiagonal workspace for NSR to be even
! 274: * . and greater than or equal to two as required. ====
! 275: *
! 276: NSR = ILAENV( 15, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )
! 277: NSR = MIN( NSR, ( N+6 ) / 9, IHI-ILO )
! 278: NSR = MAX( 2, NSR-MOD( NSR, 2 ) )
! 279: *
! 280: * ==== Estimate optimal workspace ====
! 281: *
! 282: * ==== Workspace query call to ZLAQR2 ====
! 283: *
! 284: CALL ZLAQR2( WANTT, WANTZ, N, ILO, IHI, NWR+1, H, LDH, ILOZ,
! 285: $ IHIZ, Z, LDZ, LS, LD, W, H, LDH, N, H, LDH, N, H,
! 286: $ LDH, WORK, -1 )
! 287: *
! 288: * ==== Optimal workspace = MAX(ZLAQR5, ZLAQR2) ====
! 289: *
! 290: LWKOPT = MAX( 3*NSR / 2, INT( WORK( 1 ) ) )
! 291: *
! 292: * ==== Quick return in case of workspace query. ====
! 293: *
! 294: IF( LWORK.EQ.-1 ) THEN
! 295: WORK( 1 ) = DCMPLX( LWKOPT, 0 )
! 296: RETURN
! 297: END IF
! 298: *
! 299: * ==== ZLAHQR/ZLAQR0 crossover point ====
! 300: *
! 301: NMIN = ILAENV( 12, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )
! 302: NMIN = MAX( NTINY, NMIN )
! 303: *
! 304: * ==== Nibble crossover point ====
! 305: *
! 306: NIBBLE = ILAENV( 14, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )
! 307: NIBBLE = MAX( 0, NIBBLE )
! 308: *
! 309: * ==== Accumulate reflections during ttswp? Use block
! 310: * . 2-by-2 structure during matrix-matrix multiply? ====
! 311: *
! 312: KACC22 = ILAENV( 16, 'ZLAQR4', JBCMPZ, N, ILO, IHI, LWORK )
! 313: KACC22 = MAX( 0, KACC22 )
! 314: KACC22 = MIN( 2, KACC22 )
! 315: *
! 316: * ==== NWMAX = the largest possible deflation window for
! 317: * . which there is sufficient workspace. ====
! 318: *
! 319: NWMAX = MIN( ( N-1 ) / 3, LWORK / 2 )
! 320: NW = NWMAX
! 321: *
! 322: * ==== NSMAX = the Largest number of simultaneous shifts
! 323: * . for which there is sufficient workspace. ====
! 324: *
! 325: NSMAX = MIN( ( N+6 ) / 9, 2*LWORK / 3 )
! 326: NSMAX = NSMAX - MOD( NSMAX, 2 )
! 327: *
! 328: * ==== NDFL: an iteration count restarted at deflation. ====
! 329: *
! 330: NDFL = 1
! 331: *
! 332: * ==== ITMAX = iteration limit ====
! 333: *
! 334: ITMAX = MAX( 30, 2*KEXSH )*MAX( 10, ( IHI-ILO+1 ) )
! 335: *
! 336: * ==== Last row and column in the active block ====
! 337: *
! 338: KBOT = IHI
! 339: *
! 340: * ==== Main Loop ====
! 341: *
! 342: DO 70 IT = 1, ITMAX
! 343: *
! 344: * ==== Done when KBOT falls below ILO ====
! 345: *
! 346: IF( KBOT.LT.ILO )
! 347: $ GO TO 80
! 348: *
! 349: * ==== Locate active block ====
! 350: *
! 351: DO 10 K = KBOT, ILO + 1, -1
! 352: IF( H( K, K-1 ).EQ.ZERO )
! 353: $ GO TO 20
! 354: 10 CONTINUE
! 355: K = ILO
! 356: 20 CONTINUE
! 357: KTOP = K
! 358: *
! 359: * ==== Select deflation window size:
! 360: * . Typical Case:
! 361: * . If possible and advisable, nibble the entire
! 362: * . active block. If not, use size MIN(NWR,NWMAX)
! 363: * . or MIN(NWR+1,NWMAX) depending upon which has
! 364: * . the smaller corresponding subdiagonal entry
! 365: * . (a heuristic).
! 366: * .
! 367: * . Exceptional Case:
! 368: * . If there have been no deflations in KEXNW or
! 369: * . more iterations, then vary the deflation window
! 370: * . size. At first, because, larger windows are,
! 371: * . in general, more powerful than smaller ones,
! 372: * . rapidly increase the window to the maximum possible.
! 373: * . Then, gradually reduce the window size. ====
! 374: *
! 375: NH = KBOT - KTOP + 1
! 376: NWUPBD = MIN( NH, NWMAX )
! 377: IF( NDFL.LT.KEXNW ) THEN
! 378: NW = MIN( NWUPBD, NWR )
! 379: ELSE
! 380: NW = MIN( NWUPBD, 2*NW )
! 381: END IF
! 382: IF( NW.LT.NWMAX ) THEN
! 383: IF( NW.GE.NH-1 ) THEN
! 384: NW = NH
! 385: ELSE
! 386: KWTOP = KBOT - NW + 1
! 387: IF( CABS1( H( KWTOP, KWTOP-1 ) ).GT.
! 388: $ CABS1( H( KWTOP-1, KWTOP-2 ) ) )NW = NW + 1
! 389: END IF
! 390: END IF
! 391: IF( NDFL.LT.KEXNW ) THEN
! 392: NDEC = -1
! 393: ELSE IF( NDEC.GE.0 .OR. NW.GE.NWUPBD ) THEN
! 394: NDEC = NDEC + 1
! 395: IF( NW-NDEC.LT.2 )
! 396: $ NDEC = 0
! 397: NW = NW - NDEC
! 398: END IF
! 399: *
! 400: * ==== Aggressive early deflation:
! 401: * . split workspace under the subdiagonal into
! 402: * . - an nw-by-nw work array V in the lower
! 403: * . left-hand-corner,
! 404: * . - an NW-by-at-least-NW-but-more-is-better
! 405: * . (NW-by-NHO) horizontal work array along
! 406: * . the bottom edge,
! 407: * . - an at-least-NW-but-more-is-better (NHV-by-NW)
! 408: * . vertical work array along the left-hand-edge.
! 409: * . ====
! 410: *
! 411: KV = N - NW + 1
! 412: KT = NW + 1
! 413: NHO = ( N-NW-1 ) - KT + 1
! 414: KWV = NW + 2
! 415: NVE = ( N-NW ) - KWV + 1
! 416: *
! 417: * ==== Aggressive early deflation ====
! 418: *
! 419: CALL ZLAQR2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,
! 420: $ IHIZ, Z, LDZ, LS, LD, W, H( KV, 1 ), LDH, NHO,
! 421: $ H( KV, KT ), LDH, NVE, H( KWV, 1 ), LDH, WORK,
! 422: $ LWORK )
! 423: *
! 424: * ==== Adjust KBOT accounting for new deflations. ====
! 425: *
! 426: KBOT = KBOT - LD
! 427: *
! 428: * ==== KS points to the shifts. ====
! 429: *
! 430: KS = KBOT - LS + 1
! 431: *
! 432: * ==== Skip an expensive QR sweep if there is a (partly
! 433: * . heuristic) reason to expect that many eigenvalues
! 434: * . will deflate without it. Here, the QR sweep is
! 435: * . skipped if many eigenvalues have just been deflated
! 436: * . or if the remaining active block is small.
! 437: *
! 438: IF( ( LD.EQ.0 ) .OR. ( ( 100*LD.LE.NW*NIBBLE ) .AND. ( KBOT-
! 439: $ KTOP+1.GT.MIN( NMIN, NWMAX ) ) ) ) THEN
! 440: *
! 441: * ==== NS = nominal number of simultaneous shifts.
! 442: * . This may be lowered (slightly) if ZLAQR2
! 443: * . did not provide that many shifts. ====
! 444: *
! 445: NS = MIN( NSMAX, NSR, MAX( 2, KBOT-KTOP ) )
! 446: NS = NS - MOD( NS, 2 )
! 447: *
! 448: * ==== If there have been no deflations
! 449: * . in a multiple of KEXSH iterations,
! 450: * . then try exceptional shifts.
! 451: * . Otherwise use shifts provided by
! 452: * . ZLAQR2 above or from the eigenvalues
! 453: * . of a trailing principal submatrix. ====
! 454: *
! 455: IF( MOD( NDFL, KEXSH ).EQ.0 ) THEN
! 456: KS = KBOT - NS + 1
! 457: DO 30 I = KBOT, KS + 1, -2
! 458: W( I ) = H( I, I ) + WILK1*CABS1( H( I, I-1 ) )
! 459: W( I-1 ) = W( I )
! 460: 30 CONTINUE
! 461: ELSE
! 462: *
! 463: * ==== Got NS/2 or fewer shifts? Use ZLAHQR
! 464: * . on a trailing principal submatrix to
! 465: * . get more. (Since NS.LE.NSMAX.LE.(N+6)/9,
! 466: * . there is enough space below the subdiagonal
! 467: * . to fit an NS-by-NS scratch array.) ====
! 468: *
! 469: IF( KBOT-KS+1.LE.NS / 2 ) THEN
! 470: KS = KBOT - NS + 1
! 471: KT = N - NS + 1
! 472: CALL ZLACPY( 'A', NS, NS, H( KS, KS ), LDH,
! 473: $ H( KT, 1 ), LDH )
! 474: CALL ZLAHQR( .false., .false., NS, 1, NS,
! 475: $ H( KT, 1 ), LDH, W( KS ), 1, 1, ZDUM,
! 476: $ 1, INF )
! 477: KS = KS + INF
! 478: *
! 479: * ==== In case of a rare QR failure use
! 480: * . eigenvalues of the trailing 2-by-2
! 481: * . principal submatrix. Scale to avoid
! 482: * . overflows, underflows and subnormals.
! 483: * . (The scale factor S can not be zero,
! 484: * . because H(KBOT,KBOT-1) is nonzero.) ====
! 485: *
! 486: IF( KS.GE.KBOT ) THEN
! 487: S = CABS1( H( KBOT-1, KBOT-1 ) ) +
! 488: $ CABS1( H( KBOT, KBOT-1 ) ) +
! 489: $ CABS1( H( KBOT-1, KBOT ) ) +
! 490: $ CABS1( H( KBOT, KBOT ) )
! 491: AA = H( KBOT-1, KBOT-1 ) / S
! 492: CC = H( KBOT, KBOT-1 ) / S
! 493: BB = H( KBOT-1, KBOT ) / S
! 494: DD = H( KBOT, KBOT ) / S
! 495: TR2 = ( AA+DD ) / TWO
! 496: DET = ( AA-TR2 )*( DD-TR2 ) - BB*CC
! 497: RTDISC = SQRT( -DET )
! 498: W( KBOT-1 ) = ( TR2+RTDISC )*S
! 499: W( KBOT ) = ( TR2-RTDISC )*S
! 500: *
! 501: KS = KBOT - 1
! 502: END IF
! 503: END IF
! 504: *
! 505: IF( KBOT-KS+1.GT.NS ) THEN
! 506: *
! 507: * ==== Sort the shifts (Helps a little) ====
! 508: *
! 509: SORTED = .false.
! 510: DO 50 K = KBOT, KS + 1, -1
! 511: IF( SORTED )
! 512: $ GO TO 60
! 513: SORTED = .true.
! 514: DO 40 I = KS, K - 1
! 515: IF( CABS1( W( I ) ).LT.CABS1( W( I+1 ) ) )
! 516: $ THEN
! 517: SORTED = .false.
! 518: SWAP = W( I )
! 519: W( I ) = W( I+1 )
! 520: W( I+1 ) = SWAP
! 521: END IF
! 522: 40 CONTINUE
! 523: 50 CONTINUE
! 524: 60 CONTINUE
! 525: END IF
! 526: END IF
! 527: *
! 528: * ==== If there are only two shifts, then use
! 529: * . only one. ====
! 530: *
! 531: IF( KBOT-KS+1.EQ.2 ) THEN
! 532: IF( CABS1( W( KBOT )-H( KBOT, KBOT ) ).LT.
! 533: $ CABS1( W( KBOT-1 )-H( KBOT, KBOT ) ) ) THEN
! 534: W( KBOT-1 ) = W( KBOT )
! 535: ELSE
! 536: W( KBOT ) = W( KBOT-1 )
! 537: END IF
! 538: END IF
! 539: *
! 540: * ==== Use up to NS of the the smallest magnatiude
! 541: * . shifts. If there aren't NS shifts available,
! 542: * . then use them all, possibly dropping one to
! 543: * . make the number of shifts even. ====
! 544: *
! 545: NS = MIN( NS, KBOT-KS+1 )
! 546: NS = NS - MOD( NS, 2 )
! 547: KS = KBOT - NS + 1
! 548: *
! 549: * ==== Small-bulge multi-shift QR sweep:
! 550: * . split workspace under the subdiagonal into
! 551: * . - a KDU-by-KDU work array U in the lower
! 552: * . left-hand-corner,
! 553: * . - a KDU-by-at-least-KDU-but-more-is-better
! 554: * . (KDU-by-NHo) horizontal work array WH along
! 555: * . the bottom edge,
! 556: * . - and an at-least-KDU-but-more-is-better-by-KDU
! 557: * . (NVE-by-KDU) vertical work WV arrow along
! 558: * . the left-hand-edge. ====
! 559: *
! 560: KDU = 3*NS - 3
! 561: KU = N - KDU + 1
! 562: KWH = KDU + 1
! 563: NHO = ( N-KDU+1-4 ) - ( KDU+1 ) + 1
! 564: KWV = KDU + 4
! 565: NVE = N - KDU - KWV + 1
! 566: *
! 567: * ==== Small-bulge multi-shift QR sweep ====
! 568: *
! 569: CALL ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NS,
! 570: $ W( KS ), H, LDH, ILOZ, IHIZ, Z, LDZ, WORK,
! 571: $ 3, H( KU, 1 ), LDH, NVE, H( KWV, 1 ), LDH,
! 572: $ NHO, H( KU, KWH ), LDH )
! 573: END IF
! 574: *
! 575: * ==== Note progress (or the lack of it). ====
! 576: *
! 577: IF( LD.GT.0 ) THEN
! 578: NDFL = 1
! 579: ELSE
! 580: NDFL = NDFL + 1
! 581: END IF
! 582: *
! 583: * ==== End of main loop ====
! 584: 70 CONTINUE
! 585: *
! 586: * ==== Iteration limit exceeded. Set INFO to show where
! 587: * . the problem occurred and exit. ====
! 588: *
! 589: INFO = KBOT
! 590: 80 CONTINUE
! 591: END IF
! 592: *
! 593: * ==== Return the optimal value of LWORK. ====
! 594: *
! 595: WORK( 1 ) = DCMPLX( LWKOPT, 0 )
! 596: *
! 597: * ==== End of ZLAQR4 ====
! 598: *
! 599: END
CVSweb interface <joel.bertrand@systella.fr>