00001 SUBROUTINE ZGBTRF( 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 COMPLEX*16 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 COMPLEX*16 ONE, ZERO
00090 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
00091 $ ZERO = ( 0.0D+0, 0.0D+0 ) )
00092 INTEGER NBMAX, LDWORK
00093 PARAMETER ( NBMAX = 64, LDWORK = NBMAX+1 )
00094
00095
00096 INTEGER I, I2, I3, II, IP, J, J2, J3, JB, JJ, JM, JP,
00097 $ JU, K2, KM, KV, NB, NW
00098 COMPLEX*16 TEMP
00099
00100
00101 COMPLEX*16 WORK13( LDWORK, NBMAX ),
00102 $ WORK31( LDWORK, NBMAX )
00103
00104
00105 INTEGER ILAENV, IZAMAX
00106 EXTERNAL ILAENV, IZAMAX
00107
00108
00109 EXTERNAL XERBLA, ZCOPY, ZGBTF2, ZGEMM, ZGERU, ZLASWP,
00110 $ ZSCAL, ZSWAP, ZTRSM
00111
00112
00113 INTRINSIC MAX, MIN
00114
00115
00116
00117
00118
00119
00120 KV = KU + KL
00121
00122
00123
00124 INFO = 0
00125 IF( M.LT.0 ) THEN
00126 INFO = -1
00127 ELSE IF( N.LT.0 ) THEN
00128 INFO = -2
00129 ELSE IF( KL.LT.0 ) THEN
00130 INFO = -3
00131 ELSE IF( KU.LT.0 ) THEN
00132 INFO = -4
00133 ELSE IF( LDAB.LT.KL+KV+1 ) THEN
00134 INFO = -6
00135 END IF
00136 IF( INFO.NE.0 ) THEN
00137 CALL XERBLA( 'ZGBTRF', -INFO )
00138 RETURN
00139 END IF
00140
00141
00142
00143 IF( M.EQ.0 .OR. N.EQ.0 )
00144 $ RETURN
00145
00146
00147
00148 NB = ILAENV( 1, 'ZGBTRF', ' ', M, N, KL, KU )
00149
00150
00151
00152
00153 NB = MIN( NB, NBMAX )
00154
00155 IF( NB.LE.1 .OR. NB.GT.KL ) THEN
00156
00157
00158
00159 CALL ZGBTF2( M, N, KL, KU, AB, LDAB, IPIV, INFO )
00160 ELSE
00161
00162
00163
00164
00165
00166 DO 20 J = 1, NB
00167 DO 10 I = 1, J - 1
00168 WORK13( I, J ) = ZERO
00169 10 CONTINUE
00170 20 CONTINUE
00171
00172
00173
00174 DO 40 J = 1, NB
00175 DO 30 I = J + 1, NB
00176 WORK31( I, J ) = ZERO
00177 30 CONTINUE
00178 40 CONTINUE
00179
00180
00181
00182
00183
00184 DO 60 J = KU + 2, MIN( KV, N )
00185 DO 50 I = KV - J + 2, KL
00186 AB( I, J ) = ZERO
00187 50 CONTINUE
00188 60 CONTINUE
00189
00190
00191
00192
00193 JU = 1
00194
00195 DO 180 J = 1, MIN( M, N ), NB
00196 JB = MIN( NB, MIN( M, N )-J+1 )
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 I2 = MIN( KL-JB, M-J-JB+1 )
00211 I3 = MIN( JB, M-J-KL+1 )
00212
00213
00214
00215
00216
00217 DO 80 JJ = J, J + JB - 1
00218
00219
00220
00221 IF( JJ+KV.LE.N ) THEN
00222 DO 70 I = 1, KL
00223 AB( I, JJ+KV ) = ZERO
00224 70 CONTINUE
00225 END IF
00226
00227
00228
00229
00230 KM = MIN( KL, M-JJ )
00231 JP = IZAMAX( KM+1, AB( KV+1, JJ ), 1 )
00232 IPIV( JJ ) = JP + JJ - J
00233 IF( AB( KV+JP, JJ ).NE.ZERO ) THEN
00234 JU = MAX( JU, MIN( JJ+KU+JP-1, N ) )
00235 IF( JP.NE.1 ) THEN
00236
00237
00238
00239 IF( JP+JJ-1.LT.J+KL ) THEN
00240
00241 CALL ZSWAP( JB, AB( KV+1+JJ-J, J ), LDAB-1,
00242 $ AB( KV+JP+JJ-J, J ), LDAB-1 )
00243 ELSE
00244
00245
00246
00247
00248 CALL ZSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00249 $ WORK31( JP+JJ-J-KL, 1 ), LDWORK )
00250 CALL ZSWAP( J+JB-JJ, AB( KV+1, JJ ), LDAB-1,
00251 $ AB( KV+JP, JJ ), LDAB-1 )
00252 END IF
00253 END IF
00254
00255
00256
00257 CALL ZSCAL( KM, ONE / AB( KV+1, JJ ), AB( KV+2, JJ ),
00258 $ 1 )
00259
00260
00261
00262
00263
00264 JM = MIN( JU, J+JB-1 )
00265 IF( JM.GT.JJ )
00266 $ CALL ZGERU( KM, JM-JJ, -ONE, AB( KV+2, JJ ), 1,
00267 $ AB( KV, JJ+1 ), LDAB-1,
00268 $ AB( KV+1, JJ+1 ), LDAB-1 )
00269 ELSE
00270
00271
00272
00273
00274 IF( INFO.EQ.0 )
00275 $ INFO = JJ
00276 END IF
00277
00278
00279
00280 NW = MIN( JJ-J+1, I3 )
00281 IF( NW.GT.0 )
00282 $ CALL ZCOPY( NW, AB( KV+KL+1-JJ+J, JJ ), 1,
00283 $ WORK31( 1, JJ-J+1 ), 1 )
00284 80 CONTINUE
00285 IF( J+JB.LE.N ) THEN
00286
00287
00288
00289 J2 = MIN( JU-J+1, KV ) - JB
00290 J3 = MAX( 0, JU-J-KV+1 )
00291
00292
00293
00294
00295 CALL ZLASWP( J2, AB( KV+1-JB, J+JB ), LDAB-1, 1, JB,
00296 $ IPIV( J ), 1 )
00297
00298
00299
00300 DO 90 I = J, J + JB - 1
00301 IPIV( I ) = IPIV( I ) + J - 1
00302 90 CONTINUE
00303
00304
00305
00306
00307 K2 = J - 1 + JB + J2
00308 DO 110 I = 1, J3
00309 JJ = K2 + I
00310 DO 100 II = J + I - 1, J + JB - 1
00311 IP = IPIV( II )
00312 IF( IP.NE.II ) THEN
00313 TEMP = AB( KV+1+II-JJ, JJ )
00314 AB( KV+1+II-JJ, JJ ) = AB( KV+1+IP-JJ, JJ )
00315 AB( KV+1+IP-JJ, JJ ) = TEMP
00316 END IF
00317 100 CONTINUE
00318 110 CONTINUE
00319
00320
00321
00322 IF( J2.GT.0 ) THEN
00323
00324
00325
00326 CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
00327 $ JB, J2, ONE, AB( KV+1, J ), LDAB-1,
00328 $ AB( KV+1-JB, J+JB ), LDAB-1 )
00329
00330 IF( I2.GT.0 ) THEN
00331
00332
00333
00334 CALL ZGEMM( 'No transpose', 'No transpose', I2, J2,
00335 $ JB, -ONE, AB( KV+1+JB, J ), LDAB-1,
00336 $ AB( KV+1-JB, J+JB ), LDAB-1, ONE,
00337 $ AB( KV+1, J+JB ), LDAB-1 )
00338 END IF
00339
00340 IF( I3.GT.0 ) THEN
00341
00342
00343
00344 CALL ZGEMM( 'No transpose', 'No transpose', I3, J2,
00345 $ JB, -ONE, WORK31, LDWORK,
00346 $ AB( KV+1-JB, J+JB ), LDAB-1, ONE,
00347 $ AB( KV+KL+1-JB, J+JB ), LDAB-1 )
00348 END IF
00349 END IF
00350
00351 IF( J3.GT.0 ) THEN
00352
00353
00354
00355
00356 DO 130 JJ = 1, J3
00357 DO 120 II = JJ, JB
00358 WORK13( II, JJ ) = AB( II-JJ+1, JJ+J+KV-1 )
00359 120 CONTINUE
00360 130 CONTINUE
00361
00362
00363
00364 CALL ZTRSM( 'Left', 'Lower', 'No transpose', 'Unit',
00365 $ JB, J3, ONE, AB( KV+1, J ), LDAB-1,
00366 $ WORK13, LDWORK )
00367
00368 IF( I2.GT.0 ) THEN
00369
00370
00371
00372 CALL ZGEMM( 'No transpose', 'No transpose', I2, J3,
00373 $ JB, -ONE, AB( KV+1+JB, J ), LDAB-1,
00374 $ WORK13, LDWORK, ONE, AB( 1+JB, J+KV ),
00375 $ LDAB-1 )
00376 END IF
00377
00378 IF( I3.GT.0 ) THEN
00379
00380
00381
00382 CALL ZGEMM( 'No transpose', 'No transpose', I3, J3,
00383 $ JB, -ONE, WORK31, LDWORK, WORK13,
00384 $ LDWORK, ONE, AB( 1+KL, J+KV ), LDAB-1 )
00385 END IF
00386
00387
00388
00389 DO 150 JJ = 1, J3
00390 DO 140 II = JJ, JB
00391 AB( II-JJ+1, JJ+J+KV-1 ) = WORK13( II, JJ )
00392 140 CONTINUE
00393 150 CONTINUE
00394 END IF
00395 ELSE
00396
00397
00398
00399 DO 160 I = J, J + JB - 1
00400 IPIV( I ) = IPIV( I ) + J - 1
00401 160 CONTINUE
00402 END IF
00403
00404
00405
00406
00407
00408 DO 170 JJ = J + JB - 1, J, -1
00409 JP = IPIV( JJ ) - JJ + 1
00410 IF( JP.NE.1 ) THEN
00411
00412
00413
00414 IF( JP+JJ-1.LT.J+KL ) THEN
00415
00416
00417
00418 CALL ZSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00419 $ AB( KV+JP+JJ-J, J ), LDAB-1 )
00420 ELSE
00421
00422
00423
00424 CALL ZSWAP( JJ-J, AB( KV+1+JJ-J, J ), LDAB-1,
00425 $ WORK31( JP+JJ-J-KL, 1 ), LDWORK )
00426 END IF
00427 END IF
00428
00429
00430
00431 NW = MIN( I3, JJ-J+1 )
00432 IF( NW.GT.0 )
00433 $ CALL ZCOPY( NW, WORK31( 1, JJ-J+1 ), 1,
00434 $ AB( KV+KL+1-JJ+J, JJ ), 1 )
00435 170 CONTINUE
00436 180 CONTINUE
00437 END IF
00438
00439 RETURN
00440
00441
00442
00443 END