142
143
144
145
146
147
148 INTEGER INFO, KL, KU, LDAB, M, N
149
150
151 INTEGER IPIV( * )
152 COMPLEX*16 AB( LDAB, * )
153
154
155
156
157
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
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
170 COMPLEX*16 WORK13( LDWORK, NBMAX ),
171 $ WORK31( LDWORK, NBMAX )
172
173
174 INTEGER ILAENV, IZAMAX
176
177
181
182
183 INTRINSIC max, min
184
185
186
187
188
189
190 kv = ku + kl
191
192
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
212
213 IF( m.EQ.0 .OR. n.EQ.0 )
214 $ RETURN
215
216
217
218 nb =
ilaenv( 1,
'ZGBTRF',
' ', m, n, kl, ku )
219
220
221
222
223 nb = min( nb, nbmax )
224
225 IF( nb.LE.1 .OR. nb.GT.kl ) THEN
226
227
228
229 CALL zgbtf2( m, n, kl, ku, ab, ldab, ipiv, info )
230 ELSE
231
232
233
234
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
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
251
252
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
261
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
269
270
271
272
273
274
275
276
277
278
279
280 i2 = min( kl-jb, m-j-jb+1 )
281 i3 = min( jb, m-j-kl+1 )
282
283
284
285
286
287 DO 80 jj = j, j + jb - 1
288
289
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
298
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
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
316
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
326
327 CALL zscal( km, one / ab( kv+1, jj ), ab( kv+2,
328 $ jj ),
329 $ 1 )
330
331
332
333
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
343
344
345 IF( info.EQ.0 )
346 $ info = jj
347 END IF
348
349
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
359
360 j2 = min( ju-j+1, kv ) - jb
361 j3 = max( 0, ju-j-kv+1 )
362
363
364
365
366 CALL zlaswp( j2, ab( kv+1-jb, j+jb ), ldab-1, 1, jb,
367 $ ipiv( j ), 1 )
368
369
370
371 DO 90 i = j, j + jb - 1
372 ipiv( i ) = ipiv( i ) + j - 1
373 90 CONTINUE
374
375
376
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
392
393 IF( j2.GT.0 ) THEN
394
395
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
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
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
428
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
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
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
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
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
475
476 DO 160 i = j, j + jb - 1
477 ipiv( i ) = ipiv( i ) + j - 1
478 160 CONTINUE
479 END IF
480
481
482
483
484
485 DO 170 jj = j + jb - 1, j, -1
486 jp = ipiv( jj ) - jj + 1
487 IF( jp.NE.1 ) THEN
488
489
490
491 IF( jp+jj-1.LT.j+kl ) THEN
492
493
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
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
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
519
subroutine xerbla(srname, info)
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
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...
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zgeru(m, n, alpha, x, incx, y, incy, a, lda)
ZGERU
integer function izamax(n, zx, incx)
IZAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine zlaswp(n, a, lda, k1, k2, ipiv, incx)
ZLASWP performs a series of row interchanges on a general rectangular matrix.
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
subroutine ztrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRSM