001:       SUBROUTINE DPTTRF( N, D, E, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       INTEGER            INFO, N
010: *     ..
011: *     .. Array Arguments ..
012:       DOUBLE PRECISION   D( * ), E( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  DPTTRF computes the L*D*L' factorization of a real symmetric
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) DOUBLE PRECISION 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) DOUBLE PRECISION 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:       DOUBLE PRECISION   ZERO
052:       PARAMETER          ( ZERO = 0.0D+0 )
053: *     ..
054: *     .. Local Scalars ..
055:       INTEGER            I, I4
056:       DOUBLE PRECISION   EI
057: *     ..
058: *     .. External Subroutines ..
059:       EXTERNAL           XERBLA
060: *     ..
061: *     .. Intrinsic Functions ..
062:       INTRINSIC          MOD
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( 'DPTTRF', -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 30
087:          END IF
088:          EI = E( I )
089:          E( I ) = EI / D( I )
090:          D( I+1 ) = D( I+1 ) - E( I )*EI
091:    10 CONTINUE
092: *
093:       DO 20 I = I4 + 1, N - 4, 4
094: *
095: *        Drop out of the loop if d(i) <= 0: the matrix is not positive
096: *        definite.
097: *
098:          IF( D( I ).LE.ZERO ) THEN
099:             INFO = I
100:             GO TO 30
101:          END IF
102: *
103: *        Solve for e(i) and d(i+1).
104: *
105:          EI = E( I )
106:          E( I ) = EI / D( I )
107:          D( I+1 ) = D( I+1 ) - E( I )*EI
108: *
109:          IF( D( I+1 ).LE.ZERO ) THEN
110:             INFO = I + 1
111:             GO TO 30
112:          END IF
113: *
114: *        Solve for e(i+1) and d(i+2).
115: *
116:          EI = E( I+1 )
117:          E( I+1 ) = EI / D( I+1 )
118:          D( I+2 ) = D( I+2 ) - E( I+1 )*EI
119: *
120:          IF( D( I+2 ).LE.ZERO ) THEN
121:             INFO = I + 2
122:             GO TO 30
123:          END IF
124: *
125: *        Solve for e(i+2) and d(i+3).
126: *
127:          EI = E( I+2 )
128:          E( I+2 ) = EI / D( I+2 )
129:          D( I+3 ) = D( I+3 ) - E( I+2 )*EI
130: *
131:          IF( D( I+3 ).LE.ZERO ) THEN
132:             INFO = I + 3
133:             GO TO 30
134:          END IF
135: *
136: *        Solve for e(i+3) and d(i+4).
137: *
138:          EI = E( I+3 )
139:          E( I+3 ) = EI / D( I+3 )
140:          D( I+4 ) = D( I+4 ) - E( I+3 )*EI
141:    20 CONTINUE
142: *
143: *     Check d(n) for positive definiteness.
144: *
145:       IF( D( N ).LE.ZERO )
146:      $   INFO = N
147: *
148:    30 CONTINUE
149:       RETURN
150: *
151: *     End of DPTTRF
152: *
153:       END
154: