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