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