Annotation of rpl/lapack/lapack/zlasyf_rook.f, revision 1.1
1.1 ! bertrand 1: *> \brief \b ZLASYF_ROOK computes a partial factorization of a complex symmetric matrix using the bounded Bunch-Kaufman ("rook") diagonal pivoting method.
! 2: *
! 3: * =========== DOCUMENTATION ===========
! 4: *
! 5: * Online html documentation available at
! 6: * http://www.netlib.org/lapack/explore-html/
! 7: *
! 8: *> \htmlonly
! 9: *> Download ZLASYF_ROOK + dependencies
! 10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlasyf_rook.f">
! 11: *> [TGZ]</a>
! 12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlasyf_rook.f">
! 13: *> [ZIP]</a>
! 14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlasyf_rook.f">
! 15: *> [TXT]</a>
! 16: *> \endhtmlonly
! 17: *
! 18: * Definition:
! 19: * ===========
! 20: *
! 21: * SUBROUTINE ZLASYF_ROOK( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW, INFO )
! 22: *
! 23: * .. Scalar Arguments ..
! 24: * CHARACTER UPLO
! 25: * INTEGER INFO, KB, LDA, LDW, N, NB
! 26: * ..
! 27: * .. Array Arguments ..
! 28: * INTEGER IPIV( * )
! 29: * COMPLEX*16 A( LDA, * ), W( LDW, * )
! 30: * ..
! 31: *
! 32: *
! 33: *> \par Purpose:
! 34: * =============
! 35: *>
! 36: *> \verbatim
! 37: *>
! 38: *> ZLASYF_ROOK computes a partial factorization of a complex symmetric
! 39: *> matrix A using the bounded Bunch-Kaufman ("rook") diagonal
! 40: *> pivoting method. The partial factorization has the form:
! 41: *>
! 42: *> A = ( I U12 ) ( A11 0 ) ( I 0 ) if UPLO = 'U', or:
! 43: *> ( 0 U22 ) ( 0 D ) ( U12**T U22**T )
! 44: *>
! 45: *> A = ( L11 0 ) ( D 0 ) ( L11**T L21**T ) if UPLO = 'L'
! 46: *> ( L21 I ) ( 0 A22 ) ( 0 I )
! 47: *>
! 48: *> where the order of D is at most NB. The actual order is returned in
! 49: *> the argument KB, and is either NB or NB-1, or N if N <= NB.
! 50: *>
! 51: *> ZLASYF_ROOK is an auxiliary routine called by ZSYTRF_ROOK. It uses
! 52: *> blocked code (calling Level 3 BLAS) to update the submatrix
! 53: *> A11 (if UPLO = 'U') or A22 (if UPLO = 'L').
! 54: *> \endverbatim
! 55: *
! 56: * Arguments:
! 57: * ==========
! 58: *
! 59: *> \param[in] UPLO
! 60: *> \verbatim
! 61: *> UPLO is CHARACTER*1
! 62: *> Specifies whether the upper or lower triangular part of the
! 63: *> symmetric matrix A is stored:
! 64: *> = 'U': Upper triangular
! 65: *> = 'L': Lower triangular
! 66: *> \endverbatim
! 67: *>
! 68: *> \param[in] N
! 69: *> \verbatim
! 70: *> N is INTEGER
! 71: *> The order of the matrix A. N >= 0.
! 72: *> \endverbatim
! 73: *>
! 74: *> \param[in] NB
! 75: *> \verbatim
! 76: *> NB is INTEGER
! 77: *> The maximum number of columns of the matrix A that should be
! 78: *> factored. NB should be at least 2 to allow for 2-by-2 pivot
! 79: *> blocks.
! 80: *> \endverbatim
! 81: *>
! 82: *> \param[out] KB
! 83: *> \verbatim
! 84: *> KB is INTEGER
! 85: *> The number of columns of A that were actually factored.
! 86: *> KB is either NB-1 or NB, or N if N <= NB.
! 87: *> \endverbatim
! 88: *>
! 89: *> \param[in,out] A
! 90: *> \verbatim
! 91: *> A is COMPLEX*16 array, dimension (LDA,N)
! 92: *> On entry, the symmetric matrix A. If UPLO = 'U', the leading
! 93: *> n-by-n upper triangular part of A contains the upper
! 94: *> triangular part of the matrix A, and the strictly lower
! 95: *> triangular part of A is not referenced. If UPLO = 'L', the
! 96: *> leading n-by-n lower triangular part of A contains the lower
! 97: *> triangular part of the matrix A, and the strictly upper
! 98: *> triangular part of A is not referenced.
! 99: *> On exit, A contains details of the partial factorization.
! 100: *> \endverbatim
! 101: *>
! 102: *> \param[in] LDA
! 103: *> \verbatim
! 104: *> LDA is INTEGER
! 105: *> The leading dimension of the array A. LDA >= max(1,N).
! 106: *> \endverbatim
! 107: *>
! 108: *> \param[out] IPIV
! 109: *> \verbatim
! 110: *> IPIV is INTEGER array, dimension (N)
! 111: *> Details of the interchanges and the block structure of D.
! 112: *>
! 113: *> If UPLO = 'U':
! 114: *> Only the last KB elements of IPIV are set.
! 115: *>
! 116: *> If IPIV(k) > 0, then rows and columns k and IPIV(k) were
! 117: *> interchanged and D(k,k) is a 1-by-1 diagonal block.
! 118: *>
! 119: *> If IPIV(k) < 0 and IPIV(k-1) < 0, then rows and
! 120: *> columns k and -IPIV(k) were interchanged and rows and
! 121: *> columns k-1 and -IPIV(k-1) were inerchaged,
! 122: *> D(k-1:k,k-1:k) is a 2-by-2 diagonal block.
! 123: *>
! 124: *> If UPLO = 'L':
! 125: *> Only the first KB elements of IPIV are set.
! 126: *>
! 127: *> If IPIV(k) > 0, then rows and columns k and IPIV(k)
! 128: *> were interchanged and D(k,k) is a 1-by-1 diagonal block.
! 129: *>
! 130: *> If IPIV(k) < 0 and IPIV(k+1) < 0, then rows and
! 131: *> columns k and -IPIV(k) were interchanged and rows and
! 132: *> columns k+1 and -IPIV(k+1) were inerchaged,
! 133: *> D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
! 134: *> \endverbatim
! 135: *>
! 136: *> \param[out] W
! 137: *> \verbatim
! 138: *> W is COMPLEX*16 array, dimension (LDW,NB)
! 139: *> \endverbatim
! 140: *>
! 141: *> \param[in] LDW
! 142: *> \verbatim
! 143: *> LDW is INTEGER
! 144: *> The leading dimension of the array W. LDW >= max(1,N).
! 145: *> \endverbatim
! 146: *>
! 147: *> \param[out] INFO
! 148: *> \verbatim
! 149: *> INFO is INTEGER
! 150: *> = 0: successful exit
! 151: *> > 0: if INFO = k, D(k,k) is exactly zero. The factorization
! 152: *> has been completed, but the block diagonal matrix D is
! 153: *> exactly singular.
! 154: *> \endverbatim
! 155: *
! 156: * Authors:
! 157: * ========
! 158: *
! 159: *> \author Univ. of Tennessee
! 160: *> \author Univ. of California Berkeley
! 161: *> \author Univ. of Colorado Denver
! 162: *> \author NAG Ltd.
! 163: *
! 164: *> \date November 2013
! 165: *
! 166: *> \ingroup complex16SYcomputational
! 167: *
! 168: *> \par Contributors:
! 169: * ==================
! 170: *>
! 171: *> \verbatim
! 172: *>
! 173: *> November 2013, Igor Kozachenko,
! 174: *> Computer Science Division,
! 175: *> University of California, Berkeley
! 176: *>
! 177: *> September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
! 178: *> School of Mathematics,
! 179: *> University of Manchester
! 180: *>
! 181: *> \endverbatim
! 182: *
! 183: * =====================================================================
! 184: SUBROUTINE ZLASYF_ROOK( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW,
! 185: $ INFO )
! 186: *
! 187: * -- LAPACK computational routine (version 3.5.0) --
! 188: * -- LAPACK is a software package provided by Univ. of Tennessee, --
! 189: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
! 190: * November 2013
! 191: *
! 192: * .. Scalar Arguments ..
! 193: CHARACTER UPLO
! 194: INTEGER INFO, KB, LDA, LDW, N, NB
! 195: * ..
! 196: * .. Array Arguments ..
! 197: INTEGER IPIV( * )
! 198: COMPLEX*16 A( LDA, * ), W( LDW, * )
! 199: * ..
! 200: *
! 201: * =====================================================================
! 202: *
! 203: * .. Parameters ..
! 204: DOUBLE PRECISION ZERO, ONE
! 205: PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
! 206: DOUBLE PRECISION EIGHT, SEVTEN
! 207: PARAMETER ( EIGHT = 8.0D+0, SEVTEN = 17.0D+0 )
! 208: COMPLEX*16 CONE, CZERO
! 209: PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ),
! 210: $ CZERO = ( 0.0D+0, 0.0D+0 ) )
! 211: * ..
! 212: * .. Local Scalars ..
! 213: LOGICAL DONE
! 214: INTEGER IMAX, ITEMP, J, JB, JJ, JMAX, JP1, JP2, K, KK,
! 215: $ KW, KKW, KP, KSTEP, P, II
! 216: DOUBLE PRECISION ABSAKK, ALPHA, COLMAX, ROWMAX, DTEMP, SFMIN
! 217: COMPLEX*16 D11, D12, D21, D22, R1, T, Z
! 218: * ..
! 219: * .. External Functions ..
! 220: LOGICAL LSAME
! 221: INTEGER IZAMAX
! 222: DOUBLE PRECISION DLAMCH
! 223: EXTERNAL LSAME, IZAMAX, DLAMCH
! 224: * ..
! 225: * .. External Subroutines ..
! 226: EXTERNAL ZCOPY, ZGEMM, ZGEMV, ZSCAL, ZSWAP
! 227: * ..
! 228: * .. Intrinsic Functions ..
! 229: INTRINSIC ABS, MAX, MIN, SQRT, DIMAG, DBLE
! 230: * ..
! 231: * .. Statement Functions ..
! 232: DOUBLE PRECISION CABS1
! 233: * ..
! 234: * .. Statement Function definitions ..
! 235: CABS1( Z ) = ABS( DBLE( Z ) ) + ABS( DIMAG( Z ) )
! 236: * ..
! 237: * .. Executable Statements ..
! 238: *
! 239: INFO = 0
! 240: *
! 241: * Initialize ALPHA for use in choosing pivot block size.
! 242: *
! 243: ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT
! 244: *
! 245: * Compute machine safe minimum
! 246: *
! 247: SFMIN = DLAMCH( 'S' )
! 248: *
! 249: IF( LSAME( UPLO, 'U' ) ) THEN
! 250: *
! 251: * Factorize the trailing columns of A using the upper triangle
! 252: * of A and working backwards, and compute the matrix W = U12*D
! 253: * for use in updating A11
! 254: *
! 255: * K is the main loop index, decreasing from N in steps of 1 or 2
! 256: *
! 257: K = N
! 258: 10 CONTINUE
! 259: *
! 260: * KW is the column of W which corresponds to column K of A
! 261: *
! 262: KW = NB + K - N
! 263: *
! 264: * Exit from loop
! 265: *
! 266: IF( ( K.LE.N-NB+1 .AND. NB.LT.N ) .OR. K.LT.1 )
! 267: $ GO TO 30
! 268: *
! 269: KSTEP = 1
! 270: P = K
! 271: *
! 272: * Copy column K of A to column KW of W and update it
! 273: *
! 274: CALL ZCOPY( K, A( 1, K ), 1, W( 1, KW ), 1 )
! 275: IF( K.LT.N )
! 276: $ CALL ZGEMV( 'No transpose', K, N-K, -CONE, A( 1, K+1 ),
! 277: $ LDA, W( K, KW+1 ), LDW, CONE, W( 1, KW ), 1 )
! 278: *
! 279: * Determine rows and columns to be interchanged and whether
! 280: * a 1-by-1 or 2-by-2 pivot block will be used
! 281: *
! 282: ABSAKK = CABS1( W( K, KW ) )
! 283: *
! 284: * IMAX is the row-index of the largest off-diagonal element in
! 285: * column K, and COLMAX is its absolute value.
! 286: * Determine both COLMAX and IMAX.
! 287: *
! 288: IF( K.GT.1 ) THEN
! 289: IMAX = IZAMAX( K-1, W( 1, KW ), 1 )
! 290: COLMAX = CABS1( W( IMAX, KW ) )
! 291: ELSE
! 292: COLMAX = ZERO
! 293: END IF
! 294: *
! 295: IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
! 296: *
! 297: * Column K is zero or underflow: set INFO and continue
! 298: *
! 299: IF( INFO.EQ.0 )
! 300: $ INFO = K
! 301: KP = K
! 302: CALL ZCOPY( K, W( 1, KW ), 1, A( 1, K ), 1 )
! 303: ELSE
! 304: *
! 305: * ============================================================
! 306: *
! 307: * Test for interchange
! 308: *
! 309: * Equivalent to testing for ABSAKK.GE.ALPHA*COLMAX
! 310: * (used to handle NaN and Inf)
! 311: *
! 312: IF( .NOT.( ABSAKK.LT.ALPHA*COLMAX ) ) THEN
! 313: *
! 314: * no interchange, use 1-by-1 pivot block
! 315: *
! 316: KP = K
! 317: *
! 318: ELSE
! 319: *
! 320: DONE = .FALSE.
! 321: *
! 322: * Loop until pivot found
! 323: *
! 324: 12 CONTINUE
! 325: *
! 326: * Begin pivot search loop body
! 327: *
! 328: *
! 329: * Copy column IMAX to column KW-1 of W and update it
! 330: *
! 331: CALL ZCOPY( IMAX, A( 1, IMAX ), 1, W( 1, KW-1 ), 1 )
! 332: CALL ZCOPY( K-IMAX, A( IMAX, IMAX+1 ), LDA,
! 333: $ W( IMAX+1, KW-1 ), 1 )
! 334: *
! 335: IF( K.LT.N )
! 336: $ CALL ZGEMV( 'No transpose', K, N-K, -CONE,
! 337: $ A( 1, K+1 ), LDA, W( IMAX, KW+1 ), LDW,
! 338: $ CONE, W( 1, KW-1 ), 1 )
! 339: *
! 340: * JMAX is the column-index of the largest off-diagonal
! 341: * element in row IMAX, and ROWMAX is its absolute value.
! 342: * Determine both ROWMAX and JMAX.
! 343: *
! 344: IF( IMAX.NE.K ) THEN
! 345: JMAX = IMAX + IZAMAX( K-IMAX, W( IMAX+1, KW-1 ),
! 346: $ 1 )
! 347: ROWMAX = CABS1( W( JMAX, KW-1 ) )
! 348: ELSE
! 349: ROWMAX = ZERO
! 350: END IF
! 351: *
! 352: IF( IMAX.GT.1 ) THEN
! 353: ITEMP = IZAMAX( IMAX-1, W( 1, KW-1 ), 1 )
! 354: DTEMP = CABS1( W( ITEMP, KW-1 ) )
! 355: IF( DTEMP.GT.ROWMAX ) THEN
! 356: ROWMAX = DTEMP
! 357: JMAX = ITEMP
! 358: END IF
! 359: END IF
! 360: *
! 361: * Equivalent to testing for
! 362: * CABS1( W( IMAX, KW-1 ) ).GE.ALPHA*ROWMAX
! 363: * (used to handle NaN and Inf)
! 364: *
! 365: IF( .NOT.(CABS1( W( IMAX, KW-1 ) ).LT.ALPHA*ROWMAX ) )
! 366: $ THEN
! 367: *
! 368: * interchange rows and columns K and IMAX,
! 369: * use 1-by-1 pivot block
! 370: *
! 371: KP = IMAX
! 372: *
! 373: * copy column KW-1 of W to column KW of W
! 374: *
! 375: CALL ZCOPY( K, W( 1, KW-1 ), 1, W( 1, KW ), 1 )
! 376: *
! 377: DONE = .TRUE.
! 378: *
! 379: * Equivalent to testing for ROWMAX.EQ.COLMAX,
! 380: * (used to handle NaN and Inf)
! 381: *
! 382: ELSE IF( ( P.EQ.JMAX ) .OR. ( ROWMAX.LE.COLMAX ) )
! 383: $ THEN
! 384: *
! 385: * interchange rows and columns K-1 and IMAX,
! 386: * use 2-by-2 pivot block
! 387: *
! 388: KP = IMAX
! 389: KSTEP = 2
! 390: DONE = .TRUE.
! 391: ELSE
! 392: *
! 393: * Pivot not found: set params and repeat
! 394: *
! 395: P = IMAX
! 396: COLMAX = ROWMAX
! 397: IMAX = JMAX
! 398: *
! 399: * Copy updated JMAXth (next IMAXth) column to Kth of W
! 400: *
! 401: CALL ZCOPY( K, W( 1, KW-1 ), 1, W( 1, KW ), 1 )
! 402: *
! 403: END IF
! 404: *
! 405: * End pivot search loop body
! 406: *
! 407: IF( .NOT. DONE ) GOTO 12
! 408: *
! 409: END IF
! 410: *
! 411: * ============================================================
! 412: *
! 413: KK = K - KSTEP + 1
! 414: *
! 415: * KKW is the column of W which corresponds to column KK of A
! 416: *
! 417: KKW = NB + KK - N
! 418: *
! 419: IF( ( KSTEP.EQ.2 ) .AND. ( P.NE.K ) ) THEN
! 420: *
! 421: * Copy non-updated column K to column P
! 422: *
! 423: CALL ZCOPY( K-P, A( P+1, K ), 1, A( P, P+1 ), LDA )
! 424: CALL ZCOPY( P, A( 1, K ), 1, A( 1, P ), 1 )
! 425: *
! 426: * Interchange rows K and P in last N-K+1 columns of A
! 427: * and last N-K+2 columns of W
! 428: *
! 429: CALL ZSWAP( N-K+1, A( K, K ), LDA, A( P, K ), LDA )
! 430: CALL ZSWAP( N-KK+1, W( K, KKW ), LDW, W( P, KKW ), LDW )
! 431: END IF
! 432: *
! 433: * Updated column KP is already stored in column KKW of W
! 434: *
! 435: IF( KP.NE.KK ) THEN
! 436: *
! 437: * Copy non-updated column KK to column KP
! 438: *
! 439: A( KP, K ) = A( KK, K )
! 440: CALL ZCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ),
! 441: $ LDA )
! 442: CALL ZCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 )
! 443: *
! 444: * Interchange rows KK and KP in last N-KK+1 columns
! 445: * of A and W
! 446: *
! 447: CALL ZSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA )
! 448: CALL ZSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ),
! 449: $ LDW )
! 450: END IF
! 451: *
! 452: IF( KSTEP.EQ.1 ) THEN
! 453: *
! 454: * 1-by-1 pivot block D(k): column KW of W now holds
! 455: *
! 456: * W(k) = U(k)*D(k)
! 457: *
! 458: * where U(k) is the k-th column of U
! 459: *
! 460: * Store U(k) in column k of A
! 461: *
! 462: CALL ZCOPY( K, W( 1, KW ), 1, A( 1, K ), 1 )
! 463: IF( K.GT.1 ) THEN
! 464: IF( CABS1( A( K, K ) ).GE.SFMIN ) THEN
! 465: R1 = CONE / A( K, K )
! 466: CALL ZSCAL( K-1, R1, A( 1, K ), 1 )
! 467: ELSE IF( A( K, K ).NE.CZERO ) THEN
! 468: DO 14 II = 1, K - 1
! 469: A( II, K ) = A( II, K ) / A( K, K )
! 470: 14 CONTINUE
! 471: END IF
! 472: END IF
! 473: *
! 474: ELSE
! 475: *
! 476: * 2-by-2 pivot block D(k): columns KW and KW-1 of W now
! 477: * hold
! 478: *
! 479: * ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
! 480: *
! 481: * where U(k) and U(k-1) are the k-th and (k-1)-th columns
! 482: * of U
! 483: *
! 484: IF( K.GT.2 ) THEN
! 485: *
! 486: * Store U(k) and U(k-1) in columns k and k-1 of A
! 487: *
! 488: D12 = W( K-1, KW )
! 489: D11 = W( K, KW ) / D12
! 490: D22 = W( K-1, KW-1 ) / D12
! 491: T = CONE / ( D11*D22-CONE )
! 492: DO 20 J = 1, K - 2
! 493: A( J, K-1 ) = T*( (D11*W( J, KW-1 )-W( J, KW ) ) /
! 494: $ D12 )
! 495: A( J, K ) = T*( ( D22*W( J, KW )-W( J, KW-1 ) ) /
! 496: $ D12 )
! 497: 20 CONTINUE
! 498: END IF
! 499: *
! 500: * Copy D(k) to A
! 501: *
! 502: A( K-1, K-1 ) = W( K-1, KW-1 )
! 503: A( K-1, K ) = W( K-1, KW )
! 504: A( K, K ) = W( K, KW )
! 505: END IF
! 506: END IF
! 507: *
! 508: * Store details of the interchanges in IPIV
! 509: *
! 510: IF( KSTEP.EQ.1 ) THEN
! 511: IPIV( K ) = KP
! 512: ELSE
! 513: IPIV( K ) = -P
! 514: IPIV( K-1 ) = -KP
! 515: END IF
! 516: *
! 517: * Decrease K and return to the start of the main loop
! 518: *
! 519: K = K - KSTEP
! 520: GO TO 10
! 521: *
! 522: 30 CONTINUE
! 523: *
! 524: * Update the upper triangle of A11 (= A(1:k,1:k)) as
! 525: *
! 526: * A11 := A11 - U12*D*U12**T = A11 - U12*W**T
! 527: *
! 528: * computing blocks of NB columns at a time
! 529: *
! 530: DO 50 J = ( ( K-1 ) / NB )*NB + 1, 1, -NB
! 531: JB = MIN( NB, K-J+1 )
! 532: *
! 533: * Update the upper triangle of the diagonal block
! 534: *
! 535: DO 40 JJ = J, J + JB - 1
! 536: CALL ZGEMV( 'No transpose', JJ-J+1, N-K, -CONE,
! 537: $ A( J, K+1 ), LDA, W( JJ, KW+1 ), LDW, CONE,
! 538: $ A( J, JJ ), 1 )
! 539: 40 CONTINUE
! 540: *
! 541: * Update the rectangular superdiagonal block
! 542: *
! 543: IF( J.GE.2 )
! 544: $ CALL ZGEMM( 'No transpose', 'Transpose', J-1, JB,
! 545: $ N-K, -CONE, A( 1, K+1 ), LDA, W( J, KW+1 ), LDW,
! 546: $ CONE, A( 1, J ), LDA )
! 547: 50 CONTINUE
! 548: *
! 549: * Put U12 in standard form by partially undoing the interchanges
! 550: * in columns k+1:n
! 551: *
! 552: J = K + 1
! 553: 60 CONTINUE
! 554: *
! 555: KSTEP = 1
! 556: JP1 = 1
! 557: JJ = J
! 558: JP2 = IPIV( J )
! 559: IF( JP2.LT.0 ) THEN
! 560: JP2 = -JP2
! 561: J = J + 1
! 562: JP1 = -IPIV( J )
! 563: KSTEP = 2
! 564: END IF
! 565: *
! 566: J = J + 1
! 567: IF( JP2.NE.JJ .AND. J.LE.N )
! 568: $ CALL ZSWAP( N-J+1, A( JP2, J ), LDA, A( JJ, J ), LDA )
! 569: JJ = J - 1
! 570: IF( JP1.NE.JJ .AND. KSTEP.EQ.2 )
! 571: $ CALL ZSWAP( N-J+1, A( JP1, J ), LDA, A( JJ, J ), LDA )
! 572: IF( J.LE.N )
! 573: $ GO TO 60
! 574: *
! 575: * Set KB to the number of columns factorized
! 576: *
! 577: KB = N - K
! 578: *
! 579: ELSE
! 580: *
! 581: * Factorize the leading columns of A using the lower triangle
! 582: * of A and working forwards, and compute the matrix W = L21*D
! 583: * for use in updating A22
! 584: *
! 585: * K is the main loop index, increasing from 1 in steps of 1 or 2
! 586: *
! 587: K = 1
! 588: 70 CONTINUE
! 589: *
! 590: * Exit from loop
! 591: *
! 592: IF( ( K.GE.NB .AND. NB.LT.N ) .OR. K.GT.N )
! 593: $ GO TO 90
! 594: *
! 595: KSTEP = 1
! 596: P = K
! 597: *
! 598: * Copy column K of A to column K of W and update it
! 599: *
! 600: CALL ZCOPY( N-K+1, A( K, K ), 1, W( K, K ), 1 )
! 601: IF( K.GT.1 )
! 602: $ CALL ZGEMV( 'No transpose', N-K+1, K-1, -CONE, A( K, 1 ),
! 603: $ LDA, W( K, 1 ), LDW, CONE, W( K, K ), 1 )
! 604: *
! 605: * Determine rows and columns to be interchanged and whether
! 606: * a 1-by-1 or 2-by-2 pivot block will be used
! 607: *
! 608: ABSAKK = CABS1( W( K, K ) )
! 609: *
! 610: * IMAX is the row-index of the largest off-diagonal element in
! 611: * column K, and COLMAX is its absolute value.
! 612: * Determine both COLMAX and IMAX.
! 613: *
! 614: IF( K.LT.N ) THEN
! 615: IMAX = K + IZAMAX( N-K, W( K+1, K ), 1 )
! 616: COLMAX = CABS1( W( IMAX, K ) )
! 617: ELSE
! 618: COLMAX = ZERO
! 619: END IF
! 620: *
! 621: IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
! 622: *
! 623: * Column K is zero or underflow: set INFO and continue
! 624: *
! 625: IF( INFO.EQ.0 )
! 626: $ INFO = K
! 627: KP = K
! 628: CALL ZCOPY( N-K+1, W( K, K ), 1, A( K, K ), 1 )
! 629: ELSE
! 630: *
! 631: * ============================================================
! 632: *
! 633: * Test for interchange
! 634: *
! 635: * Equivalent to testing for ABSAKK.GE.ALPHA*COLMAX
! 636: * (used to handle NaN and Inf)
! 637: *
! 638: IF( .NOT.( ABSAKK.LT.ALPHA*COLMAX ) ) THEN
! 639: *
! 640: * no interchange, use 1-by-1 pivot block
! 641: *
! 642: KP = K
! 643: *
! 644: ELSE
! 645: *
! 646: DONE = .FALSE.
! 647: *
! 648: * Loop until pivot found
! 649: *
! 650: 72 CONTINUE
! 651: *
! 652: * Begin pivot search loop body
! 653: *
! 654: *
! 655: * Copy column IMAX to column K+1 of W and update it
! 656: *
! 657: CALL ZCOPY( IMAX-K, A( IMAX, K ), LDA, W( K, K+1 ), 1)
! 658: CALL ZCOPY( N-IMAX+1, A( IMAX, IMAX ), 1,
! 659: $ W( IMAX, K+1 ), 1 )
! 660: IF( K.GT.1 )
! 661: $ CALL ZGEMV( 'No transpose', N-K+1, K-1, -CONE,
! 662: $ A( K, 1 ), LDA, W( IMAX, 1 ), LDW,
! 663: $ CONE, W( K, K+1 ), 1 )
! 664: *
! 665: * JMAX is the column-index of the largest off-diagonal
! 666: * element in row IMAX, and ROWMAX is its absolute value.
! 667: * Determine both ROWMAX and JMAX.
! 668: *
! 669: IF( IMAX.NE.K ) THEN
! 670: JMAX = K - 1 + IZAMAX( IMAX-K, W( K, K+1 ), 1 )
! 671: ROWMAX = CABS1( W( JMAX, K+1 ) )
! 672: ELSE
! 673: ROWMAX = ZERO
! 674: END IF
! 675: *
! 676: IF( IMAX.LT.N ) THEN
! 677: ITEMP = IMAX + IZAMAX( N-IMAX, W( IMAX+1, K+1 ), 1)
! 678: DTEMP = CABS1( W( ITEMP, K+1 ) )
! 679: IF( DTEMP.GT.ROWMAX ) THEN
! 680: ROWMAX = DTEMP
! 681: JMAX = ITEMP
! 682: END IF
! 683: END IF
! 684: *
! 685: * Equivalent to testing for
! 686: * CABS1( W( IMAX, K+1 ) ).GE.ALPHA*ROWMAX
! 687: * (used to handle NaN and Inf)
! 688: *
! 689: IF( .NOT.( CABS1( W( IMAX, K+1 ) ).LT.ALPHA*ROWMAX ) )
! 690: $ THEN
! 691: *
! 692: * interchange rows and columns K and IMAX,
! 693: * use 1-by-1 pivot block
! 694: *
! 695: KP = IMAX
! 696: *
! 697: * copy column K+1 of W to column K of W
! 698: *
! 699: CALL ZCOPY( N-K+1, W( K, K+1 ), 1, W( K, K ), 1 )
! 700: *
! 701: DONE = .TRUE.
! 702: *
! 703: * Equivalent to testing for ROWMAX.EQ.COLMAX,
! 704: * (used to handle NaN and Inf)
! 705: *
! 706: ELSE IF( ( P.EQ.JMAX ) .OR. ( ROWMAX.LE.COLMAX ) )
! 707: $ THEN
! 708: *
! 709: * interchange rows and columns K+1 and IMAX,
! 710: * use 2-by-2 pivot block
! 711: *
! 712: KP = IMAX
! 713: KSTEP = 2
! 714: DONE = .TRUE.
! 715: ELSE
! 716: *
! 717: * Pivot not found: set params and repeat
! 718: *
! 719: P = IMAX
! 720: COLMAX = ROWMAX
! 721: IMAX = JMAX
! 722: *
! 723: * Copy updated JMAXth (next IMAXth) column to Kth of W
! 724: *
! 725: CALL ZCOPY( N-K+1, W( K, K+1 ), 1, W( K, K ), 1 )
! 726: *
! 727: END IF
! 728: *
! 729: * End pivot search loop body
! 730: *
! 731: IF( .NOT. DONE ) GOTO 72
! 732: *
! 733: END IF
! 734: *
! 735: * ============================================================
! 736: *
! 737: KK = K + KSTEP - 1
! 738: *
! 739: IF( ( KSTEP.EQ.2 ) .AND. ( P.NE.K ) ) THEN
! 740: *
! 741: * Copy non-updated column K to column P
! 742: *
! 743: CALL ZCOPY( P-K, A( K, K ), 1, A( P, K ), LDA )
! 744: CALL ZCOPY( N-P+1, A( P, K ), 1, A( P, P ), 1 )
! 745: *
! 746: * Interchange rows K and P in first K columns of A
! 747: * and first K+1 columns of W
! 748: *
! 749: CALL ZSWAP( K, A( K, 1 ), LDA, A( P, 1 ), LDA )
! 750: CALL ZSWAP( KK, W( K, 1 ), LDW, W( P, 1 ), LDW )
! 751: END IF
! 752: *
! 753: * Updated column KP is already stored in column KK of W
! 754: *
! 755: IF( KP.NE.KK ) THEN
! 756: *
! 757: * Copy non-updated column KK to column KP
! 758: *
! 759: A( KP, K ) = A( KK, K )
! 760: CALL ZCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA )
! 761: CALL ZCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 )
! 762: *
! 763: * Interchange rows KK and KP in first KK columns of A and W
! 764: *
! 765: CALL ZSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA )
! 766: CALL ZSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW )
! 767: END IF
! 768: *
! 769: IF( KSTEP.EQ.1 ) THEN
! 770: *
! 771: * 1-by-1 pivot block D(k): column k of W now holds
! 772: *
! 773: * W(k) = L(k)*D(k)
! 774: *
! 775: * where L(k) is the k-th column of L
! 776: *
! 777: * Store L(k) in column k of A
! 778: *
! 779: CALL ZCOPY( N-K+1, W( K, K ), 1, A( K, K ), 1 )
! 780: IF( K.LT.N ) THEN
! 781: IF( CABS1( A( K, K ) ).GE.SFMIN ) THEN
! 782: R1 = CONE / A( K, K )
! 783: CALL ZSCAL( N-K, R1, A( K+1, K ), 1 )
! 784: ELSE IF( A( K, K ).NE.CZERO ) THEN
! 785: DO 74 II = K + 1, N
! 786: A( II, K ) = A( II, K ) / A( K, K )
! 787: 74 CONTINUE
! 788: END IF
! 789: END IF
! 790: *
! 791: ELSE
! 792: *
! 793: * 2-by-2 pivot block D(k): columns k and k+1 of W now hold
! 794: *
! 795: * ( W(k) W(k+1) ) = ( L(k) L(k+1) )*D(k)
! 796: *
! 797: * where L(k) and L(k+1) are the k-th and (k+1)-th columns
! 798: * of L
! 799: *
! 800: IF( K.LT.N-1 ) THEN
! 801: *
! 802: * Store L(k) and L(k+1) in columns k and k+1 of A
! 803: *
! 804: D21 = W( K+1, K )
! 805: D11 = W( K+1, K+1 ) / D21
! 806: D22 = W( K, K ) / D21
! 807: T = CONE / ( D11*D22-CONE )
! 808: DO 80 J = K + 2, N
! 809: A( J, K ) = T*( ( D11*W( J, K )-W( J, K+1 ) ) /
! 810: $ D21 )
! 811: A( J, K+1 ) = T*( ( D22*W( J, K+1 )-W( J, K ) ) /
! 812: $ D21 )
! 813: 80 CONTINUE
! 814: END IF
! 815: *
! 816: * Copy D(k) to A
! 817: *
! 818: A( K, K ) = W( K, K )
! 819: A( K+1, K ) = W( K+1, K )
! 820: A( K+1, K+1 ) = W( K+1, K+1 )
! 821: END IF
! 822: END IF
! 823: *
! 824: * Store details of the interchanges in IPIV
! 825: *
! 826: IF( KSTEP.EQ.1 ) THEN
! 827: IPIV( K ) = KP
! 828: ELSE
! 829: IPIV( K ) = -P
! 830: IPIV( K+1 ) = -KP
! 831: END IF
! 832: *
! 833: * Increase K and return to the start of the main loop
! 834: *
! 835: K = K + KSTEP
! 836: GO TO 70
! 837: *
! 838: 90 CONTINUE
! 839: *
! 840: * Update the lower triangle of A22 (= A(k:n,k:n)) as
! 841: *
! 842: * A22 := A22 - L21*D*L21**T = A22 - L21*W**T
! 843: *
! 844: * computing blocks of NB columns at a time
! 845: *
! 846: DO 110 J = K, N, NB
! 847: JB = MIN( NB, N-J+1 )
! 848: *
! 849: * Update the lower triangle of the diagonal block
! 850: *
! 851: DO 100 JJ = J, J + JB - 1
! 852: CALL ZGEMV( 'No transpose', J+JB-JJ, K-1, -CONE,
! 853: $ A( JJ, 1 ), LDA, W( JJ, 1 ), LDW, CONE,
! 854: $ A( JJ, JJ ), 1 )
! 855: 100 CONTINUE
! 856: *
! 857: * Update the rectangular subdiagonal block
! 858: *
! 859: IF( J+JB.LE.N )
! 860: $ CALL ZGEMM( 'No transpose', 'Transpose', N-J-JB+1, JB,
! 861: $ K-1, -CONE, A( J+JB, 1 ), LDA, W( J, 1 ), LDW,
! 862: $ CONE, A( J+JB, J ), LDA )
! 863: 110 CONTINUE
! 864: *
! 865: * Put L21 in standard form by partially undoing the interchanges
! 866: * in columns 1:k-1
! 867: *
! 868: J = K - 1
! 869: 120 CONTINUE
! 870: *
! 871: KSTEP = 1
! 872: JP1 = 1
! 873: JJ = J
! 874: JP2 = IPIV( J )
! 875: IF( JP2.LT.0 ) THEN
! 876: JP2 = -JP2
! 877: J = J - 1
! 878: JP1 = -IPIV( J )
! 879: KSTEP = 2
! 880: END IF
! 881: *
! 882: J = J - 1
! 883: IF( JP2.NE.JJ .AND. J.GE.1 )
! 884: $ CALL ZSWAP( J, A( JP2, 1 ), LDA, A( JJ, 1 ), LDA )
! 885: JJ = J + 1
! 886: IF( JP1.NE.JJ .AND. KSTEP.EQ.2 )
! 887: $ CALL ZSWAP( J, A( JP1, 1 ), LDA, A( JJ, 1 ), LDA )
! 888: IF( J.GE.1 )
! 889: $ GO TO 120
! 890: *
! 891: * Set KB to the number of columns factorized
! 892: *
! 893: KB = K - 1
! 894: *
! 895: END IF
! 896: RETURN
! 897: *
! 898: * End of ZLASYF_ROOK
! 899: *
! 900: END
CVSweb interface <joel.bertrand@systella.fr>