144
145
146
147
148
149
150 INTEGER INFO, KL, KU, LDAB, M, N
151
152
153 INTEGER IPIV( * )
154 DOUBLE PRECISION AB( LDAB, * )
155
156
157
158
159
160 DOUBLE PRECISION ONE, ZERO
161 parameter( one = 1.0d+0, zero = 0.0d+0 )
162 INTEGER NBMAX, LDWORK
163 parameter( nbmax = 64, ldwork = nbmax+1 )
164
165
166 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
167 $ JU, K2, KM, KV, NB, NW
168 DOUBLE PRECISION TEMP
169
170
171 DOUBLE PRECISION WORK13( LDWORK, NBMAX ),
172 $ WORK31( LDWORK, NBMAX )
173
174
175 INTEGER IDAMAX, ILAENV
177
178
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(
'DGBTRF', -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,
'DGBTRF',
' ', 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 dgbtf2( 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 =
idamax( 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 dswap( 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 dswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
319 $ work31( jp+jj-j-kl, 1 ), ldwork )
320 CALL dswap( 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 dscal( km, one / ab( kv+1, jj ), ab( kv+2, jj ),
328 $ 1 )
329
330
331
332
333
334 jm = min( ju, j+jb-1 )
335 IF( jm.GT.jj )
336 $
CALL dger( km, jm-jj, -one, ab( kv+2, jj ), 1,
337 $ ab( kv, jj+1 ), ldab-1,
338 $ ab( kv+1, jj+1 ), ldab-1 )
339 ELSE
340
341
342
343
344 IF( info.EQ.0 )
345 $ info = jj
346 END IF
347
348
349
350 nw = min( jj-j+1, i3 )
351 IF( nw.GT.0 )
352 $
CALL dcopy( nw, ab( kv+kl+1-jj+j, jj ), 1,
353 $ work31( 1, jj-j+1 ), 1 )
354 80 CONTINUE
355 IF( j+jb.LE.n ) THEN
356
357
358
359 j2 = min( ju-j+1, kv ) - jb
360 j3 = max( 0, ju-j-kv+1 )
361
362
363
364
365 CALL dlaswp( j2, ab( kv+1-jb, j+jb ), ldab-1, 1, jb,
366 $ ipiv( j ), 1 )
367
368
369
370 DO 90 i = j, j + jb - 1
371 ipiv( i ) = ipiv( i ) + j - 1
372 90 CONTINUE
373
374
375
376
377 k2 = j - 1 + jb + j2
378 DO 110 i = 1, j3
379 jj = k2 + i
380 DO 100 ii = j + i - 1, j + jb - 1
381 ip = ipiv( ii )
382 IF( ip.NE.ii ) THEN
383 temp = ab( kv+1+ii-jj, jj )
384 ab( kv+1+ii-jj, jj ) = ab( kv+1+ip-jj, jj )
385 ab( kv+1+ip-jj, jj ) = temp
386 END IF
387 100 CONTINUE
388 110 CONTINUE
389
390
391
392 IF( j2.GT.0 ) THEN
393
394
395
396 CALL dtrsm(
'Left',
'Lower',
'No transpose',
'Unit',
397 $ jb, j2, one, ab( kv+1, j ), ldab-1,
398 $ ab( kv+1-jb, j+jb ), ldab-1 )
399
400 IF( i2.GT.0 ) THEN
401
402
403
404 CALL dgemm(
'No transpose',
'No transpose', i2, j2,
405 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
406 $ ab( kv+1-jb, j+jb ), ldab-1, one,
407 $ ab( kv+1, j+jb ), ldab-1 )
408 END IF
409
410 IF( i3.GT.0 ) THEN
411
412
413
414 CALL dgemm(
'No transpose',
'No transpose', i3, j2,
415 $ jb, -one, work31, ldwork,
416 $ ab( kv+1-jb, j+jb ), ldab-1, one,
417 $ ab( kv+kl+1-jb, j+jb ), ldab-1 )
418 END IF
419 END IF
420
421 IF( j3.GT.0 ) THEN
422
423
424
425
426 DO 130 jj = 1, j3
427 DO 120 ii = jj, jb
428 work13( ii, jj ) = ab( ii-jj+1, jj+j+kv-1 )
429 120 CONTINUE
430 130 CONTINUE
431
432
433
434 CALL dtrsm(
'Left',
'Lower',
'No transpose',
'Unit',
435 $ jb, j3, one, ab( kv+1, j ), ldab-1,
436 $ work13, ldwork )
437
438 IF( i2.GT.0 ) THEN
439
440
441
442 CALL dgemm(
'No transpose',
'No transpose', i2, j3,
443 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
444 $ work13, ldwork, one, ab( 1+jb, j+kv ),
445 $ ldab-1 )
446 END IF
447
448 IF( i3.GT.0 ) THEN
449
450
451
452 CALL dgemm(
'No transpose',
'No transpose', i3, j3,
453 $ jb, -one, work31, ldwork, work13,
454 $ ldwork, one, ab( 1+kl, j+kv ), ldab-1 )
455 END IF
456
457
458
459 DO 150 jj = 1, j3
460 DO 140 ii = jj, jb
461 ab( ii-jj+1, jj+j+kv-1 ) = work13( ii, jj )
462 140 CONTINUE
463 150 CONTINUE
464 END IF
465 ELSE
466
467
468
469 DO 160 i = j, j + jb - 1
470 ipiv( i ) = ipiv( i ) + j - 1
471 160 CONTINUE
472 END IF
473
474
475
476
477
478 DO 170 jj = j + jb - 1, j, -1
479 jp = ipiv( jj ) - jj + 1
480 IF( jp.NE.1 ) THEN
481
482
483
484 IF( jp+jj-1.LT.j+kl ) THEN
485
486
487
488 CALL dswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
489 $ ab( kv+jp+jj-j, j ), ldab-1 )
490 ELSE
491
492
493
494 CALL dswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
495 $ work31( jp+jj-j-kl, 1 ), ldwork )
496 END IF
497 END IF
498
499
500
501 nw = min( i3, jj-j+1 )
502 IF( nw.GT.0 )
503 $
CALL dcopy( nw, work31( 1, jj-j+1 ), 1,
504 $ ab( kv+kl+1-jj+j, jj ), 1 )
505 170 CONTINUE
506 180 CONTINUE
507 END IF
508
509 RETURN
510
511
512
subroutine xerbla(srname, info)
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgbtf2(m, n, kl, ku, ab, ldab, ipiv, info)
DGBTF2 computes the LU factorization of a general band matrix using the unblocked version of the algo...
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
subroutine dger(m, n, alpha, x, incx, y, incy, a, lda)
DGER
integer function idamax(n, dx, incx)
IDAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine dlaswp(n, a, lda, k1, k2, ipiv, incx)
DLASWP performs a series of row interchanges on a general rectangular matrix.
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dswap(n, dx, incx, dy, incy)
DSWAP
subroutine dtrsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
DTRSM