Annotation of rpl/lapack/lapack/dsytf2.f, revision 1.20

1.12      bertrand    1: *> \brief \b DSYTF2 computes the factorization of a real symmetric indefinite matrix, using the diagonal pivoting method (unblocked algorithm).
1.9       bertrand    2: *
                      3: *  =========== DOCUMENTATION ===========
                      4: *
1.17      bertrand    5: * Online html documentation available at
                      6: *            http://www.netlib.org/lapack/explore-html/
1.9       bertrand    7: *
                      8: *> \htmlonly
1.17      bertrand    9: *> Download DSYTF2 + dependencies
                     10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsytf2.f">
                     11: *> [TGZ]</a>
                     12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsytf2.f">
                     13: *> [ZIP]</a>
                     14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsytf2.f">
1.9       bertrand   15: *> [TXT]</a>
1.17      bertrand   16: *> \endhtmlonly
1.9       bertrand   17: *
                     18: *  Definition:
                     19: *  ===========
                     20: *
                     21: *       SUBROUTINE DSYTF2( UPLO, N, A, LDA, IPIV, INFO )
1.17      bertrand   22: *
1.9       bertrand   23: *       .. Scalar Arguments ..
                     24: *       CHARACTER          UPLO
                     25: *       INTEGER            INFO, LDA, N
                     26: *       ..
                     27: *       .. Array Arguments ..
                     28: *       INTEGER            IPIV( * )
                     29: *       DOUBLE PRECISION   A( LDA, * )
                     30: *       ..
1.17      bertrand   31: *
1.9       bertrand   32: *
                     33: *> \par Purpose:
                     34: *  =============
                     35: *>
                     36: *> \verbatim
                     37: *>
                     38: *> DSYTF2 computes the factorization of a real symmetric matrix A using
                     39: *> the Bunch-Kaufman diagonal pivoting method:
                     40: *>
                     41: *>    A = U*D*U**T  or  A = L*D*L**T
                     42: *>
                     43: *> where U (or L) is a product of permutation and unit upper (lower)
                     44: *> triangular matrices, U**T is the transpose of U, and D is symmetric and
                     45: *> block diagonal with 1-by-1 and 2-by-2 diagonal blocks.
                     46: *>
                     47: *> This is the unblocked version of the algorithm, calling Level 2 BLAS.
                     48: *> \endverbatim
                     49: *
                     50: *  Arguments:
                     51: *  ==========
                     52: *
                     53: *> \param[in] UPLO
                     54: *> \verbatim
                     55: *>          UPLO is CHARACTER*1
                     56: *>          Specifies whether the upper or lower triangular part of the
                     57: *>          symmetric matrix A is stored:
                     58: *>          = 'U':  Upper triangular
                     59: *>          = 'L':  Lower triangular
                     60: *> \endverbatim
                     61: *>
                     62: *> \param[in] N
                     63: *> \verbatim
                     64: *>          N is INTEGER
                     65: *>          The order of the matrix A.  N >= 0.
                     66: *> \endverbatim
                     67: *>
                     68: *> \param[in,out] A
                     69: *> \verbatim
                     70: *>          A is DOUBLE PRECISION array, dimension (LDA,N)
                     71: *>          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
                     72: *>          n-by-n upper triangular part of A contains the upper
                     73: *>          triangular part of the matrix A, and the strictly lower
                     74: *>          triangular part of A is not referenced.  If UPLO = 'L', the
                     75: *>          leading n-by-n lower triangular part of A contains the lower
                     76: *>          triangular part of the matrix A, and the strictly upper
                     77: *>          triangular part of A is not referenced.
                     78: *>
                     79: *>          On exit, the block diagonal matrix D and the multipliers used
                     80: *>          to obtain the factor U or L (see below for further details).
                     81: *> \endverbatim
                     82: *>
                     83: *> \param[in] LDA
                     84: *> \verbatim
                     85: *>          LDA is INTEGER
                     86: *>          The leading dimension of the array A.  LDA >= max(1,N).
                     87: *> \endverbatim
                     88: *>
                     89: *> \param[out] IPIV
                     90: *> \verbatim
                     91: *>          IPIV is INTEGER array, dimension (N)
                     92: *>          Details of the interchanges and the block structure of D.
