3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SPBTRF + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spbtrf.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spbtrf.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spbtrf.f">
21 * SUBROUTINE SPBTRF( UPLO, N, KD, AB, LDAB, INFO )
23 * .. Scalar Arguments ..
25 * INTEGER INFO, KD, LDAB, N
27 * .. Array Arguments ..
37 *> SPBTRF computes the Cholesky factorization of a real symmetric
38 *> positive definite band matrix A.
40 *> The factorization has the form
41 *> A = U**T * U, if UPLO = 'U', or
42 *> A = L * L**T, if UPLO = 'L',
43 *> where U is an upper triangular matrix and L is lower triangular.
51 *> UPLO is CHARACTER*1
52 *> = 'U': Upper triangle of A is stored;
53 *> = 'L': Lower triangle of A is stored.
59 *> The order of the matrix A. N >= 0.
65 *> The number of superdiagonals of the matrix A if UPLO = 'U',
66 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
71 *> AB is REAL array, dimension (LDAB,N)
72 *> On entry, the upper or lower triangle of the symmetric band
73 *> matrix A, stored in the first KD+1 rows of the array. The
74 *> j-th column of A is stored in the j-th column of the array AB
76 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
77 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
79 *> On exit, if INFO = 0, the triangular factor U or L from the
80 *> Cholesky factorization A = U**T*U or A = L*L**T of the band
81 *> matrix A, in the same storage format as A.
87 *> The leading dimension of the array AB. LDAB >= KD+1.
93 *> = 0: successful exit
94 *> < 0: if INFO = -i, the i-th argument had an illegal value
95 *> > 0: if INFO = i, the leading minor of order i is not
96 *> positive definite, and the factorization could not be
103 *> \author Univ. of Tennessee
104 *> \author Univ. of California Berkeley
105 *> \author Univ. of Colorado Denver
108 *> \date November 2011
110 *> \ingroup realOTHERcomputational
112 *> \par Further Details:
113 * =====================
117 *> The band storage scheme is illustrated by the following example, when
118 *> N = 6, KD = 2, and UPLO = 'U':
120 *> On entry: On exit:
122 *> * * a13 a24 a35 a46 * * u13 u24 u35 u46
123 *> * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
124 *> a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
126 *> Similarly, if UPLO = 'L' the format of A is as follows:
128 *> On entry: On exit:
130 *> a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
131 *> a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
132 *> a31 a42 a53 a64 * * l31 l42 l53 l64 * *
134 *> Array elements marked * are not used by the routine.
137 *> \par Contributors:
140 *> Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989
142 * =====================================================================
143 SUBROUTINE SPBTRF( UPLO, N, KD, AB, LDAB, INFO )
145 * -- LAPACK computational routine (version 3.4.0) --
146 * -- LAPACK is a software package provided by Univ. of Tennessee, --
147 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
150 * .. Scalar Arguments ..
152 INTEGER INFO, KD, LDAB, N
154 * .. Array Arguments ..
158 * =====================================================================
162 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
163 INTEGER NBMAX, LDWORK
164 PARAMETER ( NBMAX = 32, LDWORK = NBMAX+1 )
166 * .. Local Scalars ..
167 INTEGER I, I2, I3, IB, II, J, JJ, NB
170 REAL WORK( LDWORK, NBMAX )
172 * .. External Functions ..
175 EXTERNAL LSAME, ILAENV
177 * .. External Subroutines ..
178 EXTERNAL SGEMM, SPBTF2, SPOTF2, SSYRK, STRSM, XERBLA
180 * .. Intrinsic Functions ..
183 * .. Executable Statements ..
185 * Test the input parameters.
188 IF( ( .NOT.LSAME( UPLO, 'U' ) ) .AND.
189 $ ( .NOT.LSAME( UPLO, 'L' ) ) ) THEN
191 ELSE IF( N.LT.0 ) THEN
193 ELSE IF( KD.LT.0 ) THEN
195 ELSE IF( LDAB.LT.KD+1 ) THEN
199 CALL XERBLA( 'SPBTRF', -INFO )
203 * Quick return if possible
208 * Determine the block size for this environment
210 NB = ILAENV( 1, 'SPBTRF', UPLO, N, KD, -1, -1 )
212 * The block size must not exceed the semi-bandwidth KD, and must not
213 * exceed the limit set by the size of the local array WORK.
215 NB = MIN( NB, NBMAX )
217 IF( NB.LE.1 .OR. NB.GT.KD ) THEN
221 CALL SPBTF2( UPLO, N, KD, AB, LDAB, INFO )
226 IF( LSAME( UPLO, 'U' ) ) THEN
228 * Compute the Cholesky factorization of a symmetric band
229 * matrix, given the upper triangle of the matrix in band
232 * Zero the upper triangle of the work array.
240 * Process the band matrix one diagonal block at a time.
243 IB = MIN( NB, N-I+1 )
245 * Factorize the diagonal block
247 CALL SPOTF2( UPLO, IB, AB( KD+1, I ), LDAB-1, II )
254 * Update the relevant part of the trailing submatrix.
255 * If A11 denotes the diagonal block which has just been
256 * factorized, then we need to update the remaining
257 * blocks in the diagram:
263 * The numbers of rows and columns in the partitioning
264 * are IB, I2, I3 respectively. The blocks A12, A22 and
265 * A23 are empty if IB = KD. The upper triangle of A13
266 * lies outside the band.
268 I2 = MIN( KD-IB, N-I-IB+1 )
269 I3 = MIN( IB, N-I-KD+1 )
275 CALL STRSM( 'Left', 'Upper', 'Transpose',
276 $ 'Non-unit', IB, I2, ONE, AB( KD+1, I ),
277 $ LDAB-1, AB( KD+1-IB, I+IB ), LDAB-1 )
281 CALL SSYRK( 'Upper', 'Transpose', I2, IB, -ONE,
282 $ AB( KD+1-IB, I+IB ), LDAB-1, ONE,
283 $ AB( KD+1, I+IB ), LDAB-1 )
288 * Copy the lower triangle of A13 into the work array.
292 WORK( II, JJ ) = AB( II-JJ+1, JJ+I+KD-1 )
296 * Update A13 (in the work array).
298 CALL STRSM( 'Left', 'Upper', 'Transpose',
299 $ 'Non-unit', IB, I3, ONE, AB( KD+1, I ),
300 $ LDAB-1, WORK, LDWORK )
305 $ CALL SGEMM( 'Transpose', 'No Transpose', I2, I3,
306 $ IB, -ONE, AB( KD+1-IB, I+IB ),
307 $ LDAB-1, WORK, LDWORK, ONE,
308 $ AB( 1+IB, I+KD ), LDAB-1 )
312 CALL SSYRK( 'Upper', 'Transpose', I3, IB, -ONE,
313 $ WORK, LDWORK, ONE, AB( KD+1, I+KD ),
316 * Copy the lower triangle of A13 back into place.
320 AB( II-JJ+1, JJ+I+KD-1 ) = WORK( II, JJ )
328 * Compute the Cholesky factorization of a symmetric band
329 * matrix, given the lower triangle of the matrix in band
332 * Zero the lower triangle of the work array.
340 * Process the band matrix one diagonal block at a time.
343 IB = MIN( NB, N-I+1 )
345 * Factorize the diagonal block
347 CALL SPOTF2( UPLO, IB, AB( 1, I ), LDAB-1, II )
354 * Update the relevant part of the trailing submatrix.
355 * If A11 denotes the diagonal block which has just been
356 * factorized, then we need to update the remaining
357 * blocks in the diagram:
363 * The numbers of rows and columns in the partitioning
364 * are IB, I2, I3 respectively. The blocks A21, A22 and
365 * A32 are empty if IB = KD. The lower triangle of A31
366 * lies outside the band.
368 I2 = MIN( KD-IB, N-I-IB+1 )
369 I3 = MIN( IB, N-I-KD+1 )
375 CALL STRSM( 'Right', 'Lower', 'Transpose',
376 $ 'Non-unit', I2, IB, ONE, AB( 1, I ),
377 $ LDAB-1, AB( 1+IB, I ), LDAB-1 )
381 CALL SSYRK( 'Lower', 'No Transpose', I2, IB, -ONE,
382 $ AB( 1+IB, I ), LDAB-1, ONE,
383 $ AB( 1, I+IB ), LDAB-1 )
388 * Copy the upper triangle of A31 into the work array.
391 DO 100 II = 1, MIN( JJ, I3 )
392 WORK( II, JJ ) = AB( KD+1-JJ+II, JJ+I-1 )
396 * Update A31 (in the work array).
398 CALL STRSM( 'Right', 'Lower', 'Transpose',
399 $ 'Non-unit', I3, IB, ONE, AB( 1, I ),
400 $ LDAB-1, WORK, LDWORK )
405 $ CALL SGEMM( 'No transpose', 'Transpose', I3, I2,
406 $ IB, -ONE, WORK, LDWORK,
407 $ AB( 1+IB, I ), LDAB-1, ONE,
408 $ AB( 1+KD-IB, I+IB ), LDAB-1 )
412 CALL SSYRK( 'Lower', 'No Transpose', I3, IB, -ONE,
413 $ WORK, LDWORK, ONE, AB( 1, I+KD ),
416 * Copy the upper triangle of A31 back into place.
419 DO 120 II = 1, MIN( JJ, I3 )
420 AB( KD+1-JJ+II, JJ+I-1 ) = WORK( II, JJ )