1      SUBROUTINE ZPBSTF( UPLO, N, KD, AB, LDAB, INFO )
2*
3*  -- LAPACK routine (version 3.0) --
4*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5*     Courant Institute, Argonne National Lab, and Rice University
6*     September 30, 1994
7*
8*     .. Scalar Arguments ..
9      CHARACTER          UPLO
10      INTEGER            INFO, KD, LDAB, N
11*     ..
12*     .. Array Arguments ..
13      COMPLEX*16         AB( LDAB, * )
14*     ..
15*
16*  Purpose
17*  =======
18*
19*  ZPBSTF computes a split Cholesky factorization of a complex
20*  Hermitian positive definite band matrix A.
21*
22*  This routine is designed to be used in conjunction with ZHBGST.
23*
24*  The factorization has the form  A = S**H*S  where S is a band matrix
25*  of the same bandwidth as A and the following structure:
26*
27*    S = ( U    )
28*        ( M  L )
29*
30*  where U is upper triangular of order m = (n+kd)/2, and L is lower
31*  triangular of order n-m.
32*
33*  Arguments
34*  =========
35*
36*  UPLO    (input) CHARACTER*1
37*          = 'U':  Upper triangle of A is stored;
38*          = 'L':  Lower triangle of A is stored.
39*
40*  N       (input) INTEGER
41*          The order of the matrix A.  N >= 0.
42*
43*  KD      (input) INTEGER
44*          The number of superdiagonals of the matrix A if UPLO = 'U',
45*          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
46*
47*  AB      (input/output) COMPLEX*16 array, dimension (LDAB,N)
48*          On entry, the upper or lower triangle of the Hermitian band
49*          matrix A, stored in the first kd+1 rows of the array.  The
50*          j-th column of A is stored in the j-th column of the array AB
51*          as follows:
52*          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
53*          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
54*
55*          On exit, if INFO = 0, the factor S from the split Cholesky
56*          factorization A = S**H*S. See Further Details.
57*
58*  LDAB    (input) INTEGER
59*          The leading dimension of the array AB.  LDAB >= KD+1.
60*
61*  INFO    (output) INTEGER
62*          = 0: successful exit
63*          < 0: if INFO = -i, the i-th argument had an illegal value
64*          > 0: if INFO = i, the factorization could not be completed,
65*               because the updated element a(i,i) was negative; the
66*               matrix A is not positive definite.
67*
68*  Further Details
69*  ===============
70*
71*  The band storage scheme is illustrated by the following example, when
72*  N = 7, KD = 2:
73*
74*  S = ( s11  s12  s13                     )
75*      (      s22  s23  s24                )
76*      (           s33  s34                )
77*      (                s44                )
78*      (           s53  s54  s55           )
79*      (                s64  s65  s66      )
80*      (                     s75  s76  s77 )
81*
82*  If UPLO = 'U', the array AB holds:
83*
84*  on entry:                          on exit:
85*
86*   *    *   a13  a24  a35  a46  a57   *    *   s13  s24  s53' s64' s75'
87*   *   a12  a23  a34  a45  a56  a67   *   s12  s23  s34  s54' s65' s76'
88*  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
89*
90*  If UPLO = 'L', the array AB holds:
91*
92*  on entry:                          on exit:
93*
94*  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
95*  a21  a32  a43  a54  a65  a76   *   s12' s23' s34' s54  s65  s76   *
96*  a31  a42  a53  a64  a64   *    *   s13' s24' s53  s64  s75   *    *
97*
98*  Array elements marked * are not used by the routine; s12' denotes
99*  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