1.14      bertrand   93: *>
                     94: *>          If UPLO = 'U':
                     95: *>             If IPIV(k) > 0, then rows and columns k and IPIV(k) were
                     96: *>             interchanged and D(k,k) is a 1-by-1 diagonal block.
                     97: *>
                     98: *>             If IPIV(k) = IPIV(k-1) < 0, then rows and columns
                     99: *>             k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
                    100: *>             is a 2-by-2 diagonal block.
                    101: *>
                    102: *>          If UPLO = 'L':
                    103: *>             If IPIV(k) > 0, then rows and columns k and IPIV(k) were
                    104: *>             interchanged and D(k,k) is a 1-by-1 diagonal block.
                    105: *>
                    106: *>             If IPIV(k) = IPIV(k+1) < 0, then rows and columns
                    107: *>             k+1 and -IPIV(k) were interchanged and D(k:k+1,k:k+1)
                    108: *>             is a 2-by-2 diagonal block.
1.9       bertrand  109: *> \endverbatim
                    110: *>
                    111: *> \param[out] INFO
                    112: *> \verbatim
                    113: *>          INFO is INTEGER
                    114: *>          = 0: successful exit
                    115: *>          < 0: if INFO = -k, the k-th argument had an illegal value
                    116: *>          > 0: if INFO = k, D(k,k) is exactly zero.  The factorization
                    117: *>               has been completed, but the block diagonal matrix D is
                    118: *>               exactly singular, and division by zero will occur if it
                    119: *>               is used to solve a system of equations.
                    120: *> \endverbatim
                    121: *
                    122: *  Authors:
                    123: *  ========
                    124: *
1.17      bertrand  125: *> \author Univ. of Tennessee
                    126: *> \author Univ. of California Berkeley
                    127: *> \author Univ. of Colorado Denver
                    128: *> \author NAG Ltd.
1.9       bertrand  129: *
                    130: *> \ingroup doubleSYcomputational
                    131: *
                    132: *> \par Further Details:
                    133: *  =====================
                    134: *>
                    135: *> \verbatim
                    136: *>
                    137: *>  If UPLO = 'U', then A = U*D*U**T, where
                    138: *>     U = P(n)*U(n)* ... *P(k)U(k)* ...,
                    139: *>  i.e., U is a product of terms P(k)*U(k), where k decreases from n to
                    140: *>  1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
                    141: *>  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
                    142: *>  defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
                    143: *>  that if the diagonal block D(k) is of order s (s = 1 or 2), then
                    144: *>
                    145: *>             (   I    v    0   )   k-s
                    146: *>     U(k) =  (   0    I    0   )   s
                    147: *>             (   0    0    I   )   n-k
                    148: *>                k-s   s   n-k
                    149: *>
                    150: *>  If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
                    151: *>  If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
                    152: *>  and A(k,k), and v overwrites A(1:k-2,k-1:k).
                    153: *>
                    154: *>  If UPLO = 'L', then A = L*D*L**T, where
                    155: *>     L = P(1)*L(1)* ... *P(k)*L(k)* ...,
                    156: *>  i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
                    157: *>  n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
                    158: *>  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
                    159: *>  defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
                    160: *>  that if the diagonal block D(k) is of order s (s = 1 or 2), then
                    161: *>
                    162: *>             (   I    0     0   )  k-1
                    163: *>     L(k) =  (   0    I     0   )  s
                    164: *>             (   0    v     I   )  n-k-s+1
                    165: *>                k-1   s  n-k-s+1
                    166: *>
                    167: *>  If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
                    168: *>  If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
                    169: *>  and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
                    170: *> \endverbatim
                    171: *
                    172: *> \par Contributors:
                    173: *  ==================
                    174: *>
                    175: *> \verbatim
                    176: *>
                    177: *>  09-29-06 - patch from
                    178: *>    Bobby Cheng, MathWorks
                    179: *>
                    180: *>    Replace l.204 and l.372
                    181: *>         IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
                    182: *>    by
                    183: *>         IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. DISNAN(ABSAKK) ) THEN
                    184: *>
                    185: *>  01-01-96 - Based on modifications by
                    186: *>    J. Lewis, Boeing Computer Services Company
                    187: *>    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
                    188: *>  1-96 - Based on modifications by J. Lewis, Boeing Computer Services
                    189: *>         Company
                    190: *> \endverbatim
                    191: *
                    192: *  =====================================================================
