144
145
146
147
148
149
150 INTEGER INFO, KL, KU, LDAB, M, N
151
152
153 INTEGER IPIV( * )
154 COMPLEX*16 AB( LDAB, * )
155
156
157
158
159
160 COMPLEX*16 ONE, ZERO
161 parameter( one = ( 1.0d+0, 0.0d+0 ),
162 $ zero = ( 0.0d+0, 0.0d+0 ) )
163 INTEGER NBMAX, LDWORK
164 parameter( nbmax = 64, ldwork = nbmax+1 )
165
166
167 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
168 $ JU, K2, KM, KV, NB, NW
169 COMPLEX*16 TEMP
170
171
172 COMPLEX*16 WORK13( LDWORK, NBMAX ),
173 $ WORK31( LDWORK, NBMAX )
174
175
176 INTEGER ILAENV, IZAMAX
178
179
182
183
184 INTRINSIC max, min
185
186
187
188
189
190
191 kv = ku + kl
192
193
194
195 info = 0
196 IF( m.LT.0 ) THEN
197 info = -1
198 ELSE IF( n.LT.0 ) THEN
199 info = -2
200 ELSE IF( kl.LT.0 ) THEN
201 info = -3
202 ELSE IF( ku.LT.0 ) THEN
203 info = -4
204 ELSE IF( ldab.LT.kl+kv+1 ) THEN
205 info = -6
206 END IF
207 IF( info.NE.0 ) THEN
208 CALL xerbla(
'ZGBTRF', -info )
209 RETURN
210 END IF
211
212
213
214 IF( m.EQ.0 .OR. n.EQ.0 )
215 $ RETURN
216
217
218
219 nb =
ilaenv( 1,
'ZGBTRF',
' ', m, n, kl, ku )
220
221
222
223
224 nb = min( nb, nbmax )
225
226 IF( nb.LE.1 .OR. nb.GT.kl ) THEN
227
228
229
230 CALL zgbtf2( m, n, kl, ku, ab, ldab, ipiv, info )
231 ELSE
232
233
234
235
236
237 DO 20 j = 1, nb
238 DO 10 i = 1, j - 1
239 work13( i, j ) = zero
240 10 CONTINUE
241 20 CONTINUE
242
243
244
245 DO 40 j = 1, nb
246 DO 30 i = j + 1, nb
247 work31( i, j ) = zero
248 30 CONTINUE
249 40 CONTINUE
250
251
252
253
254
255 DO 60 j = ku + 2, min( kv, n )
256 DO 50 i = kv - j + 2, kl
257 ab( i, j ) = zero
258 50 CONTINUE
259 60 CONTINUE
260
261
262
263
264 ju = 1
265
266 DO 180 j = 1, min( m, n ), nb
267 jb = min( nb, min( m, n )-j+1 )
268
269
270
271
272
273
274
275
276
277
278
279
280
281 i2 = min( kl-jb, m-j-jb+1 )
282 i3 = min( jb, m-j-kl+1 )
283
284
285
286
287
288 DO 80 jj = j, j + jb - 1
289
290
291
292 IF( jj+kv.LE.n ) THEN
293 DO 70 i = 1, kl
294 ab( i, jj+kv ) = zero
295 70 CONTINUE
296 END IF
297
298
299
300
301 km = min( kl, m-jj )
302 jp =
izamax( km+1, ab( kv+1, jj ), 1 )
303 ipiv( jj ) = jp + jj - j
304 IF( ab( kv+jp, jj ).NE.zero ) THEN
305 ju = max( ju, min( jj+ku+jp-1, n ) )
306 IF( jp.NE.1 ) THEN
307
308
309
310 IF( jp+jj-1.LT.j+kl ) THEN
311
312 CALL zswap( jb, ab( kv+1+jj-j, j ), ldab-1,
313 $ ab( kv+jp+jj-j, j ), ldab-1 )
314 ELSE
315
316
317
318
319 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
320 $ work31( jp+jj-j-kl, 1 ), ldwork )
321 CALL zswap( j+jb-jj, ab( kv+1, jj ), ldab-1,
322 $ ab( kv+jp, jj ), ldab-1 )
323 END IF
324 END IF
325
326
327
328 CALL zscal( km, one / ab( kv+1, jj ), ab( kv+2, 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',
'Unit',
398 $ jb, j2, one, ab( kv+1, j ), ldab-1,
399 $ ab( kv+1-jb, j+jb ), ldab-1 )
400
401 IF( i2.GT.0 ) THEN
402
403
404
405 CALL zgemm(
'No transpose',
'No transpose', i2, j2,
406 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
407 $ ab( kv+1-jb, j+jb ), ldab-1, one,
408 $ ab( kv+1, j+jb ), ldab-1 )
409 END IF
410
411 IF( i3.GT.0 ) THEN
412
413
414
415 CALL zgemm(
'No transpose',
'No transpose', i3, j2,
416 $ jb, -one, work31, ldwork,
417 $ ab( kv+1-jb, j+jb ), ldab-1, one,
418 $ ab( kv+kl+1-jb, j+jb ), ldab-1 )
419 END IF
420 END IF
421
422 IF( j3.GT.0 ) THEN
423
424
425
426
427 DO 130 jj = 1, j3
428 DO 120 ii = jj, jb
429 work13( ii, jj ) = ab( ii-jj+1, jj+j+kv-1 )
430 120 CONTINUE
431 130 CONTINUE
432
433
434
435 CALL ztrsm(
'Left',
'Lower',
'No transpose',
'Unit',
436 $ jb, j3, one, ab( kv+1, j ), ldab-1,
437 $ work13, ldwork )
438
439 IF( i2.GT.0 ) THEN
440
441
442
443 CALL zgemm(
'No transpose',
'No transpose', i2, j3,
444 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
445 $ work13, ldwork, one, ab( 1+jb, j+kv ),
446 $ ldab-1 )
447 END IF
448
449 IF( i3.GT.0 ) THEN
450
451
452
453 CALL zgemm(
'No transpose',
'No transpose', i3, j3,
454 $ jb, -one, work31, ldwork, work13,
455 $ ldwork, one, ab( 1+kl, j+kv ), ldab-1 )
456 END IF
457
458
459
460 DO 150 jj = 1, j3
461 DO 140 ii = jj, jb
462 ab( ii-jj+1, jj+j+kv-1 ) = work13( ii, jj )
463 140 CONTINUE
464 150 CONTINUE
465 END IF
466 ELSE
467
468
469
470 DO 160 i = j, j + jb - 1
471 ipiv( i ) = ipiv( i ) + j - 1
472 160 CONTINUE
473 END IF
474
475
476
477
478
479 DO 170 jj = j + jb - 1, j, -1
480 jp = ipiv( jj ) - jj + 1
481 IF( jp.NE.1 ) THEN
482
483
484
485 IF( jp+jj-1.LT.j+kl ) THEN
486
487
488
489 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
490 $ ab( kv+jp+jj-j, j ), ldab-1 )
491 ELSE
492
493
494
495 CALL zswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
496 $ work31( jp+jj-j-kl, 1 ), ldwork )
497 END IF
498 END IF
499
500
501
502 nw = min( i3, jj-j+1 )
503 IF( nw.GT.0 )
504 $
CALL zcopy( nw, work31( 1, jj-j+1 ), 1,
505 $ ab( kv+kl+1-jj+j, jj ), 1 )
506 170 CONTINUE
507 180 CONTINUE
508 END IF
509
510 RETURN
511
512
513
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