00001 SUBROUTINE DGBTRF( M, N, KL, KU, AB, LDAB, IPIV, INFO )
00002
00003
00004
00005
00006
00007
00008
00009 INTEGER INFO, KL, KU, LDAB, M, N
00010
00011
00012 INTEGER IPIV( * )
00013 DOUBLE PRECISION AB( LDAB, * )
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 DOUBLE PRECISION ONE, ZERO
00090 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00091 INTEGER NBMAX, LDWORK
00092 PARAMETER ( NBMAX = 64, LDWORK = NBMAX+1 )
00093
00094
00095 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
00096 $ JU, K2, KM, KV, NB, NW
00097 DOUBLE PRECISION TEMP
00098
00099
00100 DOUBLE PRECISION WORK13( LDWORK, NBMAX ),
00101 $ WORK31( LDWORK, NBMAX )
00102
00103
00104 INTEGER IDAMAX, ILAENV
00105 EXTERNAL IDAMAX, ILAENV
00106
00107
00108 EXTERNAL DCOPY, DGBTF2, DGEMM, DGER, DLASWP, DSCAL,
00109 $ DSWAP, DTRSM, XERBLA
00110
00111
00112 INTRINSIC MAX, MIN
00113
00114
00115
00116
00117
00118
00119 KV = KU + KL
00120
00121
00122
00123 INFO = 0
00124 IF( M.LT.0 ) THEN
00125 INFO = -1
00126 ELSE IF( N.LT.0 ) THEN
00127 INFO = -2
00128 ELSE IF( KL.LT.0 ) THEN
00129 INFO = -3
00130 ELSE IF( KU.LT.0 ) THEN
00131 INFO = -4
00132 ELSE IF( LDAB.LT.KL+KV+1 ) THEN
00133 INFO = -6
00134 END IF
00135 IF( INFO.NE.0 ) THEN
00136 CALL XERBLA( 'DGBTRF', -INFO )
00137 RETURN
00138 END IF
00139
00140
00141
00142 IF( M.EQ.0 .OR. N.EQ.0 )
00143 $ RETURN
00144
00145
00146
00147 NB = ILAENV( 1, 'DGBTRF', ' ', M, N, KL, KU )
00148
00149
00150
00151
00152 NB = MIN( NB, NBMAX )
00153
00154 IF( NB.LE.1 .OR. NB.GT.KL ) THEN
00155
00156
00157
00158 CALL DGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO )
00159 ELSE
00160
00161
00162
00163
00164
00165 DO 20 J = 1, NB
00166 DO 10 I = 1, J - 1
00167 WORK13( I, J ) = ZERO
00168 10 CONTINUE
00169 20 CONTINUE
00170
00171
00172
00173 DO 40 J = 1, NB
00174 DO 30 I = J + 1, NB
00175 WORK31( I, J ) = ZERO
00176 30 CONTINUE
00177 40 CONTINUE
00178
00179
00180
00181
00182
00183 DO 60 J = KU + 2, MIN( KV, N )
00184 DO 50 I = KV - J + 2, KL
00185 AB( I, J ) = ZERO
00186 50 CONTINUE
00187 60 CONTINUE
00188
00189
00190
00191
00192 JU = 1
00193
00194 DO 180 J = 1, MIN( M, N ), NB
00195 JB = MIN( NB, MIN( M, N )-J+1 )
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 I2 = MIN( KL-JB, M-J-JB+1 )
00210 I3 = MIN( JB, M-J-KL+1 )
00211
00212
00213
00214
00215
00216 DO 80 JJ = J, J + JB - 1
00217
00218
00219
00220 IF( JJ+KV.LE.N ) THEN
00221 DO 70 I = 1, KL
00222 AB( I, JJ+KV ) = ZERO
00223 70 CONTINUE
00224 END IF
00225
00226
00227
00228
00229 KM = MIN( KL, M-JJ )
00230 JP = IDAMAX( KM+1, AB( KV+1, JJ ), 1 )
00231 IPIV( JJ ) = JP + JJ - J
00232 IF( AB( KV+JP, JJ ).NE.ZERO ) THEN
00233 JU = MAX( JU, MIN( JJ+KU+JP-1, N ) )
00234 IF( JP.NE.1 ) THEN
00235
00236
00237
00238 IF( JP+JJ-1.LT.J+KL ) THEN
00239
00240 CALL DSWAP( JB, AB( KV+1+JJ-J, J ), LDAB-1,
00241 $ AB( KV+JP+JJ-J, J ), LDAB-1 )
00242 ELSE
00243
00244
00245
00246
00247 CALL DSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00248 $ WORK31( JP+JJ-J-KL, 1 ), LDWORK )
00249 CALL DSWAP( J+JB-JJ, AB( KV+1, JJ ), LDAB-1,
00250 $ AB( KV+JP, JJ ), LDAB-1 )
00251 END IF
00252 END IF
00253
00254
00255
00256 CALL DSCAL( KM, ONE / AB( KV+1, JJ ), AB( KV+2, JJ ),
00257 $ 1 )
00258
00259
00260
00261
00262
00263 JM = MIN( JU, J+JB-1 )
00264 IF( JM.GT.JJ )
00265 $ CALL DGER( KM, JM-JJ, -ONE, AB( KV+2, JJ ), 1,
00266 $ AB( KV, JJ+1 ), LDAB-1,
00267 $ AB( KV+1, JJ+1 ), LDAB-1 )
00268 ELSE
00269
00270
00271
00272
00273 IF( INFO.EQ.0 )
00274 $ INFO = JJ
00275 END IF
00276
00277
00278
00279 NW = MIN( JJ-J+1, I3 )
00280 IF( NW.GT.0 )
00281 $ CALL DCOPY( NW, AB( KV+KL+1-JJ+J, JJ ), 1,
00282 $ WORK31( 1, JJ-J+1 ), 1 )
00283 80 CONTINUE
00284 IF( J+JB.LE.N ) THEN
00285
00286
00287
00288 J2 = MIN( JU-J+1, KV ) - JB
00289 J3 = MAX( 0, JU-J-KV+1 )
00290
00291
00292
00293
00294 CALL DLASWP( J2, AB( KV+1-JB, J+JB ), LDAB-1, 1, JB,
00295 $ IPIV( J ), 1 )
00296
00297
00298
00299 DO 90 I = J, J + JB - 1
00300 IPIV( I ) = IPIV( I ) + J - 1
00301 90 CONTINUE
00302
00303
00304
00305
00306 K2 = J - 1 + JB + J2
00307 DO 110 I = 1, J3
00308 JJ = K2 + I
00309 DO 100 II = J + I - 1, J + JB - 1
00310 IP = IPIV( II )
00311 IF( IP.NE.II ) THEN
00312 TEMP = AB( KV+1+II-JJ, JJ )
00313 AB( KV+1+II-JJ, JJ ) = AB( KV+1+IP-JJ, JJ )
00314 AB( KV+1+IP-JJ, JJ ) = TEMP
00315 END IF
00316 100 CONTINUE
00317 110 CONTINUE
00318
00319
00320
00321 IF( J2.GT.0 ) THEN
00322
00323
00324
00325 CALL DTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
00326 $ JB, J2, ONE, AB( KV+1, J ), LDAB-1,
00327 $ AB( KV+1-JB, J+JB ), LDAB-1 )
00328
00329 IF( I2.GT.0 ) THEN
00330
00331
00332
00333 CALL DGEMM( 'No transpose', 'No transpose', I2, J2,
00334 $ JB, -ONE, AB( KV+1+JB, J ), LDAB-1,
00335 $ AB( KV+1-JB, J+JB ), LDAB-1, ONE,
00336 $ AB( KV+1, J+JB ), LDAB-1 )
00337 END IF
00338
00339 IF( I3.GT.0 ) THEN
00340
00341
00342
00343 CALL DGEMM( 'No transpose', 'No transpose', I3, J2,
00344 $ JB, -ONE, WORK31, LDWORK,
00345 $ AB( KV+1-JB, J+JB ), LDAB-1, ONE,
00346 $ AB( KV+KL+1-JB, J+JB ), LDAB-1 )
00347 END IF
00348 END IF
00349
00350 IF( J3.GT.0 ) THEN
00351
00352
00353
00354
00355 DO 130 JJ = 1, J3
00356 DO 120 II = JJ, JB
00357 WORK13( II, JJ ) = AB( II-JJ+1, JJ+J+KV-1 )
00358 120 CONTINUE
00359 130 CONTINUE
00360
00361
00362
00363 CALL DTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
00364 $ JB, J3, ONE, AB( KV+1, J ), LDAB-1,
00365 $ WORK13, LDWORK )
00366
00367 IF( I2.GT.0 ) THEN
00368
00369
00370
00371 CALL DGEMM( 'No transpose', 'No transpose', I2, J3,
00372 $ JB, -ONE, AB( KV+1+JB, J ), LDAB-1,
00373 $ WORK13, LDWORK, ONE, AB( 1+JB, J+KV ),
00374 $ LDAB-1 )
00375 END IF
00376
00377 IF( I3.GT.0 ) THEN
00378
00379
00380
00381 CALL DGEMM( 'No transpose', 'No transpose', I3, J3,
00382 $ JB, -ONE, WORK31, LDWORK, WORK13,
00383 $ LDWORK, ONE, AB( 1+KL, J+KV ), LDAB-1 )
00384 END IF
00385
00386
00387
00388 DO 150 JJ = 1, J3
00389 DO 140 II = JJ, JB
00390 AB( II-JJ+1, JJ+J+KV-1 ) = WORK13( II, JJ )
00391 140 CONTINUE
00392 150 CONTINUE
00393 END IF
00394 ELSE
00395
00396
00397
00398 DO 160 I = J, J + JB - 1
00399 IPIV( I ) = IPIV( I ) + J - 1
00400 160 CONTINUE
00401 END IF
00402
00403
00404
00405
00406
00407 DO 170 JJ = J + JB - 1, J, -1
00408 JP = IPIV( JJ ) - JJ + 1
00409 IF( JP.NE.1 ) THEN
00410
00411
00412
00413 IF( JP+JJ-1.LT.J+KL ) THEN
00414
00415
00416
00417 CALL DSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00418 $ AB( KV+JP+JJ-J, J ), LDAB-1 )
00419 ELSE
00420
00421
00422
00423 CALL DSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00424 $ WORK31( JP+JJ-J-KL, 1 ), LDWORK )
00425 END IF
00426 END IF
00427
00428
00429
00430 NW = MIN( I3, JJ-J+1 )
00431 IF( NW.GT.0 )
00432 $ CALL DCOPY( NW, WORK31( 1, JJ-J+1 ), 1,
00433 $ AB( KV+KL+1-JJ+J, JJ ), 1 )
00434 170 CONTINUE
00435 180 CONTINUE
00436 END IF
00437
00438 RETURN
00439
00440
00441
00442 END