001:       SUBROUTINE CPTTRF( N, D, E, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
005: *     November 2006
006: *
007: *     .. Scalar Arguments ..
008:       INTEGER            INFO, N
009: *     ..
010: *     .. Array Arguments ..
011:       REAL               D( * )
012:       COMPLEX            E( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  CPTTRF computes the L*D*L' factorization of a complex Hermitian
019: *  positive definite tridiagonal matrix A.  The factorization may also
020: *  be regarded as having the form A = U'*D*U.
021: *
022: *  Arguments
023: *  =========
024: *
025: *  N       (input) INTEGER
026: *          The order of the matrix A.  N >= 0.
027: *
028: *  D       (input/output) REAL array, dimension (N)
029: *          On entry, the n diagonal elements of the tridiagonal matrix
030: *          A.  On exit, the n diagonal elements of the diagonal matrix
031: *          D from the L*D*L' factorization of A.
032: *
033: *  E       (input/output) COMPLEX array, dimension (N-1)
034: *          On entry, the (n-1) subdiagonal elements of the tridiagonal
035: *          matrix A.  On exit, the (n-1) subdiagonal elements of the
036: *          unit bidiagonal factor L from the L*D*L' factorization of A.
037: *          E can also be regarded as the superdiagonal of the unit
038: *          bidiagonal factor U from the U'*D*U factorization of A.
039: *
040: *  INFO    (output) INTEGER
041: *          = 0: successful exit
042: *          < 0: if INFO = -k, the k-th argument had an illegal value
043: *          > 0: if INFO = k, the leading minor of order k is not
044: *               positive definite; if k < N, the factorization could not
045: *               be completed, while if k = N, the factorization was
046: *               completed, but D(N) <= 0.
047: *
048: *  =====================================================================
049: *
050: *     .. Parameters ..
051:       REAL               ZERO
052:       PARAMETER          ( ZERO = 0.0E+0 )
053: *     ..
054: *     .. Local Scalars ..
055:       INTEGER            I, I4
056:       REAL               EII, EIR, F, G
057: *     ..
058: *     .. External Subroutines ..
059:       EXTERNAL           XERBLA
060: *     ..
061: *     .. Intrinsic Functions ..
062:       INTRINSIC          AIMAG, CMPLX, MOD, REAL
063: *     ..
064: *     .. Executable Statements ..
065: *
066: *     Test the input parameters.
067: *
068:       INFO = 0
069:       IF( N.LT.0 ) THEN
070:          INFO = -1
071:          CALL XERBLA( 'CPTTRF', -INFO )
072:          RETURN
073:       END IF
074: *
075: *     Quick return if possible
076: *
077:       IF( N.EQ.0 )
078:      $   RETURN
079: *
080: *     Compute the L*D*L' (or U'*D*U) factorization of A.
081: *
082:       I4 = MOD( N-1, 4 )
083:       DO 10 I = 1, I4
084:          IF( D( I ).LE.ZERO ) THEN
085:             INFO = I
086:             GO TO 20
087:          END IF
088:          EIR = REAL( E( I ) )
089:          EII = AIMAG( E( I ) )
090:          F = EIR / D( I )
091:          G = EII / D( I )
092:          E( I ) = CMPLX( F, G )
093:          D( I+1 ) = D( I+1 ) - F*EIR - G*EII
094:    10 CONTINUE
095: *
096:       DO 110 I = I4+1, N - 4, 4
097: *
098: *        Drop out of the loop if d(i) <= 0: the matrix is not positive
099: *        definite.
100: *
101:          IF( D( I ).LE.ZERO ) THEN
102:             INFO = I
103:             GO TO 20
104:          END IF
105: *
106: *        Solve for e(i) and d(i+1).
107: *
108:          EIR = REAL( E( I ) )
109:          EII = AIMAG( E( I ) )
110:          F = EIR / D( I )
111:          G = EII / D( I )
112:          E( I ) = CMPLX( F, G )
113:          D( I+1 ) = D( I+1 ) - F*EIR - G*EII
114: *
115:          IF( D( I+1 ).LE.ZERO ) THEN
116:             INFO = I+1
117:             GO TO 20
118:          END IF
119: *
120: *        Solve for e(i+1) and d(i+2).
121: *
122:          EIR = REAL( E( I+1 ) )
123:          EII = AIMAG( E( I+1 ) )
124:          F = EIR / D( I+1 )
125:          G = EII / D( I+1 )
126:          E( I+1 ) = CMPLX( F, G )
127:          D( I+2 ) = D( I+2 ) - F*EIR - G*EII
128: *
129:          IF( D( I+2 ).LE.ZERO ) THEN
130:             INFO = I+2
131:             GO TO 20
132:          END IF
133: *
134: *        Solve for e(i+2) and d(i+3).
135: *
136:          EIR = REAL( E( I+2 ) )
137:          EII = AIMAG( E( I+2 ) )
138:          F = EIR / D( I+2 )
139:          G = EII / D( I+2 )
140:          E( I+2 ) = CMPLX( F, G )
141:          D( I+3 ) = D( I+3 ) - F*EIR - G*EII
142: *
143:          IF( D( I+3 ).LE.ZERO ) THEN
144:             INFO = I+3
145:             GO TO 20
146:          END IF
147: *
148: *        Solve for e(i+3) and d(i+4).
149: *
150:          EIR = REAL( E( I+3 ) )
151:          EII = AIMAG( E( I+3 ) )
152:          F = EIR / D( I+3 )
153:          G = EII / D( I+3 )
154:          E( I+3 ) = CMPLX( F, G )
155:          D( I+4 ) = D( I+4 ) - F*EIR - G*EII
156:   110 CONTINUE
157: *
158: *     Check d(n) for positive definiteness.
159: *
160:       IF( D( N ).LE.ZERO )
161:      $   INFO = N
162: *
163:    20 CONTINUE
164:       RETURN
165: *
166: *     End of CPTTRF
167: *
168:       END
169: