00001 SUBROUTINE CLASYF( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW, INFO )
00002
00003
00004
00005
00006
00007
00008
00009 CHARACTER UPLO
00010 INTEGER INFO, KB, LDA, LDW, N, NB
00011
00012
00013 INTEGER IPIV( * )
00014 COMPLEX A( LDA, * ), W( LDW, * )
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
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 REAL ZERO, ONE
00100 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00101 REAL EIGHT, SEVTEN
00102 PARAMETER ( EIGHT = 8.0E+0, SEVTEN = 17.0E+0 )
00103 COMPLEX CONE
00104 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
00105
00106
00107 INTEGER IMAX, J, JB, JJ, JMAX, JP, K, KK, KKW, KP,
00108 $ KSTEP, KW
00109 REAL ABSAKK, ALPHA, COLMAX, ROWMAX
00110 COMPLEX D11, D21, D22, R1, T, Z
00111
00112
00113 LOGICAL LSAME
00114 INTEGER ICAMAX
00115 EXTERNAL LSAME, ICAMAX
00116
00117
00118 EXTERNAL CCOPY, CGEMM, CGEMV, CSCAL, CSWAP
00119
00120
00121 INTRINSIC ABS, AIMAG, MAX, MIN, REAL, SQRT
00122
00123
00124 REAL CABS1
00125
00126
00127 CABS1( Z ) = ABS( REAL( Z ) ) + ABS( AIMAG( Z ) )
00128
00129
00130
00131 INFO = 0
00132
00133
00134
00135 ALPHA = ( ONE+SQRT( SEVTEN ) ) / EIGHT
00136
00137 IF( LSAME( UPLO, 'U' ) ) THEN
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 K = N
00148 10 CONTINUE
00149 KW = NB + K - N
00150
00151
00152
00153 IF( ( K.LE.N-NB+1 .AND. NB.LT.N ) .OR. K.LT.1 )
00154 $ GO TO 30
00155
00156
00157
00158 CALL CCOPY( K, A( 1, K ), 1, W( 1, KW ), 1 )
00159 IF( K.LT.N )
00160 $ CALL CGEMV( 'No transpose', K, N-K, -CONE, A( 1, K+1 ), LDA,
00161 $ W( K, KW+1 ), LDW, CONE, W( 1, KW ), 1 )
00162
00163 KSTEP = 1
00164
00165
00166
00167
00168 ABSAKK = CABS1( W( K, KW ) )
00169
00170
00171
00172
00173 IF( K.GT.1 ) THEN
00174 IMAX = ICAMAX( K-1, W( 1, KW ), 1 )
00175 COLMAX = CABS1( W( IMAX, KW ) )
00176 ELSE
00177 COLMAX = ZERO
00178 END IF
00179
00180 IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
00181
00182
00183
00184 IF( INFO.EQ.0 )
00185 $ INFO = K
00186 KP = K
00187 ELSE
00188 IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
00189
00190
00191
00192 KP = K
00193 ELSE
00194
00195
00196
00197 CALL CCOPY( IMAX, A( 1, IMAX ), 1, W( 1, KW-1 ), 1 )
00198 CALL CCOPY( K-IMAX, A( IMAX, IMAX+1 ), LDA,
00199 $ W( IMAX+1, KW-1 ), 1 )
00200 IF( K.LT.N )
00201 $ CALL CGEMV( 'No transpose', K, N-K, -CONE,
00202 $ A( 1, K+1 ), LDA, W( IMAX, KW+1 ), LDW,
00203 $ CONE, W( 1, KW-1 ), 1 )
00204
00205
00206
00207
00208 JMAX = IMAX + ICAMAX( K-IMAX, W( IMAX+1, KW-1 ), 1 )
00209 ROWMAX = CABS1( W( JMAX, KW-1 ) )
00210 IF( IMAX.GT.1 ) THEN
00211 JMAX = ICAMAX( IMAX-1, W( 1, KW-1 ), 1 )
00212 ROWMAX = MAX( ROWMAX, CABS1( W( JMAX, KW-1 ) ) )
00213 END IF
00214
00215 IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
00216
00217
00218
00219 KP = K
00220 ELSE IF( CABS1( W( IMAX, KW-1 ) ).GE.ALPHA*ROWMAX ) THEN
00221
00222
00223
00224
00225 KP = IMAX
00226
00227
00228
00229 CALL CCOPY( K, W( 1, KW-1 ), 1, W( 1, KW ), 1 )
00230 ELSE
00231
00232
00233
00234
00235 KP = IMAX
00236 KSTEP = 2
00237 END IF
00238 END IF
00239
00240 KK = K - KSTEP + 1
00241 KKW = NB + KK - N
00242
00243
00244
00245 IF( KP.NE.KK ) THEN
00246
00247
00248
00249 A( KP, K ) = A( KK, K )
00250 CALL CCOPY( K-1-KP, A( KP+1, KK ), 1, A( KP, KP+1 ),
00251 $ LDA )
00252 CALL CCOPY( KP, A( 1, KK ), 1, A( 1, KP ), 1 )
00253
00254
00255
00256 CALL CSWAP( N-KK+1, A( KK, KK ), LDA, A( KP, KK ), LDA )
00257 CALL CSWAP( N-KK+1, W( KK, KKW ), LDW, W( KP, KKW ),
00258 $ LDW )
00259 END IF
00260
00261 IF( KSTEP.EQ.1 ) THEN
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 CALL CCOPY( K, W( 1, KW ), 1, A( 1, K ), 1 )
00272 R1 = CONE / A( K, K )
00273 CALL CSCAL( K-1, R1, A( 1, K ), 1 )
00274 ELSE
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 IF( K.GT.2 ) THEN
00285
00286
00287
00288 D21 = W( K-1, KW )
00289 D11 = W( K, KW ) / D21
00290 D22 = W( K-1, KW-1 ) / D21
00291 T = CONE / ( D11*D22-CONE )
00292 D21 = T / D21
00293 DO 20 J = 1, K - 2
00294 A( J, K-1 ) = D21*( D11*W( J, KW-1 )-W( J, KW ) )
00295 A( J, K ) = D21*( D22*W( J, KW )-W( J, KW-1 ) )
00296 20 CONTINUE
00297 END IF
00298
00299
00300
00301 A( K-1, K-1 ) = W( K-1, KW-1 )
00302 A( K-1, K ) = W( K-1, KW )
00303 A( K, K ) = W( K, KW )
00304 END IF
00305 END IF
00306
00307
00308
00309 IF( KSTEP.EQ.1 ) THEN
00310 IPIV( K ) = KP
00311 ELSE
00312 IPIV( K ) = -KP
00313 IPIV( K-1 ) = -KP
00314 END IF
00315
00316
00317
00318 K = K - KSTEP
00319 GO TO 10
00320
00321 30 CONTINUE
00322
00323
00324
00325
00326
00327
00328
00329 DO 50 J = ( ( K-1 ) / NB )*NB + 1, 1, -NB
00330 JB = MIN( NB, K-J+1 )
00331
00332
00333
00334 DO 40 JJ = J, J + JB - 1
00335 CALL CGEMV( 'No transpose', JJ-J+1, N-K, -CONE,
00336 $ A( J, K+1 ), LDA, W( JJ, KW+1 ), LDW, CONE,
00337 $ A( J, JJ ), 1 )
00338 40 CONTINUE
00339
00340
00341
00342 CALL CGEMM( 'No transpose', 'Transpose', J-1, JB, N-K,
00343 $ -CONE, A( 1, K+1 ), LDA, W( J, KW+1 ), LDW,
00344 $ CONE, A( 1, J ), LDA )
00345 50 CONTINUE
00346
00347
00348
00349
00350 J = K + 1
00351 60 CONTINUE
00352 JJ = J
00353 JP = IPIV( J )
00354 IF( JP.LT.0 ) THEN
00355 JP = -JP
00356 J = J + 1
00357 END IF
00358 J = J + 1
00359 IF( JP.NE.JJ .AND. J.LE.N )
00360 $ CALL CSWAP( N-J+1, A( JP, J ), LDA, A( JJ, J ), LDA )
00361 IF( J.LE.N )
00362 $ GO TO 60
00363
00364
00365
00366 KB = N - K
00367
00368 ELSE
00369
00370
00371
00372
00373
00374
00375
00376 K = 1
00377 70 CONTINUE
00378
00379
00380
00381 IF( ( K.GE.NB .AND. NB.LT.N ) .OR. K.GT.N )
00382 $ GO TO 90
00383
00384
00385
00386 CALL CCOPY( N-K+1, A( K, K ), 1, W( K, K ), 1 )
00387 CALL CGEMV( 'No transpose', N-K+1, K-1, -CONE, A( K, 1 ), LDA,
00388 $ W( K, 1 ), LDW, CONE, W( K, K ), 1 )
00389
00390 KSTEP = 1
00391
00392
00393
00394
00395 ABSAKK = CABS1( W( K, K ) )
00396
00397
00398
00399
00400 IF( K.LT.N ) THEN
00401 IMAX = K + ICAMAX( N-K, W( K+1, K ), 1 )
00402 COLMAX = CABS1( W( IMAX, K ) )
00403 ELSE
00404 COLMAX = ZERO
00405 END IF
00406
00407 IF( MAX( ABSAKK, COLMAX ).EQ.ZERO ) THEN
00408
00409
00410
00411 IF( INFO.EQ.0 )
00412 $ INFO = K
00413 KP = K
00414 ELSE
00415 IF( ABSAKK.GE.ALPHA*COLMAX ) THEN
00416
00417
00418
00419 KP = K
00420 ELSE
00421
00422
00423
00424 CALL CCOPY( IMAX-K, A( IMAX, K ), LDA, W( K, K+1 ), 1 )
00425 CALL CCOPY( N-IMAX+1, A( IMAX, IMAX ), 1, W( IMAX, K+1 ),
00426 $ 1 )
00427 CALL CGEMV( 'No transpose', N-K+1, K-1, -CONE, A( K, 1 ),
00428 $ LDA, W( IMAX, 1 ), LDW, CONE, W( K, K+1 ),
00429 $ 1 )
00430
00431
00432
00433
00434 JMAX = K - 1 + ICAMAX( IMAX-K, W( K, K+1 ), 1 )
00435 ROWMAX = CABS1( W( JMAX, K+1 ) )
00436 IF( IMAX.LT.N ) THEN
00437 JMAX = IMAX + ICAMAX( N-IMAX, W( IMAX+1, K+1 ), 1 )
00438 ROWMAX = MAX( ROWMAX, CABS1( W( JMAX, K+1 ) ) )
00439 END IF
00440
00441 IF( ABSAKK.GE.ALPHA*COLMAX*( COLMAX / ROWMAX ) ) THEN
00442
00443
00444
00445 KP = K
00446 ELSE IF( CABS1( W( IMAX, K+1 ) ).GE.ALPHA*ROWMAX ) THEN
00447
00448
00449
00450
00451 KP = IMAX
00452
00453
00454
00455 CALL CCOPY( N-K+1, W( K, K+1 ), 1, W( K, K ), 1 )
00456 ELSE
00457
00458
00459
00460
00461 KP = IMAX
00462 KSTEP = 2
00463 END IF
00464 END IF
00465
00466 KK = K + KSTEP - 1
00467
00468
00469
00470 IF( KP.NE.KK ) THEN
00471
00472
00473
00474 A( KP, K ) = A( KK, K )
00475 CALL CCOPY( KP-K-1, A( K+1, KK ), 1, A( KP, K+1 ), LDA )
00476 CALL CCOPY( N-KP+1, A( KP, KK ), 1, A( KP, KP ), 1 )
00477
00478
00479
00480 CALL CSWAP( KK, A( KK, 1 ), LDA, A( KP, 1 ), LDA )
00481 CALL CSWAP( KK, W( KK, 1 ), LDW, W( KP, 1 ), LDW )
00482 END IF
00483
00484 IF( KSTEP.EQ.1 ) THEN
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 CALL CCOPY( N-K+1, W( K, K ), 1, A( K, K ), 1 )
00495 IF( K.LT.N ) THEN
00496 R1 = CONE / A( K, K )
00497 CALL CSCAL( N-K, R1, A( K+1, K ), 1 )
00498 END IF
00499 ELSE
00500
00501
00502
00503
00504
00505
00506
00507
00508 IF( K.LT.N-1 ) THEN
00509
00510
00511
00512 D21 = W( K+1, K )
00513 D11 = W( K+1, K+1 ) / D21
00514 D22 = W( K, K ) / D21
00515 T = CONE / ( D11*D22-CONE )
00516 D21 = T / D21
00517 DO 80 J = K + 2, N
00518 A( J, K ) = D21*( D11*W( J, K )-W( J, K+1 ) )
00519 A( J, K+1 ) = D21*( D22*W( J, K+1 )-W( J, K ) )
00520 80 CONTINUE
00521 END IF
00522
00523
00524
00525 A( K, K ) = W( K, K )
00526 A( K+1, K ) = W( K+1, K )
00527 A( K+1, K+1 ) = W( K+1, K+1 )
00528 END IF
00529 END IF
00530
00531
00532
00533 IF( KSTEP.EQ.1 ) THEN
00534 IPIV( K ) = KP
00535 ELSE
00536 IPIV( K ) = -KP
00537 IPIV( K+1 ) = -KP
00538 END IF
00539
00540
00541
00542 K = K + KSTEP
00543 GO TO 70
00544
00545 90 CONTINUE
00546
00547
00548
00549
00550
00551
00552
00553 DO 110 J = K, N, NB
00554 JB = MIN( NB, N-J+1 )
00555
00556
00557
00558 DO 100 JJ = J, J + JB - 1
00559 CALL CGEMV( 'No transpose', J+JB-JJ, K-1, -CONE,
00560 $ A( JJ, 1 ), LDA, W( JJ, 1 ), LDW, CONE,
00561 $ A( JJ, JJ ), 1 )
00562 100 CONTINUE
00563
00564
00565
00566 IF( J+JB.LE.N )
00567 $ CALL CGEMM( 'No transpose', 'Transpose', N-J-JB+1, JB,
00568 $ K-1, -CONE, A( J+JB, 1 ), LDA, W( J, 1 ),
00569 $ LDW, CONE, A( J+JB, J ), LDA )
00570 110 CONTINUE
00571
00572
00573
00574
00575 J = K - 1
00576 120 CONTINUE
00577 JJ = J
00578 JP = IPIV( J )
00579 IF( JP.LT.0 ) THEN
00580 JP = -JP
00581 J = J - 1
00582 END IF
00583 J = J - 1
00584 IF( JP.NE.JJ .AND. J.GE.1 )
00585 $ CALL CSWAP( J, A( JP, 1 ), LDA, A( JJ, 1 ), LDA )
00586 IF( J.GE.1 )
00587 $ GO TO 120
00588
00589
00590
00591 KB = K - 1
00592
00593 END IF
00594 RETURN
00595
00596
00597
00598 END