LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
chetf2.f
Go to the documentation of this file.
00001 *> \brief \b CHETF2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CHETF2 + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chetf2.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chetf2.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chetf2.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CHETF2( UPLO, N, A, LDA, IPIV, INFO )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          UPLO
00025 *       INTEGER            INFO, LDA, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       INTEGER            IPIV( * )
00029 *       COMPLEX            A( LDA, * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> CHETF2 computes the factorization of a complex Hermitian matrix A
00039 *> using the Bunch-Kaufman diagonal pivoting method:
00040 *>
00041 *>    A = U*D*U**H  or  A = L*D*L**H
00042 *>
00043 *> where U (or L) is a product of permutation and unit upper (lower)
00044 *> triangular matrices, U**H is the conjugate transpose of U, and D is
00045 *> Hermitian and block diagonal with 1-by-1 and 2-by-2 diagonal blocks.
00046 *>
00047 *> This is the unblocked version of the algorithm, calling Level 2 BLAS.
00048 *> \endverbatim
00049 *
00050 *  Arguments:
00051 *  ==========
00052 *
00053 *> \param[in] UPLO
00054 *> \verbatim
00055 *>          UPLO is CHARACTER*1
00056 *>          Specifies whether the upper or lower triangular part of the
00057 *>          Hermitian matrix A is stored:
00058 *>          = 'U':  Upper triangular
00059 *>          = 'L':  Lower triangular
00060 *> \endverbatim
00061 *>
00062 *> \param[in] N
00063 *> \verbatim
00064 *>          N is INTEGER
00065 *>          The order of the matrix A.  N >= 0.
00066 *> \endverbatim
00067 *>
00068 *> \param[in,out] A
00069 *> \verbatim
00070 *>          A is COMPLEX array, dimension (LDA,N)
00071 *>          On entry, the Hermitian matrix A.  If UPLO = 'U', the leading
00072 *>          n-by-n upper triangular part of A contains the upper
00073 *>          triangular part of the matrix A, and the strictly lower
00074 *>          triangular part of A is not referenced.  If UPLO = 'L', the
00075 *>          leading n-by-n lower triangular part of A contains the lower
00076 *>          triangular part of the matrix A, and the strictly upper
00077 *>          triangular part of A is not referenced.
00078 *>
00079 *>          On exit, the block diagonal matrix D and the multipliers used
00080 *>          to obtain the factor U or L (see below for further details).
00081 *> \endverbatim
00082 *>
00083 *> \param[in] LDA
00084 *> \verbatim
00085 *>          LDA is INTEGER
00086 *>          The leading dimension of the array A.  LDA >= max(1,N).
00087 *> \endverbatim
00088 *>
00089 *> \param[out] IPIV
00090 *> \verbatim
00091 *>          IPIV is INTEGER array, dimension (N)
00092 *>          Details of the interchanges and the block structure of D.
00093 *>          If IPIV(k) > 0, then rows and columns k and IPIV(k) were
00094 *>          interchanged and D(k,k) is a 1-by-1 diagonal block.
00095 *>          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
00096 *>          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
00097 *>          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) =
00098 *>          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
00099 *>          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
00100 *> \endverbatim
00101 *>
00102 *> \param[out] INFO
00103 *> \verbatim
00104 *>          INFO is INTEGER
00105 *>          = 0: successful exit
00106 *>          < 0: if INFO = -k, the k-th argument had an illegal value
00107 *>          > 0: if INFO = k, D(k,k) is exactly zero.  The factorization
00108 *>               has been completed, but the block diagonal matrix D is
00109 *>               exactly singular, and division by zero will occur if it
00110 *>               is used to solve a system of equations.
00111 *> \endverbatim
00112 *
00113 *  Authors:
00114 *  ========
00115 *
00116 *> \author Univ. of Tennessee 
00117 *> \author Univ. of California Berkeley 
00118 *> \author Univ. of Colorado Denver 
00119 *> \author NAG Ltd. 
00120 *
00121 *> \date November 2011
00122 *
00123 *> \ingroup complexHEcomputational
00124 *
00125 *> \par Further Details:
00126 *  =====================
00127 *>
00128 *> \verbatim
00129 *>
00130 *>  09-29-06 - patch from
00131 *>    Bobby Cheng, MathWorks
00132 *>
00133 *>    Replace l.210 and l.392
00134 *>         IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
00135 *>    by
00136 *>         IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
00137 *>
00138 *>  01-01-96 - Based on modifications by
00139 *>    J. Lewis, Boeing Computer Services Company
00140 *>    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
00141 *>
00142 *>  If UPLO = 'U', then A = U*D*U**H, where
00143 *>     U = P(n)*U(n)* ... *P(k)U(k)* ...,
00144 *>  i.e., U is a product of terms P(k)*U(k), where k decreases from n to
00145 *>  1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
00146 *>  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
00147 *>  defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
00148 *>  that if the diagonal block D(k) is of order s (s = 1 or 2), then
00149 *>
00150 *>             (   I    v    0   )   k-s
00151 *>     U(k) =  (   0    I    0   )   s
00152 *>             (   0    0    I   )   n-k
00153 *>                k-s   s   n-k
00154 *>
00155 *>  If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
00156 *>  If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
00157 *>  and A(k,k), and v overwrites A(1:k-2,k-1:k).
00158 *>
00159 *>  If UPLO = 'L', then A = L*D*L**H, where
00160 *>     L = P(1)*L(1)* ... *P(k)*L(k)* ...,
00161 *>  i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
00162 *>  n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
00163 *>  and 2-by-2 diagonal blocks D(k).  P(k) is a permutation matrix as
00164 *>  defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
00165 *>  that if the diagonal block D(k) is of order s (s = 1 or 2), then
00166 *>
00167 *>             (   I    0     0   )  k-1
00168 *>     L(k) =  (   0    I     0   )  s
00169 *>             (   0    v     I   )  n-k-s+1
00170 *>                k-1   s  n-k-s+1
00171 *>
00172 *>  If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
00173 *>  If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
00174 *>  and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
00175 *> \endverbatim
00176 *>
00177 *  =====================================================================
00178       SUBROUTINE CHETF2( UPLO, N, A, LDA, IPIV, INFO )
00179 *
00180 *  -- LAPACK computational routine (version 3.4.0) --
00181 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00182 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00183 *     November 2011
00184 *
00185 *     .. Scalar Arguments ..
00186       CHARACTER          UPLO
00187       INTEGER            INFO, LDA, N
00188 *     ..
00189 *     .. Array Arguments ..
00190       INTEGER            IPIV( * )
00191       COMPLEX            A( LDA, * )
00192 *     ..
00193 *
00194 *  =====================================================================
00195 *
00196 *     .. Parameters ..
00197       REAL               ZERO, ONE
00198       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00199       REAL               EIGHT, SEVTEN
00200       PARAMETER          ( EIGHT = 8.0E+0, SEVTEN = 17.0E+0 )
00201 *     ..
00202 *     .. Local Scalars ..
00203       LOGICAL            UPPER
00204       INTEGER            I, IMAX, J, JMAX, K, KK, KP, KSTEP
00205       REAL               ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
00206      $                   TT
00207       COMPLEX            D12, D21, T, WK, WKM1, WKP1, ZDUM
00208 *     ..
00209 *     .. External Functions ..
00210       LOGICAL            LSAME, SISNAN
00211       INTEGER            ICAMAX
00212       REAL               SLAPY2
00213       EXTERNAL           LSAME, ICAMAX, SLAPY2, SISNAN
00214 *     ..
00215 *     .. External Subroutines ..
00216       EXTERNAL           CHER, CSSCAL, CSWAP, XERBLA
00217 *     ..
00218 *     .. Intrinsic Functions ..
00219       INTRINSIC          ABS, AIMAG, CMPLX, CONJG, MAX, REAL, SQRT
00220 *     ..
00221 *     .. Statement Functions ..
00222       REAL               CABS1
00223 *     ..
00224 *     .. Statement Function definitions ..
00225       CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
00226 *     ..
00227 *     .. Executable Statements ..
00228 *
00229 *     Test the input parameters.
00230 *
00231       INFO = 0
00232       UPPER = LSAME( UPLO, 'U' )
00233       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00234          INFO = -1
00235       ELSE IF( N.LT.0 ) THEN
00236          INFO = -2
00237       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00238          INFO = -4
00239       END IF
00240       IF( INFO.NE.0 ) THEN
00241          CALL XERBLA( 'CHETF2', -INFO )
00242          RETURN
00243       END IF
00244 *
00245 *     Initialize ALPHA for use in choosing pivot block size.
00246 *
00247       ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT
00248 *
00249       IF( UPPER ) THEN
00250 *
00251 *        Factorize A as U*D*U**H using the upper triangle of A
00252 *
00253 *        K is the main loop index, decreasing from N to 1 in steps of
00254 *        1 or 2
00255 *
00256          K = N
00257    10    CONTINUE
00258 *
00259 *        If K < 1, exit from loop
00260 *
00261          IF( K.LT.1 )
00262      $      GO TO 90
00263          KSTEP = 1
00264 *
00265 *        Determine rows and columns to be interchanged and whether
00266 *        a 1-by-1 or 2-by-2 pivot block will be used
00267 *
00268          ABSAKK = ABS( REAL( A( K, K ) ) )
00269 *
00270 *        IMAX is the row-index of the largest off-diagonal element in
00271 *        column K, and COLMAX is its absolute value
00272 *
00273          IF( K.GT.1 ) THEN
00274             IMAX = ICAMAX( K-1, A( 1, K ), 1 )
00275             COLMAX = CABS1( A( IMAX, K ) )
00276          ELSE
00277             COLMAX = ZERO
00278          END IF
00279 *
00280          IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
00281 *
00282 *           Column K is zero or contains a NaN: set INFO and continue
00283 *
00284             IF( INFO.EQ.0 )
00285      $         INFO = K
00286             KP = K
00287             A( K, K ) = REAL( A( K, K ) )
00288          ELSE
00289             IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
00290 *
00291 *              no interchange, use 1-by-1 pivot block
00292 *
00293                KP = K
00294             ELSE
00295 *
00296 *              JMAX is the column-index of the largest off-diagonal
00297 *              element in row IMAX, and ROWMAX is its absolute value
00298 *
00299                JMAX = IMAX + ICAMAX( K-IMAX, A( IMAX, IMAX+1 ), LDA )
00300                ROWMAX = CABS1( A( IMAX, JMAX ) )
00301                IF( IMAX.GT.1 ) THEN
00302                   JMAX = ICAMAX( IMAX-1, A( 1, IMAX ), 1 )
00303                   ROWMAX = MAX( ROWMAX, CABS1( A( JMAX, IMAX ) ) )
00304                END IF
00305 *
00306                IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
00307 *
00308 *                 no interchange, use 1-by-1 pivot block
00309 *
00310                   KP = K
00311                ELSE IF( ABS( REAL( A( IMAX, IMAX ) ) ).GE.ALPHA*ROWMAX )
00312      $                   THEN
00313 *
00314 *                 interchange rows and columns K and IMAX, use 1-by-1
00315 *                 pivot block
00316 *
00317                   KP = IMAX
00318                ELSE
00319 *
00320 *                 interchange rows and columns K-1 and IMAX, use 2-by-2
00321 *                 pivot block
00322 *
00323                   KP = IMAX
00324                   KSTEP = 2
00325                END IF
00326             END IF
00327 *
00328             KK = K - KSTEP + 1
00329             IF( KP.NE.KK ) THEN
00330 *
00331 *              Interchange rows and columns KK and KP in the leading
00332 *              submatrix A(1:k,1:k)
00333 *
00334                CALL CSWAP( KP-1, A( 1, KK ), 1, A( 1, KP ), 1 )
00335                DO 20 J = KP + 1, KK - 1
00336                   T = CONJG( A( J, KK ) )
00337                   A( J, KK ) = CONJG( A( KP, J ) )
00338                   A( KP, J ) = T
00339    20          CONTINUE
00340                A( KP, KK ) = CONJG( A( KP, KK ) )
00341                R1 = REAL( A( KK, KK ) )
00342                A( KK, KK ) = REAL( A( KP, KP ) )
00343                A( KP, KP ) = R1
00344                IF( KSTEP.EQ.2 ) THEN
00345                   A( K, K ) = REAL( A( K, K ) )
00346                   T = A( K-1, K )
00347                   A( K-1, K ) = A( KP, K )
00348                   A( KP, K ) = T
00349                END IF
00350             ELSE
00351                A( K, K ) = REAL( A( K, K ) )
00352                IF( KSTEP.EQ.2 )
00353      $            A( K-1, K-1 ) = REAL( A( K-1, K-1 ) )
00354             END IF
00355 *
00356 *           Update the leading submatrix
00357 *
00358             IF( KSTEP.EQ.1 ) THEN
00359 *
00360 *              1-by-1 pivot block D(k): column k now holds
00361 *
00362 *              W(k) = U(k)*D(k)
00363 *
00364 *              where U(k) is the k-th column of U
00365 *
00366 *              Perform a rank-1 update of A(1:k-1,1:k-1) as
00367 *
00368 *              A := A - U(k)*D(k)*U(k)**H = A - W(k)*1/D(k)*W(k)**H
00369 *
00370                R1 = ONE / REAL( A( K, K ) )
00371                CALL CHER( UPLO, K-1, -R1, A( 1, K ), 1, A, LDA )
00372 *
00373 *              Store U(k) in column k
00374 *
00375                CALL CSSCAL( K-1, R1, A( 1, K ), 1 )
00376             ELSE
00377 *
00378 *              2-by-2 pivot block D(k): columns k and k-1 now hold
00379 *
00380 *              ( W(k-1) W(k) ) = ( U(k-1) U(k) )*D(k)
00381 *
00382 *              where U(k) and U(k-1) are the k-th and (k-1)-th columns
00383 *              of U
00384 *
00385 *              Perform a rank-2 update of A(1:k-2,1:k-2) as
00386 *
00387 *              A := A - ( U(k-1) U(k) )*D(k)*( U(k-1) U(k) )**H
00388 *                 = A - ( W(k-1) W(k) )*inv(D(k))*( W(k-1) W(k) )**H
00389 *
00390                IF( K.GT.2 ) THEN
00391 *
00392                   D = SLAPY2( REAL( A( K-1, K ) ),
00393      $                AIMAG( A( K-1, K ) ) )
00394                   D22 = REAL( A( K-1, K-1 ) ) / D
00395                   D11 = REAL( A( K, K ) ) / D
00396                   TT = ONE / ( D11*D22-ONE )
00397                   D12 = A( K-1, K ) / D
00398                   D = TT / D
00399 *
00400                   DO 40 J = K - 2, 1, -1
00401                      WKM1 = D*( D11*A( J, K-1 )-CONJG( D12 )*A( J, K ) )
00402                      WK = D*( D22*A( J, K )-D12*A( J, K-1 ) )
00403                      DO 30 I = J, 1, -1
00404                         A( I, J ) = A( I, J ) - A( I, K )*CONJG( WK ) -
00405      $                              A( I, K-1 )*CONJG( WKM1 )
00406    30                CONTINUE
00407                      A( J, K ) = WK
00408                      A( J, K-1 ) = WKM1
00409                      A( J, J ) = CMPLX( REAL( A( J, J ) ), 0.0E+0 )
00410    40             CONTINUE
00411 *
00412                END IF
00413 *
00414             END IF
00415          END IF
00416 *
00417 *        Store details of the interchanges in IPIV
00418 *
00419          IF( KSTEP.EQ.1 ) THEN
00420             IPIV( K ) = KP
00421          ELSE
00422             IPIV( K ) = -KP
00423             IPIV( K-1 ) = -KP
00424          END IF
00425 *
00426 *        Decrease K and return to the start of the main loop
00427 *
00428          K = K - KSTEP
00429          GO TO 10
00430 *
00431       ELSE
00432 *
00433 *        Factorize A as L*D*L**H using the lower triangle of A
00434 *
00435 *        K is the main loop index, increasing from 1 to N in steps of
00436 *        1 or 2
00437 *
00438          K = 1
00439    50    CONTINUE
00440 *
00441 *        If K > N, exit from loop
00442 *
00443          IF( K.GT.N )
00444      $      GO TO 90
00445          KSTEP = 1
00446 *
00447 *        Determine rows and columns to be interchanged and whether
00448 *        a 1-by-1 or 2-by-2 pivot block will be used
00449 *
00450          ABSAKK = ABS( REAL( A( K, K ) ) )
00451 *
00452 *        IMAX is the row-index of the largest off-diagonal element in
00453 *        column K, and COLMAX is its absolute value
00454 *
00455          IF( K.LT.N ) THEN
00456             IMAX = K + ICAMAX( N-K, A( K+1, K ), 1 )
00457             COLMAX = CABS1( A( IMAX, K ) )
00458          ELSE
00459             COLMAX = ZERO
00460          END IF
00461 *
00462          IF( (MAX( ABSAKK, COLMAX ).EQ.ZERO) .OR. SISNAN(ABSAKK) ) THEN
00463 *
00464 *           Column K is zero or contains a NaN: set INFO and continue
00465 *
00466             IF( INFO.EQ.0 )
00467      $         INFO = K
00468             KP = K
00469             A( K, K ) = REAL( A( K, K ) )
00470          ELSE
00471             IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
00472 *
00473 *              no interchange, use 1-by-1 pivot block
00474 *
00475                KP = K
00476             ELSE
00477 *
00478 *              JMAX is the column-index of the largest off-diagonal
00479 *              element in row IMAX, and ROWMAX is its absolute value
00480 *
00481                JMAX = K - 1 + ICAMAX( IMAX-K, A( IMAX, K ), LDA )
00482                ROWMAX = CABS1( A( IMAX, JMAX ) )
00483                IF( IMAX.LT.N ) THEN
00484                   JMAX = IMAX + ICAMAX( N-IMAX, A( IMAX+1, IMAX ), 1 )
00485                   ROWMAX = MAX( ROWMAX, CABS1( A( JMAX, IMAX ) ) )
00486                END IF
00487 *
00488                IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
00489 *
00490 *                 no interchange, use 1-by-1 pivot block
00491 *
00492                   KP = K
00493                ELSE IF( ABS( REAL( A( IMAX, IMAX ) ) ).GE.ALPHA*ROWMAX )
00494      $                   THEN
00495 *
00496 *                 interchange rows and columns K and IMAX, use 1-by-1
00497 *                 pivot block
00498 *
00499                   KP = IMAX
00500                ELSE
00501 *
00502 *                 interchange rows and columns K+1 and IMAX, use 2-by-2
00503 *                 pivot block
00504 *
00505                   KP = IMAX
00506                   KSTEP = 2
00507                END IF
00508             END IF
00509 *
00510             KK = K + KSTEP - 1
00511             IF( KP.NE.KK ) THEN
00512 *
00513 *              Interchange rows and columns KK and KP in the trailing
00514 *              submatrix A(k:n,k:n)
00515 *
00516                IF( KP.LT.N )
00517      $            CALL CSWAP( N-KP, A( KP+1, KK ), 1, A( KP+1, KP ), 1 )
00518                DO 60 J = KK + 1, KP - 1
00519                   T = CONJG( A( J, KK ) )
00520                   A( J, KK ) = CONJG( A( KP, J ) )
00521                   A( KP, J ) = T
00522    60          CONTINUE
00523                A( KP, KK ) = CONJG( A( KP, KK ) )
00524                R1 = REAL( A( KK, KK ) )
00525                A( KK, KK ) = REAL( A( KP, KP ) )
00526                A( KP, KP ) = R1
00527                IF( KSTEP.EQ.2 ) THEN
00528                   A( K, K ) = REAL( A( K, K ) )
00529                   T = A( K+1, K )
00530                   A( K+1, K ) = A( KP, K )
00531                   A( KP, K ) = T
00532                END IF
00533             ELSE
00534                A( K, K ) = REAL( A( K, K ) )
00535                IF( KSTEP.EQ.2 )
00536      $            A( K+1, K+1 ) = REAL( A( K+1, K+1 ) )
00537             END IF
00538 *
00539 *           Update the trailing submatrix
00540 *
00541             IF( KSTEP.EQ.1 ) THEN
00542 *
00543 *              1-by-1 pivot block D(k): column k now holds
00544 *
00545 *              W(k) = L(k)*D(k)
00546 *
00547 *              where L(k) is the k-th column of L
00548 *
00549                IF( K.LT.N ) THEN
00550 *
00551 *                 Perform a rank-1 update of A(k+1:n,k+1:n) as
00552 *
00553 *                 A := A - L(k)*D(k)*L(k)**H = A - W(k)*(1/D(k))*W(k)**H
00554 *
00555                   R1 = ONE / REAL( A( K, K ) )
00556                   CALL CHER( UPLO, N-K, -R1, A( K+1, K ), 1,
00557      $                       A( K+1, K+1 ), LDA )
00558 *
00559 *                 Store L(k) in column K
00560 *
00561                   CALL CSSCAL( N-K, R1, A( K+1, K ), 1 )
00562                END IF
00563             ELSE
00564 *
00565 *              2-by-2 pivot block D(k)
00566 *
00567                IF( K.LT.N-1 ) THEN
00568 *
00569 *                 Perform a rank-2 update of A(k+2:n,k+2:n) as
00570 *
00571 *                 A := A - ( L(k) L(k+1) )*D(k)*( L(k) L(k+1) )**H
00572 *                    = A - ( W(k) W(k+1) )*inv(D(k))*( W(k) W(k+1) )**H
00573 *
00574 *                 where L(k) and L(k+1) are the k-th and (k+1)-th
00575 *                 columns of L
00576 *
00577                   D = SLAPY2( REAL( A( K+1, K ) ),
00578      $                        AIMAG( A( K+1, K ) ) )
00579                   D11 = REAL( A( K+1, K+1 ) ) / D
00580                   D22 = REAL( A( K, K ) ) / D
00581                   TT = ONE / ( D11*D22-ONE )
00582                   D21 = A( K+1, K ) / D
00583                   D =  TT / D
00584 *
00585                   DO 80 J = K + 2, N
00586                      WK = D*( D11*A( J, K )-D21*A( J, K+1 ) )
00587                      WKP1 = D*( D22*A( J, K+1 )-CONJG( D21 )*A( J, K ) )
00588                      DO 70 I = J, N
00589                         A( I, J ) = A( I, J ) - A( I, K )*CONJG( WK ) -
00590      $                              A( I, K+1 )*CONJG( WKP1 )
00591    70                CONTINUE
00592                      A( J, K ) = WK
00593                      A( J, K+1 ) = WKP1
00594                      A( J, J ) = CMPLX( REAL( A( J, J ) ), 0.0E+0 )
00595    80             CONTINUE
00596                END IF
00597             END IF
00598          END IF
00599 *
00600 *        Store details of the interchanges in IPIV
00601 *
00602          IF( KSTEP.EQ.1 ) THEN
00603             IPIV( K ) = KP
00604          ELSE
00605             IPIV( K ) = -KP
00606             IPIV( K+1 ) = -KP
00607          END IF
00608 *
00609 *        Increase K and return to the start of the main loop
00610 *
00611          K = K + KSTEP
00612          GO TO 50
00613 *
00614       END IF
00615 *
00616    90 CONTINUE
00617       RETURN
00618 *
00619 *     End of CHETF2
00620 *
00621       END
 All Files Functions