1.1       bertrand  193:       SUBROUTINE DSYTF2( UPLO, N, A, LDA, IPIV, INFO )
                    194: *
1.20    ! bertrand  195: *  -- LAPACK computational routine --
1.1       bertrand  196: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
                    197: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
                    198: *
                    199: *     .. Scalar Arguments ..
                    200:       CHARACTER          UPLO
                    201:       INTEGER            INFO, LDA, N
                    202: *     ..
                    203: *     .. Array Arguments ..
                    204:       INTEGER            IPIV( * )
                    205:       DOUBLE PRECISION   A( LDA, * )
                    206: *     ..
                    207: *
                    208: *  =====================================================================
                    209: *
                    210: *     .. Parameters ..
                    211:       DOUBLE PRECISION   ZERO, ONE
                    212:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
                    213:       DOUBLE PRECISION   EIGHT, SEVTEN
                    214:       PARAMETER          ( EIGHT = 8.0D+0, SEVTEN = 17.0D+0 )
                    215: *     ..
                    216: *     .. Local Scalars ..
                    217:       LOGICAL            UPPER
                    218:       INTEGER            I, IMAX, J, JMAX, K, KK, KP, KSTEP
                    219:       DOUBLE PRECISION   ABSAKK, ALPHA, COLMAX, D11, D12, D21, D22, R1,
                    220:      $                   ROWMAX, T, WK, WKM1, WKP1
                    221: *     ..
                    222: *     .. External Functions ..
                    223:       LOGICAL            LSAME, DISNAN
                    224:       INTEGER            IDAMAX
                    225:       EXTERNAL           LSAME, IDAMAX, DISNAN
                    226: *     ..
                    227: *     .. External Subroutines ..
                    228:       EXTERNAL           DSCAL, DSWAP, DSYR, XERBLA
                    229: *     ..
                    230: *     .. Intrinsic Functions ..
                    231:       INTRINSIC          ABS, MAX, SQRT
                    232: *     ..
                    233: *     .. Executable Statements ..
                    234: *
                    235: *     Test the input parameters.
                    236: *
                    237:       INFO = 0
                    238:       UPPER = LSAME( UPLO, 'U' )
                    239:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
                    240:          INFO = -1
                    241:       ELSE IF( N.LT.0 ) THEN
                    242:          INFO = -2
                    243:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
                    244:          INFO = -4
                    245:       END IF
                    246:       IF( INFO.NE.0 ) THEN
                    247:          CALL XERBLA( 'DSYTF2', -INFO )
                    248:          RETURN
                    249:       END IF
                    250: *
                    251: *     Initialize ALPHA for use in choosing pivot block size.
                    252: *
                    253:       ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT
                    254: *
                    255:       IF( UPPER ) THEN
                    256: *
1.8       bertrand  257: *        Factorize A as U*D*U**T using the upper triangle of A
1.1       bertrand  258: *
                    259: *        K is the main loop index, decreasing from N to 1 in steps of
                    260: *        1 or 2
                    261: *
                    262:          K = N
                    263:    10    CONTINUE
                    264: *
                    265: *        If K < 1, exit from loop
                    266: *
                    267:          IF( K.LT.1 )
                    268:      $      GO TO 70
                    269:          KSTEP = 1
                    270: *
                    271: *        Determine rows and columns to be interchanged and whether
                    272: *        a 1-by-1 or 2-by-2 pivot block will be used
                    273: *
                    274:          ABSAKK = ABS( A( K, K ) )
                    275: *
                    276: *        IMAX is the row-index of the largest off-diagonal element in
1.14      bertrand  277: *        column K, and COLMAX is its absolute value.
                    278: *        Determine both COLMAX and IMAX.
1.1       bertrand  279: *
                    280:          IF( K.GT.1 ) THEN
                    281:             IMAX = IDAMAX( K-1, A( 1, K ), 1 )
                    282:             COLMAX = ABS( A( IMAX, K ) )
                    283:          ELSE
                    284:             COLMAX = ZERO
                    285:          END IF
                    286: *
                    287:          IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. DISNAN(ABSAKK) ) THEN
                    288: *
1.14      bertrand  289: *           Column K is zero or underflow, or contains a NaN:
                    290: *           set INFO and continue
1.1       bertrand  291: *
                    292:             IF( INFO.EQ.0 )
                    293:      $         INFO = K
                    294:             KP = K
                    295:          ELSE
                    296:             IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
                    297: *
                    298: *              no interchange, use 1-by-1 pivot block
                    299: *
                    300:                KP = K
                    301:             ELSE
                    302: *
                    303: *              JMAX is the column-index of the largest off-diagonal
                    304: *              element in row IMAX, and ROWMAX is its absolute value
                    305: *
                    306:                JMAX = IMAX + IDAMAX( K-IMAX, A( IMAX, IMAX+1 ), LDA )
                    307:                ROWMAX = ABS( A( IMAX, JMAX ) )
                    308:                IF( IMAX.GT.1 ) THEN
                    309:                   JMAX = IDAMAX( IMAX-1, A( 1, IMAX ), 1 )
                    310:                   ROWMAX = MAX( ROWMAX, ABS( A( JMAX, IMAX ) ) )
                    311:                END IF
                    312: *
                    313:                IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
                    314: *
                    315: *                 no interchange, use 1-by-1 pivot block
                    316: *
                    317:                   KP = K
                    318:                ELSE IF( ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN
                    319: *
                    320: *                 interchange rows and columns K and IMAX, use 1-by-1
                    321: *                 pivot block
                    322: *
                    323:                   KP = IMAX
                    324:                ELSE
                    325: *
                    326: *                 interchange rows and columns K-1 and IMAX, use 2-by-2
                    327: *                 pivot block
                    328: *
                    329:                   KP = IMAX
                    330:                   KSTEP = 2
                    331:                END IF
                    332:             END IF
                    333: *
                    334:             KK = K - KSTEP + 1
                    335:             IF( KP.NE.KK ) THEN
                    336: *
                    337: *              Interchange rows and columns KK and KP in the leading
                    338: *              submatrix A(1:k,1:k)
                    339: *
                    340:                CALL DSWAP( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 )
                    341:                CALL DSWAP( KK-KP-1, A( KP+1, KK ), 1, A( KP, KP+1 ),
                    342:      $                     LDA )
                    343:                T = A( KK, KK )
                    344:                A( KK, KK ) = A( KP, KP )
                    345:                A( KP, KP ) = T
                    346:                IF( KSTEP.EQ.2 ) THEN
                    347:                   T = A( K-1, K )
                    348:                   A( K-1, K ) = A( KP, K )
                    349:                   A( KP, K ) = T
                    350:                END IF
                    351:             END IF
                    352: *
                    353: *           Update the leading submatrix
                    354: *
                    355:             IF( KSTEP.EQ.1 ) THEN
                    356: *
                    357: *              1-by-1 pivot block D(k): column k now holds
                    358: *
                    359: *              W(k) = U(k)*D(k)
                    360: *
                    361: *              where U(k) is the k-th column of U
                    362: *
                    363: *              Perform a rank-1 update of A(1:k-1,1:k-1) as
                    364: *
1.8       bertrand  365: *              A := A - U(k)*D(k)*U(k)**T = A - W(k)*1/D(k)*W(k)**T
1.1       bertrand  366: *
                    367:                R1 = ONE / A( K, K )
                    368:                CALL DSYR( UPLO, K-1, -R1, A( 1, K ), 1, A, LDA )
                    369: *
                    370: *              Store U(k) in column k
                    371: *
                    372:                CALL DSCAL( K-1, R1, A( 1, K ), 1 )
                    373:             ELSE
                    374: *
                    375: *              2-by-2 pivot block D(k): columns k and k-1 now hold
                    376: *
                    377: *              ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
                    378: *
                    379: *              where U(k) and U(k-1) are the k-th and (k-1)-th columns
                    380: *              of U
                    381: *
                    382: *              Perform a rank-2 update of A(1:k-2,1:k-2) as
                    383: *
1.8       bertrand  384: *              A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**T
                    385: *                 = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**T
1.1       bertrand  386: *
                    387:                IF( K.GT.2 ) THEN
                    388: *
                    389:                   D12 = A( K-1, K )
                    390:                   D22 = A( K-1, K-1 ) / D12
                    391:                   D11 = A( K, K ) / D12
                    392:                   T = ONE / ( D11*D22-ONE )
                    393:                   D12 = T / D12
                    394: *
                    395:                   DO 30 J = K - 2, 1, -1
                    396:                      WKM1 = D12*( D11*A( J, K-1 )-A( J, K ) )
                    397:                      WK = D12*( D22*A( J, K )-A( J, K-1 ) )
                    398:                      DO 20 I = J, 1, -1
                    399:                         A( I, J ) = A( I, J ) - A( I, K )*WK -
                    400:      $                              A( I, K-1 )*WKM1
                    401:    20                CONTINUE
                    402:                      A( J, K ) = WK
                    403:                      A( J, K-1 ) = WKM1
                    404:    30             CONTINUE
                    405: *
                    406:                END IF
                    407: *
                    408:             END IF
                    409:          END IF
                    410: *
                    411: *        Store details of the interchanges in IPIV
                    412: *
                    413:          IF( KSTEP.EQ.1 ) THEN
                    414:             IPIV( K ) = KP
                    415:          ELSE
                    416:             IPIV( K ) = -KP
                    417:             IPIV( K-1 ) = -KP
                    418:          END IF
                    419: *
                    420: *        Decrease K and return to the start of the main loop
                    421: *
                    422:          K = K - KSTEP
                    423:          GO TO 10
                    424: *
                    425:       ELSE
                    426: *
1.8       bertrand  427: *        Factorize A as L*D*L**T using the lower triangle of A
1.1       bertrand  428: *
                    429: *        K is the main loop index, increasing from 1 to N in steps of
                    430: *        1 or 2
                    431: *
                    432:          K = 1
                    433:    40    CONTINUE
                    434: *
                    435: *        If K > N, exit from loop
                    436: *
                    437:          IF( K.GT.N )
                    438:      $      GO TO 70
                    439:          KSTEP = 1
                    440: *
                    441: *        Determine rows and columns to be interchanged and whether
                    442: *        a 1-by-1 or 2-by-2 pivot block will be used
                    443: *
                    444:          ABSAKK = ABS( A( K, K ) )
                    445: *
                    446: *        IMAX is the row-index of the largest off-diagonal element in
1.14      bertrand  447: *        column K, and COLMAX is its absolute value.
                    448: *        Determine both COLMAX and IMAX.
1.1       bertrand  449: *
                    450:          IF( K.LT.N ) THEN
                    451:             IMAX = K + IDAMAX( N-K, A( K+1, K ), 1 )
                    452:             COLMAX = ABS( A( IMAX, K ) )
                    453:          ELSE
                    454:             COLMAX = ZERO
                    455:          END IF
                    456: *
                    457:          IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. DISNAN(ABSAKK) ) THEN
                    458: *
1.14      bertrand  459: *           Column K is zero or underflow, or contains a NaN:
                    460: *           set INFO and continue
1.1       bertrand  461: *
                    462:             IF( INFO.EQ.0 )
                    463:      $         INFO = K
                    464:             KP = K
                    465:          ELSE
                    466:             IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
                    467: *
                    468: *              no interchange, use 1-by-1 pivot block
                    469: *
                    470:                KP = K
                    471:             ELSE
                    472: *
                    473: *              JMAX is the column-index of the largest off-diagonal
                    474: *              element in row IMAX, and ROWMAX is its absolute value
                    475: *
                    476:                JMAX = K - 1 + IDAMAX( IMAX-K, A( IMAX, K ), LDA )
                    477:                ROWMAX = ABS( A( IMAX, JMAX ) )
                    478:                IF( IMAX.LT.N ) THEN
                    479:                   JMAX = IMAX + IDAMAX( N-IMAX, A( IMAX+1, IMAX ), 1 )
                    480:                   ROWMAX = MAX( ROWMAX, ABS( A( JMAX, IMAX ) ) )
                    481:                END IF
                    482: *
                    483:                IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
                    484: *
                    485: *                 no interchange, use 1-by-1 pivot block
                    486: *
                    487:                   KP = K
                    488:                ELSE IF( ABS( A( IMAX, IMAX ) ).GE.ALPHA*ROWMAX ) THEN
                    489: *
                    490: *                 interchange rows and columns K and IMAX, use 1-by-1
                    491: *                 pivot block
                    492: *
                    493:                   KP = IMAX
                    494:                ELSE
                    495: *
                    496: *                 interchange rows and columns K+1 and IMAX, use 2-by-2
                    497: *                 pivot block
                    498: *
                    499:                   KP = IMAX
                    500:                   KSTEP = 2
                    501:                END IF
                    502:             END IF
                    503: *
                    504:             KK = K + KSTEP - 1
                    505:             IF( KP.NE.KK ) THEN
                    506: *
                    507: *              Interchange rows and columns KK and KP in the trailing
                    508: *              submatrix A(k:n,k:n)
                    509: *
                    510:                IF( KP.LT.N )
                    511:      $            CALL DSWAP( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )
                    512:                CALL DSWAP( KP-KK-1, A( KK+1, KK ), 1, A( KP, KK+1 ),
                    513:      $                     LDA )
                    514:                T = A( KK, KK )
                    515:                A( KK, KK ) = A( KP, KP )
                    516:                A( KP, KP ) = T
                    517:                IF( KSTEP.EQ.2 ) THEN
                    518:                   T = A( K+1, K )
                    519:                   A( K+1, K ) = A( KP, K )
                    520:                   A( KP, K ) = T
                    521:                END IF
                    522:             END IF
                    523: *
                    524: *           Update the trailing submatrix
                    525: *
                    526:             IF( KSTEP.EQ.1 ) THEN
                    527: *
                    528: *              1-by-1 pivot block D(k): column k now holds
                    529: *
                    530: *              W(k) = L(k)*D(k)
                    531: *
                    532: *              where L(k) is the k-th column of L
                    533: *
                    534:                IF( K.LT.N ) THEN
                    535: *
                    536: *                 Perform a rank-1 update of A(k+1:n,k+1:n) as
                    537: *
1.8       bertrand  538: *                 A := A - L(k)*D(k)*L(k)**T = A - W(k)*(1/D(k))*W(k)**T
1.1       bertrand  539: *
                    540:                   D11 = ONE / A( K, K )
                    541:                   CALL DSYR( UPLO, N-K, -D11, A( K+1, K ), 1,
                    542:      $                       A( K+1, K+1 ), LDA )
                    543: *
                    544: *                 Store L(k) in column K
                    545: *
                    546:                   CALL DSCAL( N-K, D11, A( K+1, K ), 1 )
                    547:                END IF
                    548:             ELSE
                    549: *
                    550: *              2-by-2 pivot block D(k)
                    551: *
                    552:                IF( K.LT.N-1 ) THEN
                    553: *
                    554: *                 Perform a rank-2 update of A(k+2:n,k+2:n) as
                    555: *
1.8       bertrand  556: *                 A := A - ( (A(k) A(k+1))*D(k)**(-1) ) * (A(k) A(k+1))**T
1.1       bertrand  557: *
                    558: *                 where L(k) and L(k+1) are the k-th and (k+1)-th
                    559: *                 columns of L
                    560: *
                    561:                   D21 = A( K+1, K )
                    562:                   D11 = A( K+1, K+1 ) / D21
                    563:                   D22 = A( K, K ) / D21
                    564:                   T = ONE / ( D11*D22-ONE )
                    565:                   D21 = T / D21
                    566: *
                    567:                   DO 60 J = K + 2, N
                    568: *
                    569:                      WK = D21*( D11*A( J, K )-A( J, K+1 ) )
                    570:                      WKP1 = D21*( D22*A( J, K+1 )-A( J, K ) )
                    571: *
                    572:                      DO 50 I = J, N
                    573:                         A( I, J ) = A( I, J ) - A( I, K )*WK -
                    574:      $                              A( I, K+1 )*WKP1
                    575:    50                CONTINUE
                    576: *
                    577:                      A( J, K ) = WK
                    578:                      A( J, K+1 ) = WKP1
                    579: *
                    580:    60             CONTINUE
                    581:                END IF
                    582:             END IF
                    583:          END IF
                    584: *
                    585: *        Store details of the interchanges in IPIV
                    586: *
                    587:          IF( KSTEP.EQ.1 ) THEN
                    588:             IPIV( K ) = KP
                    589:          ELSE
                    590:             IPIV( K ) = -KP
                    591:             IPIV( K+1 ) = -KP
                    592:          END IF
                    593: *
                    594: *        Increase K and return to the start of the main loop
                    595: *
                    596:          K = K + KSTEP
                    597:          GO TO 40
                    598: *
                    599:       END IF
                    600: *
                    601:    70 CONTINUE
                    602: *
                    603:       RETURN
                    604: *
                    605: *     End of DSYTF2
                    606: *
                    607:       END

CVSweb interface <joel.bertrand@systella.fr>