KTH framework for Nek5000 toolboxes; testing version  0.0.1
dpbtrf.f
Go to the documentation of this file.
1  SUBROUTINE dpbtrf( 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 * March 31, 1993
7 *
8 * .. Scalar Arguments ..
9  CHARACTER UPLO
10  INTEGER INFO, KD, LDAB, N
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION AB( LDAB, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DPBTRF computes the Cholesky factorization of a real symmetric
20 * positive definite band matrix A.
21 *
22 * The factorization has the form
23 * A = U**T * U, if UPLO = 'U', or
24 * A = L * L**T, if UPLO = 'L',
25 * where U is an upper triangular matrix and L is lower triangular.
26 *
27 * Arguments
28 * =========
29 *
30 * UPLO (input) CHARACTER*1
31 * = 'U': Upper triangle of A is stored;
32 * = 'L': Lower triangle of A is stored.
33 *
34 * N (input) INTEGER
35 * The order of the matrix A. N >= 0.
36 *
37 * KD (input) INTEGER
38 * The number of superdiagonals of the matrix A if UPLO = 'U',
39 * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
40 *
41 * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
42 * On entry, the upper or lower triangle of the symmetric band
43 * matrix A, stored in the first KD+1 rows of the array. The
44 * j-th column of A is stored in the j-th column of the array AB
45 * as follows:
46 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
47 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
48 *
49 * On exit, if INFO = 0, the triangular factor U or L from the
50 * Cholesky factorization A = U**T*U or A = L*L**T of the band
51 * matrix A, in the same storage format as A.
52 *
53 * LDAB (input) INTEGER
54 * The leading dimension of the array AB. LDAB >= KD+1.
55 *
56 * INFO (output) INTEGER
57 * = 0: successful exit
58 * < 0: if INFO = -i, the i-th argument had an illegal value
59 * > 0: if INFO = i, the leading minor of order i is not
60 * positive definite, and the factorization could not be
61 * completed.
62 *
63 * Further Details
64 * ===============
65 *
66 * The band storage scheme is illustrated by the following example, when
67 * N = 6, KD = 2, and UPLO = 'U':
68 *
69 * On entry: On exit:
70 *
71 * * * a13 a24 a35 a46 * * u13 u24 u35 u46
72 * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
73 * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
74 *
75 * Similarly, if UPLO = 'L' the format of A is as follows:
76 *
77 * On entry: On exit:
78 *
79 * a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
80 * a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
81 * a31 a42 a53 a64 * * l31 l42 l53 l64 * *
82 *
83 * Array elements marked * are not used by the routine.
84 *
85 * Contributed by
86 * Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989
87 *
88 * =====================================================================
89 *
90 * .. Parameters ..
91  DOUBLE PRECISION ONE, ZERO
92  parameter( one = 1.0d+0, zero = 0.0d+0 )
93  INTEGER NBMAX, LDWORK
94  parameter( nbmax = 32, ldwork = nbmax+1 )
95 * ..
96 * .. Local Scalars ..
97  INTEGER I, I2, I3, IB, II, J, JJ, NB
98 * ..
99 * .. Local Arrays ..
100  DOUBLE PRECISION WORK( LDWORK, NBMAX )
101 * ..
102 * .. External Functions ..
103  LOGICAL LSAME
104  INTEGER ILAENV
105  EXTERNAL lsame, ilaenv
106 * ..
107 * .. External Subroutines ..
108  EXTERNAL dgemm, dpbtf2, dpotf2, dsyrk, dtrsm, xerbla
109 * ..
110 * .. Intrinsic Functions ..
111  INTRINSIC min
112 * ..
113 * .. Executable Statements ..
114 *
115 * Test the input parameters.
116 *
117  info = 0
118  IF( ( .NOT.lsame( uplo, 'U' ) ) .AND.
119  $ ( .NOT.lsame( uplo, 'L' ) ) ) THEN
120  info = -1
121  ELSE IF( n.LT.0 ) THEN
122  info = -2
123  ELSE IF( kd.LT.0 ) THEN
124  info = -3
125  ELSE IF( ldab.LT.kd+1 ) THEN
126  info = -5
127  END IF
128  IF( info.NE.0 ) THEN
129  CALL xerbla( 'DPBTRF', -info )
130  RETURN
131  END IF
132 *
133 * Quick return if possible
134 *
135  IF( n.EQ.0 )
136  $ RETURN
137 *
138 * Determine the block size for this environment
139 *
140  nb = ilaenv( 1, 'DPBTRF', uplo, n, kd, -1, -1 )
141 *
142 * The block size must not exceed the semi-bandwidth KD, and must not
143 * exceed the limit set by the size of the local array WORK.
144 *
145  nb = min( nb, nbmax )
146 *
147  IF( nb.LE.1 .OR. nb.GT.kd ) THEN
148 *
149 * Use unblocked code
150 *
151  CALL dpbtf2( uplo, n, kd, ab, ldab, info )
152  ELSE
153 *
154 * Use blocked code
155 *
156  IF( lsame( uplo, 'U' ) ) THEN
157 *
158 * Compute the Cholesky factorization of a symmetric band
159 * matrix, given the upper triangle of the matrix in band
160 * storage.
161 *
162 * Zero the upper triangle of the work array.
163 *
164  DO 20 j = 1, nb
165  DO 10 i = 1, j - 1
166  work( i, j ) = zero
167  10 CONTINUE
168  20 CONTINUE
169 *
170 * Process the band matrix one diagonal block at a time.
171 *
172  DO 70 i = 1, n, nb
173  ib = min( nb, n-i+1 )
174 *
175 * Factorize the diagonal block
176 *
177  CALL dpotf2( uplo, ib, ab( kd+1, i ), ldab-1, ii )
178  IF( ii.NE.0 ) THEN
179  info = i + ii - 1
180  GO TO 150
181  END IF
182  IF( i+ib.LE.n ) THEN
183 *
184 * Update the relevant part of the trailing submatrix.
185 * If A11 denotes the diagonal block which has just been
186 * factorized, then we need to update the remaining
187 * blocks in the diagram:
188 *
189 * A11 A12 A13
190 * A22 A23
191 * A33
192 *
193 * The numbers of rows and columns in the partitioning
194 * are IB, I2, I3 respectively. The blocks A12, A22 and
195 * A23 are empty if IB = KD. The upper triangle of A13
196 * lies outside the band.
197 *
198  i2 = min( kd-ib, n-i-ib+1 )
199  i3 = min( ib, n-i-kd+1 )
200 *
201  IF( i2.GT.0 ) THEN
202 *
203 * Update A12
204 *
205  CALL dtrsm( 'Left', 'Upper', 'Transpose',
206  $ 'Non-unit', ib, i2, one, ab( kd+1, i ),
207  $ ldab-1, ab( kd+1-ib, i+ib ), ldab-1 )
208 *
209 * Update A22
210 *
211  CALL dsyrk( 'Upper', 'Transpose', i2, ib, -one,
212  $ ab( kd+1-ib, i+ib ), ldab-1, one,
213  $ ab( kd+1, i+ib ), ldab-1 )
214  END IF
215 *
216  IF( i3.GT.0 ) THEN
217 *
218 * Copy the lower triangle of A13 into the work array.
219 *
220  DO 40 jj = 1, i3
221  DO 30 ii = jj, ib
222  work( ii, jj ) = ab( ii-jj+1, jj+i+kd-1 )
223  30 CONTINUE
224  40 CONTINUE
225 *
226 * Update A13 (in the work array).
227 *
228  CALL dtrsm( 'Left', 'Upper', 'Transpose',
229  $ 'Non-unit', ib, i3, one, ab( kd+1, i ),
230  $ ldab-1, work, ldwork )
231 *
232 * Update A23
233 *
234  IF( i2.GT.0 )
235  $ CALL dgemm( 'Transpose', 'No Transpose', i2, i3,
236  $ ib, -one, ab( kd+1-ib, i+ib ),
237  $ ldab-1, work, ldwork, one,
238  $ ab( 1+ib, i+kd ), ldab-1 )
239 *
240 * Update A33
241 *
242  CALL dsyrk( 'Upper', 'Transpose', i3, ib, -one,
243  $ work, ldwork, one, ab( kd+1, i+kd ),
244  $ ldab-1 )
245 *
246 * Copy the lower triangle of A13 back into place.
247 *
248  DO 60 jj = 1, i3
249  DO 50 ii = jj, ib
250  ab( ii-jj+1, jj+i+kd-1 ) = work( ii, jj )
251  50 CONTINUE
252  60 CONTINUE
253  END IF
254  END IF
255  70 CONTINUE
256  ELSE
257 *
258 * Compute the Cholesky factorization of a symmetric band
259 * matrix, given the lower triangle of the matrix in band
260 * storage.
261 *
262 * Zero the lower triangle of the work array.
263 *
264  DO 90 j = 1, nb
265  DO 80 i = j + 1, nb
266  work( i, j ) = zero
267  80 CONTINUE
268  90 CONTINUE
269 *
270 * Process the band matrix one diagonal block at a time.
271 *
272  DO 140 i = 1, n, nb
273  ib = min( nb, n-i+1 )
274 *
275 * Factorize the diagonal block
276 *
277  CALL dpotf2( uplo, ib, ab( 1, i ), ldab-1, ii )
278  IF( ii.NE.0 ) THEN
279  info = i + ii - 1
280  GO TO 150
281  END IF
282  IF( i+ib.LE.n ) THEN
283 *
284 * Update the relevant part of the trailing submatrix.
285 * If A11 denotes the diagonal block which has just been
286 * factorized, then we need to update the remaining
287 * blocks in the diagram:
288 *
289 * A11
290 * A21 A22
291 * A31 A32 A33
292 *
293 * The numbers of rows and columns in the partitioning
294 * are IB, I2, I3 respectively. The blocks A21, A22 and
295 * A32 are empty if IB = KD. The lower triangle of A31
296 * lies outside the band.
297 *
298  i2 = min( kd-ib, n-i-ib+1 )
299  i3 = min( ib, n-i-kd+1 )
300 *
301  IF( i2.GT.0 ) THEN
302 *
303 * Update A21
304 *
305  CALL dtrsm( 'Right', 'Lower', 'Transpose',
306  $ 'Non-unit', i2, ib, one, ab( 1, i ),
307  $ ldab-1, ab( 1+ib, i ), ldab-1 )
308 *
309 * Update A22
310 *
311  CALL dsyrk( 'Lower', 'No Transpose', i2, ib, -one,
312  $ ab( 1+ib, i ), ldab-1, one,
313  $ ab( 1, i+ib ), ldab-1 )
314  END IF
315 *
316  IF( i3.GT.0 ) THEN
317 *
318 * Copy the upper triangle of A31 into the work array.
319 *
320  DO 110 jj = 1, ib
321  DO 100 ii = 1, min( jj, i3 )
322  work( ii, jj ) = ab( kd+1-jj+ii, jj+i-1 )
323  100 CONTINUE
324  110 CONTINUE
325 *
326 * Update A31 (in the work array).
327 *
328  CALL dtrsm( 'Right', 'Lower', 'Transpose',
329  $ 'Non-unit', i3, ib, one, ab( 1, i ),
330  $ ldab-1, work, ldwork )
331 *
332 * Update A32
333 *
334  IF( i2.GT.0 )
335  $ CALL dgemm( 'No transpose', 'Transpose', i3, i2,
336  $ ib, -one, work, ldwork,
337  $ ab( 1+ib, i ), ldab-1, one,
338  $ ab( 1+kd-ib, i+ib ), ldab-1 )
339 *
340 * Update A33
341 *
342  CALL dsyrk( 'Lower', 'No Transpose', i3, ib, -one,
343  $ work, ldwork, one, ab( 1, i+kd ),
344  $ ldab-1 )
345 *
346 * Copy the upper triangle of A31 back into place.
347 *
348  DO 130 jj = 1, ib
349  DO 120 ii = 1, min( jj, i3 )
350  ab( kd+1-jj+ii, jj+i-1 ) = work( ii, jj )
351  120 CONTINUE
352  130 CONTINUE
353  END IF
354  END IF
355  140 CONTINUE
356  END IF
357  END IF
358  RETURN
359 *
360  150 CONTINUE
361  RETURN
362 *
363 * End of DPBTRF
364 *
365  END
subroutine dgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
Definition: dgemm.f:3
subroutine dpbtf2(UPLO, N, KD, AB, LDAB, INFO)
Definition: dpbtf2.f:2
subroutine dpbtrf(UPLO, N, KD, AB, LDAB, INFO)
Definition: dpbtrf.f:2
subroutine dpotf2(UPLO, N, A, LDA, INFO)
Definition: dpotf2.f:2
subroutine dsyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
Definition: dsyrk.f:3
subroutine dtrsm(SIDE, UPLO, TRANSA, DIAG, M, N, ALPHA, A, LDA, B, LDB)
Definition: dtrsm.f:3
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2