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