```001:       SUBROUTINE DPBSTF( UPLO, N, KD, AB, LDAB, 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:       CHARACTER          UPLO
009:       INTEGER            INFO, KD, LDAB, N
010: *     ..
011: *     .. Array Arguments ..
012:       DOUBLE PRECISION   AB( LDAB, * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  DPBSTF computes a split Cholesky factorization of a real
019: *  symmetric positive definite band matrix A.
020: *
021: *  This routine is designed to be used in conjunction with DSBGST.
022: *
023: *  The factorization has the form  A = S**T*S  where S is a band matrix
024: *  of the same bandwidth as A and the following structure:
025: *
026: *    S = ( U    )
027: *        ( M  L )
028: *
029: *  where U is upper triangular of order m = (n+kd)/2, and L is lower
030: *  triangular of order n-m.
031: *
032: *  Arguments
033: *  =========
034: *
035: *  UPLO    (input) CHARACTER*1
036: *          = 'U':  Upper triangle of A is stored;
037: *          = 'L':  Lower triangle of A is stored.
038: *
039: *  N       (input) INTEGER
040: *          The order of the matrix A.  N >= 0.
041: *
042: *  KD      (input) INTEGER
043: *          The number of superdiagonals of the matrix A if UPLO = 'U',
044: *          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
045: *
046: *  AB      (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
047: *          On entry, the upper or lower triangle of the symmetric band
048: *          matrix A, stored in the first kd+1 rows of the array.  The
049: *          j-th column of A is stored in the j-th column of the array AB
050: *          as follows:
051: *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
052: *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
053: *
054: *          On exit, if INFO = 0, the factor S from the split Cholesky
055: *          factorization A = S**T*S. See Further Details.
056: *
057: *  LDAB    (input) INTEGER
058: *          The leading dimension of the array AB.  LDAB >= KD+1.
059: *
060: *  INFO    (output) INTEGER
061: *          = 0: successful exit
062: *          < 0: if INFO = -i, the i-th argument had an illegal value
063: *          > 0: if INFO = i, the factorization could not be completed,
064: *               because the updated element a(i,i) was negative; the
065: *               matrix A is not positive definite.
066: *
067: *  Further Details
068: *  ===============
069: *
070: *  The band storage scheme is illustrated by the following example, when
071: *  N = 7, KD = 2:
072: *
073: *  S = ( s11  s12  s13                     )
074: *      (      s22  s23  s24                )
075: *      (           s33  s34                )
076: *      (                s44                )
077: *      (           s53  s54  s55           )
078: *      (                s64  s65  s66      )
079: *      (                     s75  s76  s77 )
080: *
081: *  If UPLO = 'U', the array AB holds:
082: *
083: *  on entry:                          on exit:
084: *
085: *   *    *   a13  a24  a35  a46  a57   *    *   s13  s24  s53  s64  s75
086: *   *   a12  a23  a34  a45  a56  a67   *   s12  s23  s34  s54  s65  s76
087: *  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
088: *
089: *  If UPLO = 'L', the array AB holds:
090: *
091: *  on entry:                          on exit:
092: *
093: *  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
094: *  a21  a32  a43  a54  a65  a76   *   s12  s23  s34  s54  s65  s76   *
095: *  a31  a42  a53  a64  a64   *    *   s13  s24  s53  s64  s75   *    *
096: *
097: *  Array elements marked * are not used by the routine.
098: *
099: *  =====================================================================
100: *
101: *     .. Parameters ..
102:       DOUBLE PRECISION   ONE, ZERO
103:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
104: *     ..
105: *     .. Local Scalars ..
106:       LOGICAL            UPPER
107:       INTEGER            J, KLD, KM, M
108:       DOUBLE PRECISION   AJJ
109: *     ..
110: *     .. External Functions ..
111:       LOGICAL            LSAME
112:       EXTERNAL           LSAME
113: *     ..
114: *     .. External Subroutines ..
115:       EXTERNAL           DSCAL, DSYR, XERBLA
116: *     ..
117: *     .. Intrinsic Functions ..
118:       INTRINSIC          MAX, MIN, SQRT
119: *     ..
120: *     .. Executable Statements ..
121: *
122: *     Test the input parameters.
123: *
124:       INFO = 0
125:       UPPER = LSAME( UPLO, 'U' )
126:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
127:          INFO = -1
128:       ELSE IF( N.LT.0 ) THEN
129:          INFO = -2
130:       ELSE IF( KD.LT.0 ) THEN
131:          INFO = -3
132:       ELSE IF( LDAB.LT.KD+1 ) THEN
133:          INFO = -5
134:       END IF
135:       IF( INFO.NE.0 ) THEN
136:          CALL XERBLA( 'DPBSTF', -INFO )
137:          RETURN
138:       END IF
139: *
140: *     Quick return if possible
141: *
142:       IF( N.EQ.0 )
143:      \$   RETURN
144: *
145:       KLD = MAX( 1, LDAB-1 )
146: *
147: *     Set the splitting point m.
148: *
149:       M = ( N+KD ) / 2
150: *
151:       IF( UPPER ) THEN
152: *
153: *        Factorize A(m+1:n,m+1:n) as L**T*L, and update A(1:m,1:m).
154: *
155:          DO 10 J = N, M + 1, -1
156: *
157: *           Compute s(j,j) and test for non-positive-definiteness.
158: *
159:             AJJ = AB( KD+1, J )
160:             IF( AJJ.LE.ZERO )
161:      \$         GO TO 50
162:             AJJ = SQRT( AJJ )
163:             AB( KD+1, J ) = AJJ
164:             KM = MIN( J-1, KD )
165: *
166: *           Compute elements j-km:j-1 of the j-th column and update the
167: *           the leading submatrix within the band.
168: *
169:             CALL DSCAL( KM, ONE / AJJ, AB( KD+1-KM, J ), 1 )
170:             CALL DSYR( 'Upper', KM, -ONE, AB( KD+1-KM, J ), 1,
171:      \$                 AB( KD+1, J-KM ), KLD )
172:    10    CONTINUE
173: *
174: *        Factorize the updated submatrix A(1:m,1:m) as U**T*U.
175: *
176:          DO 20 J = 1, M
177: *
178: *           Compute s(j,j) and test for non-positive-definiteness.
179: *
180:             AJJ = AB( KD+1, J )
181:             IF( AJJ.LE.ZERO )
182:      \$         GO TO 50
183:             AJJ = SQRT( AJJ )
184:             AB( KD+1, J ) = AJJ
185:             KM = MIN( KD, M-J )
186: *
187: *           Compute elements j+1:j+km of the j-th row and update the
188: *           trailing submatrix within the band.
189: *
190:             IF( KM.GT.0 ) THEN
191:                CALL DSCAL( KM, ONE / AJJ, AB( KD, J+1 ), KLD )
192:                CALL DSYR( 'Upper', KM, -ONE, AB( KD, J+1 ), KLD,
193:      \$                    AB( KD+1, J+1 ), KLD )
194:             END IF
195:    20    CONTINUE
196:       ELSE
197: *
198: *        Factorize A(m+1:n,m+1:n) as L**T*L, and update A(1:m,1:m).
199: *
200:          DO 30 J = N, M + 1, -1
201: *
202: *           Compute s(j,j) and test for non-positive-definiteness.
203: *
204:             AJJ = AB( 1, J )
205:             IF( AJJ.LE.ZERO )
206:      \$         GO TO 50
207:             AJJ = SQRT( AJJ )
208:             AB( 1, J ) = AJJ
209:             KM = MIN( J-1, KD )
210: *
211: *           Compute elements j-km:j-1 of the j-th row and update the
212: *           trailing submatrix within the band.
213: *
214:             CALL DSCAL( KM, ONE / AJJ, AB( KM+1, J-KM ), KLD )
215:             CALL DSYR( 'Lower', KM, -ONE, AB( KM+1, J-KM ), KLD,
216:      \$                 AB( 1, J-KM ), KLD )
217:    30    CONTINUE
218: *
219: *        Factorize the updated submatrix A(1:m,1:m) as U**T*U.
220: *
221:          DO 40 J = 1, M
222: *
223: *           Compute s(j,j) and test for non-positive-definiteness.
224: *
225:             AJJ = AB( 1, J )
226:             IF( AJJ.LE.ZERO )
227:      \$         GO TO 50
228:             AJJ = SQRT( AJJ )
229:             AB( 1, J ) = AJJ
230:             KM = MIN( KD, M-J )
231: *
232: *           Compute elements j+1:j+km of the j-th column and update the
233: *           trailing submatrix within the band.
234: *
235:             IF( KM.GT.0 ) THEN
236:                CALL DSCAL( KM, ONE / AJJ, AB( 2, J ), 1 )
237:                CALL DSYR( 'Lower', KM, -ONE, AB( 2, J ), 1,
238:      \$                    AB( 1, J+1 ), KLD )
239:             END IF
240:    40    CONTINUE
241:       END IF
242:       RETURN
243: *
244:    50 CONTINUE
245:       INFO = J
246:       RETURN
247: *
248: *     End of DPBSTF
249: *
250:       END
251: ```