142
143
144
145
146
147
148 INTEGER INFO, KL, KU, LDAB, M, N
149
150
151 INTEGER IPIV( * )
152 REAL AB( LDAB, * )
153
154
155
156
157
158 REAL ONE, ZERO
159 parameter( one = 1.0e+0, zero = 0.0e+0 )
160 INTEGER NBMAX, LDWORK
161 parameter( nbmax = 64, ldwork = nbmax+1 )
162
163
164 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
165 $ JU, K2, KM, KV, NB, NW
166 REAL TEMP
167
168
169 REAL WORK13( LDWORK, NBMAX ),
170 $ WORK31( LDWORK, NBMAX )
171
172
173 INTEGER ILAENV, ISAMAX
175
176
180
181
182 INTRINSIC max, min
183
184
185
186
187
188
189 kv = ku + kl
190
191
192
193 info = 0
194 IF( m.LT.0 ) THEN
195 info = -1
196 ELSE IF( n.LT.0 ) THEN
197 info = -2
198 ELSE IF( kl.LT.0 ) THEN
199 info = -3
200 ELSE IF( ku.LT.0 ) THEN
201 info = -4
202 ELSE IF( ldab.LT.kl+kv+1 ) THEN
203 info = -6
204 END IF
205 IF( info.NE.0 ) THEN
206 CALL xerbla(
'SGBTRF', -info )
207 RETURN
208 END IF
209
210
211
212 IF( m.EQ.0 .OR. n.EQ.0 )
213 $ RETURN
214
215
216
217 nb =
ilaenv( 1,
'SGBTRF',
' ', m, n, kl, ku )
218
219
220
221
222 nb = min( nb, nbmax )
223
224 IF( nb.LE.1 .OR. nb.GT.kl ) THEN
225
226
227
228 CALL sgbtf2( m, n, kl, ku, ab, ldab, ipiv, info )
229 ELSE
230
231
232
233
234
235 DO 20 j = 1, nb
236 DO 10 i = 1, j - 1
237 work13( i, j ) = zero
238 10 CONTINUE
239 20 CONTINUE
240
241
242
243 DO 40 j = 1, nb
244 DO 30 i = j + 1, nb
245 work31( i, j ) = zero
246 30 CONTINUE
247 40 CONTINUE
248
249
250
251
252
253 DO 60 j = ku + 2, min( kv, n )
254 DO 50 i = kv - j + 2, kl
255 ab( i, j ) = zero
256 50 CONTINUE
257 60 CONTINUE
258
259
260
261
262 ju = 1
263
264 DO 180 j = 1, min( m, n ), nb
265 jb = min( nb, min( m, n )-j+1 )
266
267
268
269
270
271
272
273
274
275
276
277
278
279 i2 = min( kl-jb, m-j-jb+1 )
280 i3 = min( jb, m-j-kl+1 )
281
282
283
284
285
286 DO 80 jj = j, j + jb - 1
287
288
289
290 IF( jj+kv.LE.n ) THEN
291 DO 70 i = 1, kl
292 ab( i, jj+kv ) = zero
293 70 CONTINUE
294 END IF
295
296
297
298
299 km = min( kl, m-jj )
300 jp =
isamax( km+1, ab( kv+1, jj ), 1 )
301 ipiv( jj ) = jp + jj - j
302 IF( ab( kv+jp, jj ).NE.zero ) THEN
303 ju = max( ju, min( jj+ku+jp-1, n ) )
304 IF( jp.NE.1 ) THEN
305
306
307
308 IF( jp+jj-1.LT.j+kl ) THEN
309
310 CALL sswap( jb, ab( kv+1+jj-j, j ), ldab-1,
311 $ ab( kv+jp+jj-j, j ), ldab-1 )
312 ELSE
313
314
315
316
317 CALL sswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
318 $ work31( jp+jj-j-kl, 1 ), ldwork )
319 CALL sswap( j+jb-jj, ab( kv+1, jj ), ldab-1,
320 $ ab( kv+jp, jj ), ldab-1 )
321 END IF
322 END IF
323
324
325
326 CALL sscal( km, one / ab( kv+1, jj ), ab( kv+2,
327 $ jj ),
328 $ 1 )
329
330
331
332
333
334 jm = min( ju, j+jb-1 )
335 IF( jm.GT.jj )
336 $
CALL sger( 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 scopy( 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 slaswp( 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 strsm(
'Left',
'Lower',
'No transpose',
397 $ '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 sgemm(
'No transpose',
'No transpose', i2,
406 $ j2,
407 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
408 $ ab( kv+1-jb, j+jb ), ldab-1, one,
409 $ ab( kv+1, j+jb ), ldab-1 )
410 END IF
411
412 IF( i3.GT.0 ) THEN
413
414
415
416 CALL sgemm(
'No transpose',
'No transpose', i3,
417 $ j2,
418 $ jb, -one, work31, ldwork,
419 $ ab( kv+1-jb, j+jb ), ldab-1, one,
420 $ ab( kv+kl+1-jb, j+jb ), ldab-1 )
421 END IF
422 END IF
423
424 IF( j3.GT.0 ) THEN
425
426
427
428
429 DO 130 jj = 1, j3
430 DO 120 ii = jj, jb
431 work13( ii, jj ) = ab( ii-jj+1, jj+j+kv-1 )
432 120 CONTINUE
433 130 CONTINUE
434
435
436
437 CALL strsm(
'Left',
'Lower',
'No transpose',
438 $ 'Unit',
439 $ jb, j3, one, ab( kv+1, j ), ldab-1,
440 $ work13, ldwork )
441
442 IF( i2.GT.0 ) THEN
443
444
445
446 CALL sgemm(
'No transpose',
'No transpose', i2,
447 $ j3,
448 $ jb, -one, ab( kv+1+jb, j ), ldab-1,
449 $ work13, ldwork, one, ab( 1+jb, j+kv ),
450 $ ldab-1 )
451 END IF
452
453 IF( i3.GT.0 ) THEN
454
455
456
457 CALL sgemm(
'No transpose',
'No transpose', i3,
458 $ j3,
459 $ jb, -one, work31, ldwork, work13,
460 $ ldwork, one, ab( 1+kl, j+kv ), ldab-1 )
461 END IF
462
463
464
465 DO 150 jj = 1, j3
466 DO 140 ii = jj, jb
467 ab( ii-jj+1, jj+j+kv-1 ) = work13( ii, jj )
468 140 CONTINUE
469 150 CONTINUE
470 END IF
471 ELSE
472
473
474
475 DO 160 i = j, j + jb - 1
476 ipiv( i ) = ipiv( i ) + j - 1
477 160 CONTINUE
478 END IF
479
480
481
482
483
484 DO 170 jj = j + jb - 1, j, -1
485 jp = ipiv( jj ) - jj + 1
486 IF( jp.NE.1 ) THEN
487
488
489
490 IF( jp+jj-1.LT.j+kl ) THEN
491
492
493
494 CALL sswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
495 $ ab( kv+jp+jj-j, j ), ldab-1 )
496 ELSE
497
498
499
500 CALL sswap( jj-j, ab( kv+1+jj-j, j ), ldab-1,
501 $ work31( jp+jj-j-kl, 1 ), ldwork )
502 END IF
503 END IF
504
505
506
507 nw = min( i3, jj-j+1 )
508 IF( nw.GT.0 )
509 $
CALL scopy( nw, work31( 1, jj-j+1 ), 1,
510 $ ab( kv+kl+1-jj+j, jj ), 1 )
511 170 CONTINUE
512 180 CONTINUE
513 END IF
514
515 RETURN
516
517
518
subroutine xerbla(srname, info)
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
subroutine sgbtf2(m, n, kl, ku, ab, ldab, ipiv, info)
SGBTF2 computes the LU factorization of a general band matrix using the unblocked version of the algo...
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
subroutine sger(m, n, alpha, x, incx, y, incy, a, lda)
SGER
integer function isamax(n, sx, incx)
ISAMAX
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
subroutine slaswp(n, a, lda, k1, k2, ipiv, incx)
SLASWP performs a series of row interchanges on a general rectangular matrix.
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
subroutine strsm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
STRSM