LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zgbtrf.f
Go to the documentation of this file.
1*> \brief \b ZGBTRF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZGBTRF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgbtrf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgbtrf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgbtrf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZGBTRF( M, N, KL, KU, AB, LDAB, IPIV, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, KL, KU, LDAB, M, N
23* ..
24* .. Array Arguments ..
25* INTEGER IPIV( * )
26* COMPLEX*16 AB( LDAB, * )
27* ..
28*
29*
30*> \par Purpose:
31* =============
32*>
33*> \verbatim
34*>
35*> ZGBTRF computes an LU factorization of a complex m-by-n band matrix A
36*> using partial pivoting with row interchanges.
37*>
38*> This is the blocked version of the algorithm, calling Level 3 BLAS.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] M
45*> \verbatim
46*> M is INTEGER
47*> The number of rows of the matrix A. M >= 0.
48*> \endverbatim
49*>
50*> \param[in] N
51*> \verbatim
52*> N is INTEGER
53*> The number of columns of the matrix A. N >= 0.
54*> \endverbatim
55*>
56*> \param[in] KL
57*> \verbatim
58*> KL is INTEGER
59*> The number of subdiagonals within the band of A. KL >= 0.
60*> \endverbatim
61*>
62*> \param[in] KU
63*> \verbatim
64*> KU is INTEGER
65*> The number of superdiagonals within the band of A. KU >= 0.
66*> \endverbatim
67*>
68*> \param[in,out] AB
69*> \verbatim
70*> AB is COMPLEX*16 array, dimension (LDAB,N)
71*> On entry, the matrix A in band storage, in rows KL+1 to
72*> 2*KL+KU+1; rows 1 to KL of the array need not be set.
73*> The j-th column of A is stored in the j-th column of the
74*> array AB as follows:
75*> AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl)
76*>
77*> On exit, details of the factorization: U is stored as an
78*> upper triangular band matrix with KL+KU superdiagonals in
79*> rows 1 to KL+KU+1, and the multipliers used during the
80*> factorization are stored in rows KL+KU+2 to 2*KL+KU+1.
81*> See below for further details.
82*> \endverbatim
83*>
84*> \param[in] LDAB
85*> \verbatim
86*> LDAB is INTEGER
87*> The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
88*> \endverbatim
89*>
90*> \param[out] IPIV
91*> \verbatim
92*> IPIV is INTEGER array, dimension (min(M,N))
93*> The pivot indices; for 1 <= i <= min(M,N), row i of the
94*> matrix was interchanged with row IPIV(i).
95*> \endverbatim
96*>
97*> \param[out] INFO
98*> \verbatim
99*> INFO is INTEGER
100*> = 0: successful exit
101*> < 0: if INFO = -i, the i-th argument had an illegal value
102*> > 0: if INFO = +i, U(i,i) is exactly zero. The factorization
103*> has been completed, but the factor U is exactly
104*> singular, and division by zero will occur if it is used
105*> to solve a system of equations.
106*> \endverbatim
107*
108* Authors:
109* ========
110*
111*> \author Univ. of Tennessee
112*> \author Univ. of California Berkeley
113*> \author Univ. of Colorado Denver
114*> \author NAG Ltd.
115*
116*> \ingroup gbtrf
117*
118*> \par Further Details:
119* =====================
120*>
121*> \verbatim
122*>
123*> The band storage scheme is illustrated by the following example, when
124*> M = N = 6, KL = 2, KU = 1:
125*>
126*> On entry: On exit:
127*>
128*> * * * + + + * * * u14 u25 u36
129*> * * + + + + * * u13 u24 u35 u46
130*> * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
131*> a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
132*> a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 *
133*> a31 a42 a53 a64 * * m31 m42 m53 m64 * *
134*>
135*> Array elements marked * are not used by the routine; elements marked
136*> + need not be set on entry, but are required by the routine to store
137*> elements of U because of fill-in resulting from the row interchanges.
138*> \endverbatim
139*>
140* =====================================================================
141 SUBROUTINE zgbtrf( M, N, KL, KU, AB, LDAB, IPIV, INFO )
142*
143* -- LAPACK computational routine --
144* -- LAPACK is a software package provided by Univ. of Tennessee, --
145* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146*
147* .. Scalar Arguments ..
148 INTEGER INFO, KL, KU, LDAB, M, N
149* ..
150* .. Array Arguments ..
151 INTEGER IPIV( * )
152 COMPLEX*16 AB( LDAB, * )
153* ..
154*
155* =====================================================================
156*
157* .. Parameters ..
158 COMPLEX*16 ONE, ZERO
159 parameter( one = ( 1.0d+0, 0.0d+0 ),
160 $ zero = ( 0.0d+0, 0.0d+0 ) )
161 INTEGER NBMAX, LDWORK
162 parameter( nbmax = 64, ldwork = nbmax+1 )
163* ..
164* .. Local Scalars ..
165 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
166 $ JU, K2, KM, KV, NB, NW
167 COMPLEX*16 TEMP
168* ..
169* .. Local Arrays ..
170 COMPLEX*16 WORK13( LDWORK, NBMAX ),
171 $ WORK31( LDWORK, NBMAX )
172* ..
173* .. External Functions ..
174 INTEGER ILAENV, IZAMAX
175 EXTERNAL ilaenv, izamax
176* ..
177* .. External Subroutines ..
178 EXTERNAL xerbla, zcopy, zgbtf2, zgemm, zgeru,
179 $ zlaswp,
180 $ zscal, zswap, ztrsm
181* ..
182* .. Intrinsic Functions ..
183 INTRINSIC max, min
184* ..
185* .. Executable Statements ..
186*
187* KV is the number of superdiagonals in the factor U, allowing for
188* fill-in
189*
190 kv = ku + kl
191*
192* Test the input parameters.
193*
194 info = 0
195 IF( m.LT.0 ) THEN
196 info = -1
197 ELSE IF( n.LT.0 ) THEN
198 info = -2
199 ELSE IF( kl.LT.0 ) THEN
200 info = -3
201 ELSE IF( ku.LT.0 ) THEN
202 info = -4
203 ELSE IF( ldab.LT.kl+kv+1 ) THEN
204 info = -6
205 END IF
206 IF( info.NE.0 ) THEN
207 CALL xerbla( 'ZGBTRF', -info )
208 RETURN
209 END IF
210*
211* Quick return if possible
212*
213 IF( m.EQ.0 .OR. n.EQ.0 )
214 $ RETURN
215*
216* Determine the block size for this environment
217*
218 nb = ilaenv( 1, 'ZGBTRF', ' ', m, n, kl, ku )
219*
220* The block size must not exceed the limit set by the size of the
221* local arrays WORK13 and WORK31.
222*
223 nb = min( nb, nbmax )
224*
225 IF( nb.LE.1 .OR. nb.GT.kl ) THEN
226*
227* Use unblocked code
228*
229 CALL zgbtf2( m, n, kl, ku, ab, ldab, ipiv, info )
230 ELSE
231*
232* Use blocked code
233*
234* Zero the superdiagonal elements of the work array WORK13
235*
236 DO 20 j = 1, nb
237 DO 10 i = 1, j - 1
238 work13( i, j ) = zero
239 10 CONTINUE
240 20 CONTINUE
241*
242* Zero the subdiagonal elements of the work array WORK31
243*
244 DO 40 j = 1, nb
245 DO 30 i = j + 1, nb
246 work31( i, j ) = zero
247 30 CONTINUE
248 40 CONTINUE
249*
250* Gaussian elimination with partial pivoting
251*
252* Set fill-in elements in columns KU+2 to KV to zero
253*
254 DO 60 j = ku + 2, min( kv, n )
255 DO 50 i = kv - j + 2, kl
256 ab( i, j ) = zero
257 50 CONTINUE
258 60 CONTINUE
259*
260* JU is the index of the last column affected by the current
261* stage of the factorization
262*
263 ju = 1
264*
265 DO 180 j = 1, min( m, n ), nb
266 jb = min( nb, min( m, n )-j+1 )
267*
268* The active part of the matrix is partitioned
269*
270* A11 A12 A13
271* A21 A22 A23
272* A31 A32 A33
273*
274* Here A11, A21 and A31 denote the current block of JB columns
275* which is about to be factorized. The number of rows in the
276* partitioning are JB, I2, I3 respectively, and the numbers
277* of columns are JB, J2, J3. The superdiagonal elements of A13
278* and the subdiagonal elements of A31 lie outside the band.
279*
280 i2 = min( kl-jb, m-j-jb+1 )
281 i3 = min( jb, m-j-kl+1 )
282*
283* J2 and J3 are computed after JU has been updated.
284*
285* Factorize the current block of JB columns
286*
287 DO 80 jj = j, j + jb - 1
288*
289* Set fill-in elements in column JJ+KV to zero
290*
291 IF( jj+kv.LE.n ) THEN
292 DO 70 i = 1, kl
293 ab( i, jj+kv ) = zero
294 70 CONTINUE
295 END IF
296*
297* Find pivot and test for singularity. KM is the number of
298* subdiagonal elements in the current column.
299*
300 km = min( kl, m-jj )
301 jp = izamax( km+1, ab( kv+1, jj ), 1 )
302 ipiv( jj ) = jp + jj - j
303 IF( ab( kv+jp, jj ).NE.zero ) THEN
304 ju = max( ju, min( jj+ku+jp-1, n ) )
305 IF( jp.NE.1 ) THEN
306*
307* Apply interchange to columns J to J+JB-1
308*
309 IF( jp+jj-1.LT.j+kl ) THEN
310*
311 CALL zswap( jb, ab( kv+1+jj-j, j ), ldab-1,
312 $ ab( kv+jp+jj-j, j ), ldab-1 )
313 ELSE
314*
315* The interchange affects columns J to JJ-1 of A31
316* which are stored in the work array WORK31
317*
318 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
319 $ work31( jp+jj-j-kl, 1 ), ldwork )
320 CALL zswap( j+jb-jj, ab( kv+1, jj ), ldab-1,
321 $ ab( kv+jp, jj ), ldab-1 )
322 END IF
323 END IF
324*
325* Compute multipliers
326*
327 CALL zscal( km, one / ab( kv+1, jj ), ab( kv+2,
328 $ jj ),
329 $ 1 )
330*
331* Update trailing submatrix within the band and within
332* the current block. JM is the index of the last column
333* which needs to be updated.
334*
335 jm = min( ju, j+jb-1 )
336 IF( jm.GT.jj )
337 $ CALL zgeru( km, jm-jj, -one, ab( kv+2, jj ), 1,
338 $ ab( kv, jj+1 ), ldab-1,
339 $ ab( kv+1, jj+1 ), ldab-1 )
340 ELSE
341*
342* If pivot is zero, set INFO to the index of the pivot
343* unless a zero pivot has already been found.
344*
345 IF( info.EQ.0 )
346 $ info = jj
347 END IF
348*
349* Copy current column of A31 into the work array WORK31
350*
351 nw = min( jj-j+1, i3 )
352 IF( nw.GT.0 )
353 $ CALL zcopy( nw, ab( kv+kl+1-jj+j, jj ), 1,
354 $ work31( 1, jj-j+1 ), 1 )
355 80 CONTINUE
356 IF( j+jb.LE.n ) THEN
357*
358* Apply the row interchanges to the other blocks.
359*
360 j2 = min( ju-j+1, kv ) - jb
361 j3 = max( 0, ju-j-kv+1 )
362*
363* Use ZLASWP to apply the row interchanges to A12, A22, and
364* A32.
365*
366 CALL zlaswp( j2, ab( kv+1-jb, j+jb ), ldab-1, 1, jb,
367 $ ipiv( j ), 1 )
368*
369* Adjust the pivot indices.
370*
371 DO 90 i = j, j + jb - 1
372 ipiv( i ) = ipiv( i ) + j - 1
373 90 CONTINUE
374*
375* Apply the row interchanges to A13, A23, and A33
376* columnwise.
377*
378 k2 = j - 1 + jb + j2
379 DO 110 i = 1, j3
380 jj = k2 + i
381 DO 100 ii = j + i - 1, j + jb - 1
382 ip = ipiv( ii )
383 IF( ip.NE.ii ) THEN
384 temp = ab( kv+1+ii-jj, jj )
385 ab( kv+1+ii-jj, jj ) = ab( kv+1+ip-jj, jj )
386 ab( kv+1+ip-jj, jj ) = temp
387 END IF
388 100 CONTINUE
389 110 CONTINUE
390*
391* Update the relevant part of the trailing submatrix
392*
393 IF( j2.GT.0 ) THEN
394*
395* Update A12
396*
397 CALL ztrsm( 'Left', 'Lower', 'No transpose',
398 $ 'Unit',
399 $ jb, j2, one, ab( kv+1, j ), ldab-1,
400 $ ab( kv+1-jb, j+jb ), ldab-1 )
401*
402 IF( i2.GT.0 ) THEN
403*
404* Update A22
405*
406 CALL zgemm( 'No transpose', 'No transpose', i2,
407 $ j2,
408 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
409 $ ab( kv+1-jb, j+jb ), ldab-1, one,
410 $ ab( kv+1, j+jb ), ldab-1 )
411 END IF
412*
413 IF( i3.GT.0 ) THEN
414*
415* Update A32
416*
417 CALL zgemm( 'No transpose', 'No transpose', i3,
418 $ j2,
419 $ jb, -one, work31, ldwork,
420 $ ab( kv+1-jb, j+jb ), ldab-1, one,
421 $ ab( kv+kl+1-jb, j+jb ), ldab-1 )
422 END IF
423 END IF
424*
425 IF( j3.GT.0 ) THEN
426*
427* Copy the lower triangle of A13 into the work array
428* WORK13
429*
430 DO 130 jj = 1, j3
431 DO 120 ii = jj, jb
432 work13( ii, jj ) = ab( ii-jj+1, jj+j+kv-1 )
433 120 CONTINUE
434 130 CONTINUE
435*
436* Update A13 in the work array
437*
438 CALL ztrsm( 'Left', 'Lower', 'No transpose',
439 $ 'Unit',
440 $ jb, j3, one, ab( kv+1, j ), ldab-1,
441 $ work13, ldwork )
442*
443 IF( i2.GT.0 ) THEN
444*
445* Update A23
446*
447 CALL zgemm( 'No transpose', 'No transpose', i2,
448 $ j3,
449 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
450 $ work13, ldwork, one, ab( 1+jb, j+kv ),
451 $ ldab-1 )
452 END IF
453*
454 IF( i3.GT.0 ) THEN
455*
456* Update A33
457*
458 CALL zgemm( 'No transpose', 'No transpose', i3,
459 $ j3,
460 $ jb, -one, work31, ldwork, work13,
461 $ ldwork, one, ab( 1+kl, j+kv ), ldab-1 )
462 END IF
463*
464* Copy the lower triangle of A13 back into place
465*
466 DO 150 jj = 1, j3
467 DO 140 ii = jj, jb
468 ab( ii-jj+1, jj+j+kv-1 ) = work13( ii, jj )
469 140 CONTINUE
470 150 CONTINUE
471 END IF
472 ELSE
473*
474* Adjust the pivot indices.
475*
476 DO 160 i = j, j + jb - 1
477 ipiv( i ) = ipiv( i ) + j - 1
478 160 CONTINUE
479 END IF
480*
481* Partially undo the interchanges in the current block to
482* restore the upper triangular form of A31 and copy the upper
483* triangle of A31 back into place
484*
485 DO 170 jj = j + jb - 1, j, -1
486 jp = ipiv( jj ) - jj + 1
487 IF( jp.NE.1 ) THEN
488*
489* Apply interchange to columns J to JJ-1
490*
491 IF( jp+jj-1.LT.j+kl ) THEN
492*
493* The interchange does not affect A31
494*
495 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
496 $ ab( kv+jp+jj-j, j ), ldab-1 )
497 ELSE
498*
499* The interchange does affect A31
500*
501 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
502 $ work31( jp+jj-j-kl, 1 ), ldwork )
503 END IF
504 END IF
505*
506* Copy the current column of A31 back into place
507*
508 nw = min( i3, jj-j+1 )
509 IF( nw.GT.0 )
510 $ CALL zcopy( nw, work31( 1, jj-j+1 ), 1,
511 $ ab( kv+kl+1-jj+j, jj ), 1 )
512 170 CONTINUE
513 180 CONTINUE
514 END IF
515*
516 RETURN
517*
518* End of ZGBTRF
519*
520 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
Definition zcopy.f:81
subroutine zgbtf2(m, n, kl, ku, ab, ldab, ipiv, info)
ZGBTF2 computes the LU factorization of a general band matrix using the unblocked version of the algo...
Definition zgbtf2.f:143
subroutine zgbtrf(m, n, kl, ku, ab, ldab, ipiv, info)
ZGBTRF
Definition zgbtrf.f:142
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
Definition zgemm.f:188
subroutine zgeru(m, n, alpha, x, incx, y, incy, a, lda)
ZGERU
Definition zgeru.f:130
subroutine zlaswp(n, a, lda, k1, k2, ipiv, incx)
ZLASWP performs a series of row interchanges on a general rectangular matrix.
Definition zlaswp.f:113
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
Definition zswap.f:81
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM
Definition ztrsm.f:180