![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SPBTRF 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SPBTRF + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spbtrf.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spbtrf.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spbtrf.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SPBTRF( UPLO, N, KD, AB, LDAB, INFO ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER UPLO 00025 * INTEGER INFO, KD, LDAB, N 00026 * .. 00027 * .. Array Arguments .. 00028 * REAL AB( LDAB, * ) 00029 * .. 00030 * 00031 * 00032 *> \par Purpose: 00033 * ============= 00034 *> 00035 *> \verbatim 00036 *> 00037 *> SPBTRF computes the Cholesky factorization of a real symmetric 00038 *> positive definite band matrix A. 00039 *> 00040 *> The factorization has the form 00041 *> A = U**T * U, if UPLO = 'U', or 00042 *> A = L * L**T, if UPLO = 'L', 00043 *> where U is an upper triangular matrix and L is lower triangular. 00044 *> \endverbatim 00045 * 00046 * Arguments: 00047 * ========== 00048 * 00049 *> \param[in] UPLO 00050 *> \verbatim 00051 *> UPLO is CHARACTER*1 00052 *> = 'U': Upper triangle of A is stored; 00053 *> = 'L': Lower triangle of A is stored. 00054 *> \endverbatim 00055 *> 00056 *> \param[in] N 00057 *> \verbatim 00058 *> N is INTEGER 00059 *> The order of the matrix A. N >= 0. 00060 *> \endverbatim 00061 *> 00062 *> \param[in] KD 00063 *> \verbatim 00064 *> KD is INTEGER 00065 *> The number of superdiagonals of the matrix A if UPLO = 'U', 00066 *> or the number of subdiagonals if UPLO = 'L'. KD >= 0. 00067 *> \endverbatim 00068 *> 00069 *> \param[in,out] AB 00070 *> \verbatim 00071 *> AB is REAL array, dimension (LDAB,N) 00072 *> On entry, the upper or lower triangle of the symmetric band 00073 *> matrix A, stored in the first KD+1 rows of the array. The 00074 *> j-th column of A is stored in the j-th column of the array AB 00075 *> as follows: 00076 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; 00077 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). 00078 *> 00079 *> On exit, if INFO = 0, the triangular factor U or L from the 00080 *> Cholesky factorization A = U**T*U or A = L*L**T of the band 00081 *> matrix A, in the same storage format as A. 00082 *> \endverbatim 00083 *> 00084 *> \param[in] LDAB 00085 *> \verbatim 00086 *> LDAB is INTEGER 00087 *> The leading dimension of the array AB. LDAB >= KD+1. 00088 *> \endverbatim 00089 *> 00090 *> \param[out] INFO 00091 *> \verbatim 00092 *> INFO is INTEGER 00093 *> = 0: successful exit 00094 *> < 0: if INFO = -i, the i-th argument had an illegal value 00095 *> > 0: if INFO = i, the leading minor of order i is not 00096 *> positive definite, and the factorization could not be 00097 *> completed. 00098 *> \endverbatim 00099 * 00100 * Authors: 00101 * ======== 00102 * 00103 *> \author Univ. of Tennessee 00104 *> \author Univ. of California Berkeley 00105 *> \author Univ. of Colorado Denver 00106 *> \author NAG Ltd. 00107 * 00108 *> \date November 2011 00109 * 00110 *> \ingroup realOTHERcomputational 00111 * 00112 *> \par Further Details: 00113 * ===================== 00114 *> 00115 *> \verbatim 00116 *> 00117 *> The band storage scheme is illustrated by the following example, when 00118 *> N = 6, KD = 2, and UPLO = 'U': 00119 *> 00120 *> On entry: On exit: 00121 *> 00122 *> * * a13 a24 a35 a46 * * u13 u24 u35 u46 00123 *> * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 00124 *> a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 00125 *> 00126 *> Similarly, if UPLO = 'L' the format of A is as follows: 00127 *> 00128 *> On entry: On exit: 00129 *> 00130 *> a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66 00131 *> a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 * 00132 *> a31 a42 a53 a64 * * l31 l42 l53 l64 * * 00133 *> 00134 *> Array elements marked * are not used by the routine. 00135 *> \endverbatim 00136 * 00137 *> \par Contributors: 00138 * ================== 00139 *> 00140 *> Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989 00141 * 00142 * ===================================================================== 00143 SUBROUTINE SPBTRF( UPLO, N, KD, AB, LDAB, INFO ) 00144 * 00145 * -- LAPACK computational routine (version 3.4.0) -- 00146 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00147 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00148 * November 2011 00149 * 00150 * .. Scalar Arguments .. 00151 CHARACTER UPLO 00152 INTEGER INFO, KD, LDAB, N 00153 * .. 00154 * .. Array Arguments .. 00155 REAL AB( LDAB, * ) 00156 * .. 00157 * 00158 * ===================================================================== 00159 * 00160 * .. Parameters .. 00161 REAL ONE, ZERO 00162 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00163 INTEGER NBMAX, LDWORK 00164 PARAMETER ( NBMAX = 32, LDWORK = NBMAX+1 ) 00165 * .. 00166 * .. Local Scalars .. 00167 INTEGER I, I2, I3, IB, II, J, JJ, NB 00168 * .. 00169 * .. Local Arrays .. 00170 REAL WORK( LDWORK, NBMAX ) 00171 * .. 00172 * .. External Functions .. 00173 LOGICAL LSAME 00174 INTEGER ILAENV 00175 EXTERNAL LSAME, ILAENV 00176 * .. 00177 * .. External Subroutines .. 00178 EXTERNAL SGEMM, SPBTF2, SPOTF2, SSYRK, STRSM, XERBLA 00179 * .. 00180 * .. Intrinsic Functions .. 00181 INTRINSIC MIN 00182 * .. 00183 * .. Executable Statements .. 00184 * 00185 * Test the input parameters. 00186 * 00187 INFO = 0 00188 IF( ( .NOT.LSAME( UPLO, 'U' ) ) .AND. 00189 $ ( .NOT.LSAME( UPLO, 'L' ) ) ) THEN 00190 INFO = -1 00191 ELSE IF( N.LT.0 ) THEN 00192 INFO = -2 00193 ELSE IF( KD.LT.0 ) THEN 00194 INFO = -3 00195 ELSE IF( LDAB.LT.KD+1 ) THEN 00196 INFO = -5 00197 END IF 00198 IF( INFO.NE.0 ) THEN 00199 CALL XERBLA( 'SPBTRF', -INFO ) 00200 RETURN 00201 END IF 00202 * 00203 * Quick return if possible 00204 * 00205 IF( N.EQ.0 ) 00206 $ RETURN 00207 * 00208 * Determine the block size for this environment 00209 * 00210 NB = ILAENV( 1, 'SPBTRF', UPLO, N, KD, -1, -1 ) 00211 * 00212 * The block size must not exceed the semi-bandwidth KD, and must not 00213 * exceed the limit set by the size of the local array WORK. 00214 * 00215 NB = MIN( NB, NBMAX ) 00216 * 00217 IF( NB.LE.1 .OR. NB.GT.KD ) THEN 00218 * 00219 * Use unblocked code 00220 * 00221 CALL SPBTF2( UPLO, N, KD, AB, LDAB, INFO ) 00222 ELSE 00223 * 00224 * Use blocked code 00225 * 00226 IF( LSAME( UPLO, 'U' ) ) THEN 00227 * 00228 * Compute the Cholesky factorization of a symmetric band 00229 * matrix, given the upper triangle of the matrix in band 00230 * storage. 00231 * 00232 * Zero the upper triangle of the work array. 00233 * 00234 DO 20 J = 1, NB 00235 DO 10 I = 1, J - 1 00236 WORK( I, J ) = ZERO 00237 10 CONTINUE 00238 20 CONTINUE 00239 * 00240 * Process the band matrix one diagonal block at a time. 00241 * 00242 DO 70 I = 1, N, NB 00243 IB = MIN( NB, N-I+1 ) 00244 * 00245 * Factorize the diagonal block 00246 * 00247 CALL SPOTF2( UPLO, IB, AB( KD+1, I ), LDAB-1, II ) 00248 IF( II.NE.0 ) THEN 00249 INFO = I + II - 1 00250 GO TO 150 00251 END IF 00252 IF( I+IB.LE.N ) THEN 00253 * 00254 * Update the relevant part of the trailing submatrix. 00255 * If A11 denotes the diagonal block which has just been 00256 * factorized, then we need to update the remaining 00257 * blocks in the diagram: 00258 * 00259 * A11 A12 A13 00260 * A22 A23 00261 * A33 00262 * 00263 * The numbers of rows and columns in the partitioning 00264 * are IB, I2, I3 respectively. The blocks A12, A22 and 00265 * A23 are empty if IB = KD. The upper triangle of A13 00266 * lies outside the band. 00267 * 00268 I2 = MIN( KD-IB, N-I-IB+1 ) 00269 I3 = MIN( IB, N-I-KD+1 ) 00270 * 00271 IF( I2.GT.0 ) THEN 00272 * 00273 * Update A12 00274 * 00275 CALL STRSM( 'Left', 'Upper', 'Transpose', 00276 $ 'Non-unit', IB, I2, ONE, AB( KD+1, I ), 00277 $ LDAB-1, AB( KD+1-IB, I+IB ), LDAB-1 ) 00278 * 00279 * Update A22 00280 * 00281 CALL SSYRK( 'Upper', 'Transpose', I2, IB, -ONE, 00282 $ AB( KD+1-IB, I+IB ), LDAB-1, ONE, 00283 $ AB( KD+1, I+IB ), LDAB-1 ) 00284 END IF 00285 * 00286 IF( I3.GT.0 ) THEN 00287 * 00288 * Copy the lower triangle of A13 into the work array. 00289 * 00290 DO 40 JJ = 1, I3 00291 DO 30 II = JJ, IB 00292 WORK( II, JJ ) = AB( II-JJ+1, JJ+I+KD-1 ) 00293 30 CONTINUE 00294 40 CONTINUE 00295 * 00296 * Update A13 (in the work array). 00297 * 00298 CALL STRSM( 'Left', 'Upper', 'Transpose', 00299 $ 'Non-unit', IB, I3, ONE, AB( KD+1, I ), 00300 $ LDAB-1, WORK, LDWORK ) 00301 * 00302 * Update A23 00303 * 00304 IF( I2.GT.0 ) 00305 $ CALL SGEMM( 'Transpose', 'No Transpose', I2, I3, 00306 $ IB, -ONE, AB( KD+1-IB, I+IB ), 00307 $ LDAB-1, WORK, LDWORK, ONE, 00308 $ AB( 1+IB, I+KD ), LDAB-1 ) 00309 * 00310 * Update A33 00311 * 00312 CALL SSYRK( 'Upper', 'Transpose', I3, IB, -ONE, 00313 $ WORK, LDWORK, ONE, AB( KD+1, I+KD ), 00314 $ LDAB-1 ) 00315 * 00316 * Copy the lower triangle of A13 back into place. 00317 * 00318 DO 60 JJ = 1, I3 00319 DO 50 II = JJ, IB 00320 AB( II-JJ+1, JJ+I+KD-1 ) = WORK( II, JJ ) 00321 50 CONTINUE 00322 60 CONTINUE 00323 END IF 00324 END IF 00325 70 CONTINUE 00326 ELSE 00327 * 00328 * Compute the Cholesky factorization of a symmetric band 00329 * matrix, given the lower triangle of the matrix in band 00330 * storage. 00331 * 00332 * Zero the lower triangle of the work array. 00333 * 00334 DO 90 J = 1, NB 00335 DO 80 I = J + 1, NB 00336 WORK( I, J ) = ZERO 00337 80 CONTINUE 00338 90 CONTINUE 00339 * 00340 * Process the band matrix one diagonal block at a time. 00341 * 00342 DO 140 I = 1, N, NB 00343 IB = MIN( NB, N-I+1 ) 00344 * 00345 * Factorize the diagonal block 00346 * 00347 CALL SPOTF2( UPLO, IB, AB( 1, I ), LDAB-1, II ) 00348 IF( II.NE.0 ) THEN 00349 INFO = I + II - 1 00350 GO TO 150 00351 END IF 00352 IF( I+IB.LE.N ) THEN 00353 * 00354 * Update the relevant part of the trailing submatrix. 00355 * If A11 denotes the diagonal block which has just been 00356 * factorized, then we need to update the remaining 00357 * blocks in the diagram: 00358 * 00359 * A11 00360 * A21 A22 00361 * A31 A32 A33 00362 * 00363 * The numbers of rows and columns in the partitioning 00364 * are IB, I2, I3 respectively. The blocks A21, A22 and 00365 * A32 are empty if IB = KD. The lower triangle of A31 00366 * lies outside the band. 00367 * 00368 I2 = MIN( KD-IB, N-I-IB+1 ) 00369 I3 = MIN( IB, N-I-KD+1 ) 00370 * 00371 IF( I2.GT.0 ) THEN 00372 * 00373 * Update A21 00374 * 00375 CALL STRSM( 'Right', 'Lower', 'Transpose', 00376 $ 'Non-unit', I2, IB, ONE, AB( 1, I ), 00377 $ LDAB-1, AB( 1+IB, I ), LDAB-1 ) 00378 * 00379 * Update A22 00380 * 00381 CALL SSYRK( 'Lower', 'No Transpose', I2, IB, -ONE, 00382 $ AB( 1+IB, I ), LDAB-1, ONE, 00383 $ AB( 1, I+IB ), LDAB-1 ) 00384 END IF 00385 * 00386 IF( I3.GT.0 ) THEN 00387 * 00388 * Copy the upper triangle of A31 into the work array. 00389 * 00390 DO 110 JJ = 1, IB 00391 DO 100 II = 1, MIN( JJ, I3 ) 00392 WORK( II, JJ ) = AB( KD+1-JJ+II, JJ+I-1 ) 00393 100 CONTINUE 00394 110 CONTINUE 00395 * 00396 * Update A31 (in the work array). 00397 * 00398 CALL STRSM( 'Right', 'Lower', 'Transpose', 00399 $ 'Non-unit', I3, IB, ONE, AB( 1, I ), 00400 $ LDAB-1, WORK, LDWORK ) 00401 * 00402 * Update A32 00403 * 00404 IF( I2.GT.0 ) 00405 $ CALL SGEMM( 'No transpose', 'Transpose', I3, I2, 00406 $ IB, -ONE, WORK, LDWORK, 00407 $ AB( 1+IB, I ), LDAB-1, ONE, 00408 $ AB( 1+KD-IB, I+IB ), LDAB-1 ) 00409 * 00410 * Update A33 00411 * 00412 CALL SSYRK( 'Lower', 'No Transpose', I3, IB, -ONE, 00413 $ WORK, LDWORK, ONE, AB( 1, I+KD ), 00414 $ LDAB-1 ) 00415 * 00416 * Copy the upper triangle of A31 back into place. 00417 * 00418 DO 130 JJ = 1, IB 00419 DO 120 II = 1, MIN( JJ, I3 ) 00420 AB( KD+1-JJ+II, JJ+I-1 ) = WORK( II, JJ ) 00421 120 CONTINUE 00422 130 CONTINUE 00423 END IF 00424 END IF 00425 140 CONTINUE 00426 END IF 00427 END IF 00428 RETURN 00429 * 00430 150 CONTINUE 00431 RETURN 00432 * 00433 * End of SPBTRF 00434 * 00435 END