00001 SUBROUTINE DLALN2( LTRANS, NA, NW, SMIN, CA, A, LDA, D1, D2, B,
00002 $ LDB, WR, WI, X, LDX, SCALE, XNORM, INFO )
00003
00004
00005
00006
00007
00008
00009
00010 LOGICAL LTRANS
00011 INTEGER INFO, LDA, LDB, LDX, NA, NW
00012 DOUBLE PRECISION CA, D1, D2, SCALE, SMIN, WI, WR, XNORM
00013
00014
00015 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), X( LDX, * )
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
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 DOUBLE PRECISION ZERO, ONE
00136 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
00137 DOUBLE PRECISION TWO
00138 PARAMETER ( TWO = 2.0D0 )
00139
00140
00141 INTEGER ICMAX, J
00142 DOUBLE PRECISION BBND, BI1, BI2, BIGNUM, BNORM, BR1, BR2, CI21,
00143 $ CI22, CMAX, CNORM, CR21, CR22, CSI, CSR, LI21,
00144 $ LR21, SMINI, SMLNUM, TEMP, U22ABS, UI11, UI11R,
00145 $ UI12, UI12S, UI22, UR11, UR11R, UR12, UR12S,
00146 $ UR22, XI1, XI2, XR1, XR2
00147
00148
00149 LOGICAL RSWAP( 4 ), ZSWAP( 4 )
00150 INTEGER IPIVOT( 4, 4 )
00151 DOUBLE PRECISION CI( 2, 2 ), CIV( 4 ), CR( 2, 2 ), CRV( 4 )
00152
00153
00154 DOUBLE PRECISION DLAMCH
00155 EXTERNAL DLAMCH
00156
00157
00158 EXTERNAL DLADIV
00159
00160
00161 INTRINSIC ABS, MAX
00162
00163
00164 EQUIVALENCE ( CI( 1, 1 ), CIV( 1 ) ),
00165 $ ( CR( 1, 1 ), CRV( 1 ) )
00166
00167
00168 DATA ZSWAP / .FALSE., .FALSE., .TRUE., .TRUE. /
00169 DATA RSWAP / .FALSE., .TRUE., .FALSE., .TRUE. /
00170 DATA IPIVOT / 1, 2, 3, 4, 2, 1, 4, 3, 3, 4, 1, 2, 4,
00171 $ 3, 2, 1 /
00172
00173
00174
00175
00176
00177 SMLNUM = TWO*DLAMCH( 'Safe minimum' )
00178 BIGNUM = ONE / SMLNUM
00179 SMINI = MAX( SMIN, SMLNUM )
00180
00181
00182
00183 INFO = 0
00184
00185
00186
00187 SCALE = ONE
00188
00189 IF( NA.EQ.1 ) THEN
00190
00191
00192
00193 IF( NW.EQ.1 ) THEN
00194
00195
00196
00197
00198
00199 CSR = CA*A( 1, 1 ) - WR*D1
00200 CNORM = ABS( CSR )
00201
00202
00203
00204 IF( CNORM.LT.SMINI ) THEN
00205 CSR = SMINI
00206 CNORM = SMINI
00207 INFO = 1
00208 END IF
00209
00210
00211
00212 BNORM = ABS( B( 1, 1 ) )
00213 IF( CNORM.LT.ONE .AND. BNORM.GT.ONE ) THEN
00214 IF( BNORM.GT.BIGNUM*CNORM )
00215 $ SCALE = ONE / BNORM
00216 END IF
00217
00218
00219
00220 X( 1, 1 ) = ( B( 1, 1 )*SCALE ) / CSR
00221 XNORM = ABS( X( 1, 1 ) )
00222 ELSE
00223
00224
00225
00226
00227
00228 CSR = CA*A( 1, 1 ) - WR*D1
00229 CSI = -WI*D1
00230 CNORM = ABS( CSR ) + ABS( CSI )
00231
00232
00233
00234 IF( CNORM.LT.SMINI ) THEN
00235 CSR = SMINI
00236 CSI = ZERO
00237 CNORM = SMINI
00238 INFO = 1
00239 END IF
00240
00241
00242
00243 BNORM = ABS( B( 1, 1 ) ) + ABS( B( 1, 2 ) )
00244 IF( CNORM.LT.ONE .AND. BNORM.GT.ONE ) THEN
00245 IF( BNORM.GT.BIGNUM*CNORM )
00246 $ SCALE = ONE / BNORM
00247 END IF
00248
00249
00250
00251 CALL DLADIV( SCALE*B( 1, 1 ), SCALE*B( 1, 2 ), CSR, CSI,
00252 $ X( 1, 1 ), X( 1, 2 ) )
00253 XNORM = ABS( X( 1, 1 ) ) + ABS( X( 1, 2 ) )
00254 END IF
00255
00256 ELSE
00257
00258
00259
00260
00261
00262 CR( 1, 1 ) = CA*A( 1, 1 ) - WR*D1
00263 CR( 2, 2 ) = CA*A( 2, 2 ) - WR*D2
00264 IF( LTRANS ) THEN
00265 CR( 1, 2 ) = CA*A( 2, 1 )
00266 CR( 2, 1 ) = CA*A( 1, 2 )
00267 ELSE
00268 CR( 2, 1 ) = CA*A( 2, 1 )
00269 CR( 1, 2 ) = CA*A( 1, 2 )
00270 END IF
00271
00272 IF( NW.EQ.1 ) THEN
00273
00274
00275
00276
00277
00278 CMAX = ZERO
00279 ICMAX = 0
00280
00281 DO 10 J = 1, 4
00282 IF( ABS( CRV( J ) ).GT.CMAX ) THEN
00283 CMAX = ABS( CRV( J ) )
00284 ICMAX = J
00285 END IF
00286 10 CONTINUE
00287
00288
00289
00290 IF( CMAX.LT.SMINI ) THEN
00291 BNORM = MAX( ABS( B( 1, 1 ) ), ABS( B( 2, 1 ) ) )
00292 IF( SMINI.LT.ONE .AND. BNORM.GT.ONE ) THEN
00293 IF( BNORM.GT.BIGNUM*SMINI )
00294 $ SCALE = ONE / BNORM
00295 END IF
00296 TEMP = SCALE / SMINI
00297 X( 1, 1 ) = TEMP*B( 1, 1 )
00298 X( 2, 1 ) = TEMP*B( 2, 1 )
00299 XNORM = TEMP*BNORM
00300 INFO = 1
00301 RETURN
00302 END IF
00303
00304
00305
00306 UR11 = CRV( ICMAX )
00307 CR21 = CRV( IPIVOT( 2, ICMAX ) )
00308 UR12 = CRV( IPIVOT( 3, ICMAX ) )
00309 CR22 = CRV( IPIVOT( 4, ICMAX ) )
00310 UR11R = ONE / UR11
00311 LR21 = UR11R*CR21
00312 UR22 = CR22 - UR12*LR21
00313
00314
00315
00316 IF( ABS( UR22 ).LT.SMINI ) THEN
00317 UR22 = SMINI
00318 INFO = 1
00319 END IF
00320 IF( RSWAP( ICMAX ) ) THEN
00321 BR1 = B( 2, 1 )
00322 BR2 = B( 1, 1 )
00323 ELSE
00324 BR1 = B( 1, 1 )
00325 BR2 = B( 2, 1 )
00326 END IF
00327 BR2 = BR2 - LR21*BR1
00328 BBND = MAX( ABS( BR1*( UR22*UR11R ) ), ABS( BR2 ) )
00329 IF( BBND.GT.ONE .AND. ABS( UR22 ).LT.ONE ) THEN
00330 IF( BBND.GE.BIGNUM*ABS( UR22 ) )
00331 $ SCALE = ONE / BBND
00332 END IF
00333
00334 XR2 = ( BR2*SCALE ) / UR22
00335 XR1 = ( SCALE*BR1 )*UR11R - XR2*( UR11R*UR12 )
00336 IF( ZSWAP( ICMAX ) ) THEN
00337 X( 1, 1 ) = XR2
00338 X( 2, 1 ) = XR1
00339 ELSE
00340 X( 1, 1 ) = XR1
00341 X( 2, 1 ) = XR2
00342 END IF
00343 XNORM = MAX( ABS( XR1 ), ABS( XR2 ) )
00344
00345
00346
00347 IF( XNORM.GT.ONE .AND. CMAX.GT.ONE ) THEN
00348 IF( XNORM.GT.BIGNUM / CMAX ) THEN
00349 TEMP = CMAX / BIGNUM
00350 X( 1, 1 ) = TEMP*X( 1, 1 )
00351 X( 2, 1 ) = TEMP*X( 2, 1 )
00352 XNORM = TEMP*XNORM
00353 SCALE = TEMP*SCALE
00354 END IF
00355 END IF
00356 ELSE
00357
00358
00359
00360
00361
00362 CI( 1, 1 ) = -WI*D1
00363 CI( 2, 1 ) = ZERO
00364 CI( 1, 2 ) = ZERO
00365 CI( 2, 2 ) = -WI*D2
00366 CMAX = ZERO
00367 ICMAX = 0
00368
00369 DO 20 J = 1, 4
00370 IF( ABS( CRV( J ) )+ABS( CIV( J ) ).GT.CMAX ) THEN
00371 CMAX = ABS( CRV( J ) ) + ABS( CIV( J ) )
00372 ICMAX = J
00373 END IF
00374 20 CONTINUE
00375
00376
00377
00378 IF( CMAX.LT.SMINI ) THEN
00379 BNORM = MAX( ABS( B( 1, 1 ) )+ABS( B( 1, 2 ) ),
00380 $ ABS( B( 2, 1 ) )+ABS( B( 2, 2 ) ) )
00381 IF( SMINI.LT.ONE .AND. BNORM.GT.ONE ) THEN
00382 IF( BNORM.GT.BIGNUM*SMINI )
00383 $ SCALE = ONE / BNORM
00384 END IF
00385 TEMP = SCALE / SMINI
00386 X( 1, 1 ) = TEMP*B( 1, 1 )
00387 X( 2, 1 ) = TEMP*B( 2, 1 )
00388 X( 1, 2 ) = TEMP*B( 1, 2 )
00389 X( 2, 2 ) = TEMP*B( 2, 2 )
00390 XNORM = TEMP*BNORM
00391 INFO = 1
00392 RETURN
00393 END IF
00394
00395
00396
00397 UR11 = CRV( ICMAX )
00398 UI11 = CIV( ICMAX )
00399 CR21 = CRV( IPIVOT( 2, ICMAX ) )
00400 CI21 = CIV( IPIVOT( 2, ICMAX ) )
00401 UR12 = CRV( IPIVOT( 3, ICMAX ) )
00402 UI12 = CIV( IPIVOT( 3, ICMAX ) )
00403 CR22 = CRV( IPIVOT( 4, ICMAX ) )
00404 CI22 = CIV( IPIVOT( 4, ICMAX ) )
00405 IF( ICMAX.EQ.1 .OR. ICMAX.EQ.4 ) THEN
00406
00407
00408
00409 IF( ABS( UR11 ).GT.ABS( UI11 ) ) THEN
00410 TEMP = UI11 / UR11
00411 UR11R = ONE / ( UR11*( ONE+TEMP**2 ) )
00412 UI11R = -TEMP*UR11R
00413 ELSE
00414 TEMP = UR11 / UI11
00415 UI11R = -ONE / ( UI11*( ONE+TEMP**2 ) )
00416 UR11R = -TEMP*UI11R
00417 END IF
00418 LR21 = CR21*UR11R
00419 LI21 = CR21*UI11R
00420 UR12S = UR12*UR11R
00421 UI12S = UR12*UI11R
00422 UR22 = CR22 - UR12*LR21
00423 UI22 = CI22 - UR12*LI21
00424 ELSE
00425
00426
00427
00428 UR11R = ONE / UR11
00429 UI11R = ZERO
00430 LR21 = CR21*UR11R
00431 LI21 = CI21*UR11R
00432 UR12S = UR12*UR11R
00433 UI12S = UI12*UR11R
00434 UR22 = CR22 - UR12*LR21 + UI12*LI21
00435 UI22 = -UR12*LI21 - UI12*LR21
00436 END IF
00437 U22ABS = ABS( UR22 ) + ABS( UI22 )
00438
00439
00440
00441 IF( U22ABS.LT.SMINI ) THEN
00442 UR22 = SMINI
00443 UI22 = ZERO
00444 INFO = 1
00445 END IF
00446 IF( RSWAP( ICMAX ) ) THEN
00447 BR2 = B( 1, 1 )
00448 BR1 = B( 2, 1 )
00449 BI2 = B( 1, 2 )
00450 BI1 = B( 2, 2 )
00451 ELSE
00452 BR1 = B( 1, 1 )
00453 BR2 = B( 2, 1 )
00454 BI1 = B( 1, 2 )
00455 BI2 = B( 2, 2 )
00456 END IF
00457 BR2 = BR2 - LR21*BR1 + LI21*BI1
00458 BI2 = BI2 - LI21*BR1 - LR21*BI1
00459 BBND = MAX( ( ABS( BR1 )+ABS( BI1 ) )*
00460 $ ( U22ABS*( ABS( UR11R )+ABS( UI11R ) ) ),
00461 $ ABS( BR2 )+ABS( BI2 ) )
00462 IF( BBND.GT.ONE .AND. U22ABS.LT.ONE ) THEN
00463 IF( BBND.GE.BIGNUM*U22ABS ) THEN
00464 SCALE = ONE / BBND
00465 BR1 = SCALE*BR1
00466 BI1 = SCALE*BI1
00467 BR2 = SCALE*BR2
00468 BI2 = SCALE*BI2
00469 END IF
00470 END IF
00471
00472 CALL DLADIV( BR2, BI2, UR22, UI22, XR2, XI2 )
00473 XR1 = UR11R*BR1 - UI11R*BI1 - UR12S*XR2 + UI12S*XI2
00474 XI1 = UI11R*BR1 + UR11R*BI1 - UI12S*XR2 - UR12S*XI2
00475 IF( ZSWAP( ICMAX ) ) THEN
00476 X( 1, 1 ) = XR2
00477 X( 2, 1 ) = XR1
00478 X( 1, 2 ) = XI2
00479 X( 2, 2 ) = XI1
00480 ELSE
00481 X( 1, 1 ) = XR1
00482 X( 2, 1 ) = XR2
00483 X( 1, 2 ) = XI1
00484 X( 2, 2 ) = XI2
00485 END IF
00486 XNORM = MAX( ABS( XR1 )+ABS( XI1 ), ABS( XR2 )+ABS( XI2 ) )
00487
00488
00489
00490 IF( XNORM.GT.ONE .AND. CMAX.GT.ONE ) THEN
00491 IF( XNORM.GT.BIGNUM / CMAX ) THEN
00492 TEMP = CMAX / BIGNUM
00493 X( 1, 1 ) = TEMP*X( 1, 1 )
00494 X( 2, 1 ) = TEMP*X( 2, 1 )
00495 X( 1, 2 ) = TEMP*X( 1, 2 )
00496 X( 2, 2 ) = TEMP*X( 2, 2 )
00497 XNORM = TEMP*XNORM
00498 SCALE = TEMP*SCALE
00499 END IF
00500 END IF
00501 END IF
00502 END IF
00503
00504 RETURN
00505
00506
00507
00508 END