LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
spbtrf.f
Go to the documentation of this file.
1*> \brief \b SPBTRF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SPBTRF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/spbtrf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/spbtrf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/spbtrf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SPBTRF( UPLO, N, KD, AB, LDAB, INFO )
20*
21* .. Scalar Arguments ..
22* CHARACTER UPLO
23* INTEGER INFO, KD, LDAB, N
24* ..
25* .. Array Arguments ..
26* REAL AB( LDAB, * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> SPBTRF computes the Cholesky factorization of a real symmetric
36*> positive definite band matrix A.
37*>
38*> The factorization has the form
39*> A = U**T * U, if UPLO = 'U', or
40*> A = L * L**T, if UPLO = 'L',
41*> where U is an upper triangular matrix and L is lower triangular.
42*> \endverbatim
43*
44* Arguments:
45* ==========
46*
47*> \param[in] UPLO
48*> \verbatim
49*> UPLO is CHARACTER*1
50*> = 'U': Upper triangle of A is stored;
51*> = 'L': Lower triangle of A is stored.
52*> \endverbatim
53*>
54*> \param[in] N
55*> \verbatim
56*> N is INTEGER
57*> The order of the matrix A. N >= 0.
58*> \endverbatim
59*>
60*> \param[in] KD
61*> \verbatim
62*> KD is INTEGER
63*> The number of superdiagonals of the matrix A if UPLO = 'U',
64*> or the number of subdiagonals if UPLO = 'L'. KD >= 0.
65*> \endverbatim
66*>
67*> \param[in,out] AB
68*> \verbatim
69*> AB is REAL array, dimension (LDAB,N)
70*> On entry, the upper or lower triangle of the symmetric band
71*> matrix A, stored in the first KD+1 rows of the array. The
72*> j-th column of A is stored in the j-th column of the array AB
73*> as follows:
74*> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
75*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
76*>
77*> On exit, if INFO = 0, the triangular factor U or L from the
78*> Cholesky factorization A = U**T*U or A = L*L**T of the band
79*> matrix A, in the same storage format as A.
80*> \endverbatim
81*>
82*> \param[in] LDAB
83*> \verbatim
84*> LDAB is INTEGER
85*> The leading dimension of the array AB. LDAB >= KD+1.
86*> \endverbatim
87*>
88*> \param[out] INFO
89*> \verbatim
90*> INFO is INTEGER
91*> = 0: successful exit
92*> < 0: if INFO = -i, the i-th argument had an illegal value
93*> > 0: if INFO = i, the leading principal minor of order i
94*> is not positive, and the factorization could not be
95*> completed.
96*> \endverbatim
97*
98* Authors:
99* ========
100*
101*> \author Univ. of Tennessee
102*> \author Univ. of California Berkeley
103*> \author Univ. of Colorado Denver
104*> \author NAG Ltd.
105*
106*> \ingroup pbtrf
107*
108*> \par Further Details:
109* =====================
110*>
111*> \verbatim
112*>
113*> The band storage scheme is illustrated by the following example, when
114*> N = 6, KD = 2, and UPLO = 'U':
115*>
116*> On entry: On exit:
117*>
118*> * * a13 a24 a35 a46 * * u13 u24 u35 u46
119*> * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
120*> a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
121*>
122*> Similarly, if UPLO = 'L' the format of A is as follows:
123*>
124*> On entry: On exit:
125*>
126*> a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
127*> a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
128*> a31 a42 a53 a64 * * l31 l42 l53 l64 * *
129*>
130*> Array elements marked * are not used by the routine.
131*> \endverbatim
132*
133*> \par Contributors:
134* ==================
135*>
136*> Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989
137*
138* =====================================================================
139 SUBROUTINE spbtrf( UPLO, N, KD, AB, LDAB, INFO )
140*
141* -- LAPACK computational routine --
142* -- LAPACK is a software package provided by Univ. of Tennessee, --
143* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
144*
145* .. Scalar Arguments ..
146 CHARACTER UPLO
147 INTEGER INFO, KD, LDAB, N
148* ..
149* .. Array Arguments ..
150 REAL AB( LDAB, * )
151* ..
152*
153* =====================================================================
154*
155* .. Parameters ..
156 REAL ONE, ZERO
157 parameter( one = 1.0e+0, zero = 0.0e+0 )
158 INTEGER NBMAX, LDWORK
159 parameter( nbmax = 32, ldwork = nbmax+1 )
160* ..
161* .. Local Scalars ..
162 INTEGER I, I2, I3, IB, II, J, JJ, NB
163* ..
164* .. Local Arrays ..
165 REAL WORK( LDWORK, NBMAX )
166* ..
167* .. External Functions ..
168 LOGICAL LSAME
169 INTEGER ILAENV
170 EXTERNAL lsame, ilaenv
171* ..
172* .. External Subroutines ..
173 EXTERNAL sgemm, spbtf2, spotf2, ssyrk, strsm,
174 $ xerbla
175* ..
176* .. Intrinsic Functions ..
177 INTRINSIC min
178* ..
179* .. Executable Statements ..
180*
181* Test the input parameters.
182*
183 info = 0
184 IF( ( .NOT.lsame( uplo, 'U' ) ) .AND.
185 $ ( .NOT.lsame( uplo, 'L' ) ) ) THEN
186 info = -1
187 ELSE IF( n.LT.0 ) THEN
188 info = -2
189 ELSE IF( kd.LT.0 ) THEN
190 info = -3
191 ELSE IF( ldab.LT.kd+1 ) THEN
192 info = -5
193 END IF
194 IF( info.NE.0 ) THEN
195 CALL xerbla( 'SPBTRF', -info )
196 RETURN
197 END IF
198*
199* Quick return if possible
200*
201 IF( n.EQ.0 )
202 $ RETURN
203*
204* Determine the block size for this environment
205*
206 nb = ilaenv( 1, 'SPBTRF', uplo, n, kd, -1, -1 )
207*
208* The block size must not exceed the semi-bandwidth KD, and must not
209* exceed the limit set by the size of the local array WORK.
210*
211 nb = min( nb, nbmax )
212*
213 IF( nb.LE.1 .OR. nb.GT.kd ) THEN
214*
215* Use unblocked code
216*
217 CALL spbtf2( uplo, n, kd, ab, ldab, info )
218 ELSE
219*
220* Use blocked code
221*
222 IF( lsame( uplo, 'U' ) ) THEN
223*
224* Compute the Cholesky factorization of a symmetric band
225* matrix, given the upper triangle of the matrix in band
226* storage.
227*
228* Zero the upper triangle of the work array.
229*
230 DO 20 j = 1, nb
231 DO 10 i = 1, j - 1
232 work( i, j ) = zero
233 10 CONTINUE
234 20 CONTINUE
235*
236* Process the band matrix one diagonal block at a time.
237*
238 DO 70 i = 1, n, nb
239 ib = min( nb, n-i+1 )
240*
241* Factorize the diagonal block
242*
243 CALL spotf2( uplo, ib, ab( kd+1, i ), ldab-1, ii )
244 IF( ii.NE.0 ) THEN
245 info = i + ii - 1
246 GO TO 150
247 END IF
248 IF( i+ib.LE.n ) THEN
249*
250* Update the relevant part of the trailing submatrix.
251* If A11 denotes the diagonal block which has just been
252* factorized, then we need to update the remaining
253* blocks in the diagram:
254*
255* A11 A12 A13
256* A22 A23
257* A33
258*
259* The numbers of rows and columns in the partitioning
260* are IB, I2, I3 respectively. The blocks A12, A22 and
261* A23 are empty if IB = KD. The upper triangle of A13
262* lies outside the band.
263*
264 i2 = min( kd-ib, n-i-ib+1 )
265 i3 = min( ib, n-i-kd+1 )
266*
267 IF( i2.GT.0 ) THEN
268*
269* Update A12
270*
271 CALL strsm( 'Left', 'Upper', 'Transpose',
272 $ 'Non-unit', ib, i2, one, ab( kd+1, i ),
273 $ ldab-1, ab( kd+1-ib, i+ib ), ldab-1 )
274*
275* Update A22
276*
277 CALL ssyrk( 'Upper', 'Transpose', i2, ib, -one,
278 $ ab( kd+1-ib, i+ib ), ldab-1, one,
279 $ ab( kd+1, i+ib ), ldab-1 )
280 END IF
281*
282 IF( i3.GT.0 ) THEN
283*
284* Copy the lower triangle of A13 into the work array.
285*
286 DO 40 jj = 1, i3
287 DO 30 ii = jj, ib
288 work( ii, jj ) = ab( ii-jj+1, jj+i+kd-1 )
289 30 CONTINUE
290 40 CONTINUE
291*
292* Update A13 (in the work array).
293*
294 CALL strsm( 'Left', 'Upper', 'Transpose',
295 $ 'Non-unit', ib, i3, one, ab( kd+1, i ),
296 $ ldab-1, work, ldwork )
297*
298* Update A23
299*
300 IF( i2.GT.0 )
301 $ CALL sgemm( 'Transpose', 'No Transpose', i2,
302 $ i3,
303 $ ib, -one, ab( kd+1-ib, i+ib ),
304 $ ldab-1, work, ldwork, one,
305 $ ab( 1+ib, i+kd ), ldab-1 )
306*
307* Update A33
308*
309 CALL ssyrk( 'Upper', 'Transpose', i3, ib, -one,
310 $ work, ldwork, one, ab( kd+1, i+kd ),
311 $ ldab-1 )
312*
313* Copy the lower triangle of A13 back into place.
314*
315 DO 60 jj = 1, i3
316 DO 50 ii = jj, ib
317 ab( ii-jj+1, jj+i+kd-1 ) = work( ii, jj )
318 50 CONTINUE
319 60 CONTINUE
320 END IF
321 END IF
322 70 CONTINUE
323 ELSE
324*
325* Compute the Cholesky factorization of a symmetric band
326* matrix, given the lower triangle of the matrix in band
327* storage.
328*
329* Zero the lower triangle of the work array.
330*
331 DO 90 j = 1, nb
332 DO 80 i = j + 1, nb
333 work( i, j ) = zero
334 80 CONTINUE
335 90 CONTINUE
336*
337* Process the band matrix one diagonal block at a time.
338*
339 DO 140 i = 1, n, nb
340 ib = min( nb, n-i+1 )
341*
342* Factorize the diagonal block
343*
344 CALL spotf2( uplo, ib, ab( 1, i ), ldab-1, ii )
345 IF( ii.NE.0 ) THEN
346 info = i + ii - 1
347 GO TO 150
348 END IF
349 IF( i+ib.LE.n ) THEN
350*
351* Update the relevant part of the trailing submatrix.
352* If A11 denotes the diagonal block which has just been
353* factorized, then we need to update the remaining
354* blocks in the diagram:
355*
356* A11
357* A21 A22
358* A31 A32 A33
359*
360* The numbers of rows and columns in the partitioning
361* are IB, I2, I3 respectively. The blocks A21, A22 and
362* A32 are empty if IB = KD. The lower triangle of A31
363* lies outside the band.
364*
365 i2 = min( kd-ib, n-i-ib+1 )
366 i3 = min( ib, n-i-kd+1 )
367*
368 IF( i2.GT.0 ) THEN
369*
370* Update A21
371*
372 CALL strsm( 'Right', 'Lower', 'Transpose',
373 $ 'Non-unit', i2, ib, one, ab( 1, i ),
374 $ ldab-1, ab( 1+ib, i ), ldab-1 )
375*
376* Update A22
377*
378 CALL ssyrk( 'Lower', 'No Transpose', i2, ib,
379 $ -one,
380 $ ab( 1+ib, i ), ldab-1, one,
381 $ ab( 1, i+ib ), ldab-1 )
382 END IF
383*
384 IF( i3.GT.0 ) THEN
385*
386* Copy the upper triangle of A31 into the work array.
387*
388 DO 110 jj = 1, ib
389 DO 100 ii = 1, min( jj, i3 )
390 work( ii, jj ) = ab( kd+1-jj+ii, jj+i-1 )
391 100 CONTINUE
392 110 CONTINUE
393*
394* Update A31 (in the work array).
395*
396 CALL strsm( 'Right', 'Lower', 'Transpose',
397 $ 'Non-unit', i3, ib, one, ab( 1, i ),
398 $ ldab-1, work, ldwork )
399*
400* Update A32
401*
402 IF( i2.GT.0 )
403 $ CALL sgemm( 'No transpose', 'Transpose', i3,
404 $ i2,
405 $ ib, -one, work, ldwork,
406 $ ab( 1+ib, i ), ldab-1, one,
407 $ ab( 1+kd-ib, i+ib ), ldab-1 )
408*
409* Update A33
410*
411 CALL ssyrk( 'Lower', 'No Transpose', i3, ib,
412 $ -one,
413 $ work, ldwork, one, ab( 1, i+kd ),
414 $ ldab-1 )
415*
416* Copy the upper triangle of A31 back into place.
417*
418 DO 130 jj = 1, ib
419 DO 120 ii = 1, min( jj, i3 )
420 ab( kd+1-jj+ii, jj+i-1 ) = work( ii, jj )
421 120 CONTINUE
422 130 CONTINUE
423 END IF
424 END IF
425 140 CONTINUE
426 END IF
427 END IF
428 RETURN
429*
430 150 CONTINUE
431 RETURN
432*
433* End of SPBTRF
434*
435 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
subroutine ssyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
SSYRK
Definition ssyrk.f:169
subroutine spbtf2(uplo, n, kd, ab, ldab, info)
SPBTF2 computes the Cholesky factorization of a symmetric/Hermitian positive definite band matrix (un...
Definition spbtf2.f:140
subroutine spbtrf(uplo, n, kd, ab, ldab, info)
SPBTRF
Definition spbtrf.f:140
subroutine spotf2(uplo, n, a, lda, info)
SPOTF2 computes the Cholesky factorization of a symmetric/Hermitian positive definite matrix (unblock...
Definition spotf2.f:107
subroutine strsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
STRSM
Definition strsm.f:181