001:       SUBROUTINE ZPBSTF( 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:       COMPLEX*16         AB( LDAB, * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  ZPBSTF computes a split Cholesky factorization of a complex
019: *  Hermitian positive definite band matrix A.
020: *
021: *  This routine is designed to be used in conjunction with ZHBGST.
022: *
023: *  The factorization has the form  A = S**H*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) COMPLEX*16 array, dimension (LDAB,N)
047: *          On entry, the upper or lower triangle of the Hermitian 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**H*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; s12' denotes
098: *  conjg(s12); the diagonal elements of S are real.
099: *
100: *  =====================================================================
101: *
102: *     .. Parameters ..
103:       DOUBLE PRECISION   ONE, ZERO
104:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
105: *     ..
106: *     .. Local Scalars ..
107:       LOGICAL            UPPER
108:       INTEGER            J, KLD, KM, M
109:       DOUBLE PRECISION   AJJ
110: *     ..
111: *     .. External Functions ..
112:       LOGICAL            LSAME
113:       EXTERNAL           LSAME
114: *     ..
115: *     .. External Subroutines ..
116:       EXTERNAL           XERBLA, ZDSCAL, ZHER, ZLACGV
117: *     ..
118: *     .. Intrinsic Functions ..
119:       INTRINSIC          DBLE, MAX, MIN, SQRT
120: *     ..
121: *     .. Executable Statements ..
122: *
123: *     Test the input parameters.
124: *
125:       INFO = 0
126:       UPPER = LSAME( UPLO, 'U' )
127:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
128:          INFO = -1
129:       ELSE IF( N.LT.0 ) THEN
130:          INFO = -2
131:       ELSE IF( KD.LT.0 ) THEN
132:          INFO = -3
133:       ELSE IF( LDAB.LT.KD+1 ) THEN
134:          INFO = -5
135:       END IF
136:       IF( INFO.NE.0 ) THEN
137:          CALL XERBLA( 'ZPBSTF', -INFO )
138:          RETURN
139:       END IF
140: *
141: *     Quick return if possible
142: *
143:       IF( N.EQ.0 )
144:      $   RETURN
145: *
146:       KLD = MAX( 1, LDAB-1 )
147: *
148: *     Set the splitting point m.
149: *
150:       M = ( N+KD ) / 2
151: *
152:       IF( UPPER ) THEN
153: *
154: *        Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m).
155: *
156:          DO 10 J = N, M + 1, -1
157: *
158: *           Compute s(j,j) and test for non-positive-definiteness.
159: *
160:             AJJ = DBLE( AB( KD+1, J ) )
161:             IF( AJJ.LE.ZERO ) THEN
162:                AB( KD+1, J ) = AJJ
163:                GO TO 50
164:             END IF
165:             AJJ = SQRT( AJJ )
166:             AB( KD+1, J ) = AJJ
167:             KM = MIN( J-1, KD )
168: *
169: *           Compute elements j-km:j-1 of the j-th column and update the
170: *           the leading submatrix within the band.
171: *
172:             CALL ZDSCAL( KM, ONE / AJJ, AB( KD+1-KM, J ), 1 )
173:             CALL ZHER( 'Upper', KM, -ONE, AB( KD+1-KM, J ), 1,
174:      $                 AB( KD+1, J-KM ), KLD )
175:    10    CONTINUE
176: *
177: *        Factorize the updated submatrix A(1:m,1:m) as U**H*U.
178: *
179:          DO 20 J = 1, M
180: *
181: *           Compute s(j,j) and test for non-positive-definiteness.
182: *
183:             AJJ = DBLE( AB( KD+1, J ) )
184:             IF( AJJ.LE.ZERO ) THEN
185:                AB( KD+1, J ) = AJJ
186:                GO TO 50
187:             END IF
188:             AJJ = SQRT( AJJ )
189:             AB( KD+1, J ) = AJJ
190:             KM = MIN( KD, M-J )
191: *
192: *           Compute elements j+1:j+km of the j-th row and update the
193: *           trailing submatrix within the band.
194: *
195:             IF( KM.GT.0 ) THEN
196:                CALL ZDSCAL( KM, ONE / AJJ, AB( KD, J+1 ), KLD )
197:                CALL ZLACGV( KM, AB( KD, J+1 ), KLD )
198:                CALL ZHER( 'Upper', KM, -ONE, AB( KD, J+1 ), KLD,
199:      $                    AB( KD+1, J+1 ), KLD )
200:                CALL ZLACGV( KM, AB( KD, J+1 ), KLD )
201:             END IF
202:    20    CONTINUE
203:       ELSE
204: *
205: *        Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m).
206: *
207:          DO 30 J = N, M + 1, -1
208: *
209: *           Compute s(j,j) and test for non-positive-definiteness.
210: *
211:             AJJ = DBLE( AB( 1, J ) )
212:             IF( AJJ.LE.ZERO ) THEN
213:                AB( 1, J ) = AJJ
214:                GO TO 50
215:             END IF
216:             AJJ = SQRT( AJJ )
217:             AB( 1, J ) = AJJ
218:             KM = MIN( J-1, KD )
219: *
220: *           Compute elements j-km:j-1 of the j-th row and update the
221: *           trailing submatrix within the band.
222: *
223:             CALL ZDSCAL( KM, ONE / AJJ, AB( KM+1, J-KM ), KLD )
224:             CALL ZLACGV( KM, AB( KM+1, J-KM ), KLD )
225:             CALL ZHER( 'Lower', KM, -ONE, AB( KM+1, J-KM ), KLD,
226:      $                 AB( 1, J-KM ), KLD )
227:             CALL ZLACGV( KM, AB( KM+1, J-KM ), KLD )
228:    30    CONTINUE
229: *
230: *        Factorize the updated submatrix A(1:m,1:m) as U**H*U.
231: *
232:          DO 40 J = 1, M
233: *
234: *           Compute s(j,j) and test for non-positive-definiteness.
235: *
236:             AJJ = DBLE( AB( 1, J ) )
237:             IF( AJJ.LE.ZERO ) THEN
238:                AB( 1, J ) = AJJ
239:                GO TO 50
240:             END IF
241:             AJJ = SQRT( AJJ )
242:             AB( 1, J ) = AJJ
243:             KM = MIN( KD, M-J )
244: *
245: *           Compute elements j+1:j+km of the j-th column and update the
246: *           trailing submatrix within the band.
247: *
248:             IF( KM.GT.0 ) THEN
249:                CALL ZDSCAL( KM, ONE / AJJ, AB( 2, J ), 1 )
250:                CALL ZHER( 'Lower', KM, -ONE, AB( 2, J ), 1,
251:      $                    AB( 1, J+1 ), KLD )
252:             END IF
253:    40    CONTINUE
254:       END IF
255:       RETURN
256: *
257:    50 CONTINUE
258:       INFO = J
259:       RETURN
260: *
261: *     End of ZPBSTF
262: *
263:       END
264: