00001 SUBROUTINE ZTREVC( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,
00002 $ LDVR, MM, M, WORK, RWORK, INFO )
00003
00004
00005
00006
00007
00008
00009
00010 CHARACTER HOWMNY, SIDE
00011 INTEGER INFO, LDT, LDVL, LDVR, M, MM, N
00012
00013
00014 LOGICAL SELECT( * )
00015 DOUBLE PRECISION RWORK( * )
00016 COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
00017 $ WORK( * )
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
00136
00137
00138
00139
00140
00141 DOUBLE PRECISION ZERO, ONE
00142 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00143 COMPLEX*16 CMZERO, CMONE
00144 PARAMETER ( CMZERO = ( 0.0D+0, 0.0D+0 ),
00145 $ CMONE = ( 1.0D+0, 0.0D+0 ) )
00146
00147
00148 LOGICAL ALLV, BOTHV, LEFTV, OVER, RIGHTV, SOMEV
00149 INTEGER I, II, IS, J, K, KI
00150 DOUBLE PRECISION OVFL, REMAX, SCALE, SMIN, SMLNUM, ULP, UNFL
00151 COMPLEX*16 CDUM
00152
00153
00154 LOGICAL LSAME
00155 INTEGER IZAMAX
00156 DOUBLE PRECISION DLAMCH, DZASUM
00157 EXTERNAL LSAME, IZAMAX, DLAMCH, DZASUM
00158
00159
00160 EXTERNAL XERBLA, ZCOPY, ZDSCAL, ZGEMV, ZLATRS
00161
00162
00163 INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX
00164
00165
00166 DOUBLE PRECISION CABS1
00167
00168
00169 CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
00170
00171
00172
00173
00174
00175 BOTHV = LSAME( SIDE, 'B' )
00176 RIGHTV = LSAME( SIDE, 'R' ) .OR. BOTHV
00177 LEFTV = LSAME( SIDE, 'L' ) .OR. BOTHV
00178
00179 ALLV = LSAME( HOWMNY, 'A' )
00180 OVER = LSAME( HOWMNY, 'B' )
00181 SOMEV = LSAME( HOWMNY, 'S' )
00182
00183
00184
00185
00186 IF( SOMEV ) THEN
00187 M = 0
00188 DO 10 J = 1, N
00189 IF( SELECT( J ) )
00190 $ M = M + 1
00191 10 CONTINUE
00192 ELSE
00193 M = N
00194 END IF
00195
00196 INFO = 0
00197 IF( .NOT.RIGHTV .AND. .NOT.LEFTV ) THEN
00198 INFO = -1
00199 ELSE IF( .NOT.ALLV .AND. .NOT.OVER .AND. .NOT.SOMEV ) THEN
00200 INFO = -2
00201 ELSE IF( N.LT.0 ) THEN
00202 INFO = -4
00203 ELSE IF( LDT.LT.MAX( 1, N ) ) THEN
00204 INFO = -6
00205 ELSE IF( LDVL.LT.1 .OR. ( LEFTV .AND. LDVL.LT.N ) ) THEN
00206 INFO = -8
00207 ELSE IF( LDVR.LT.1 .OR. ( RIGHTV .AND. LDVR.LT.N ) ) THEN
00208 INFO = -10
00209 ELSE IF( MM.LT.M ) THEN
00210 INFO = -11
00211 END IF
00212 IF( INFO.NE.0 ) THEN
00213 CALL XERBLA( 'ZTREVC', -INFO )
00214 RETURN
00215 END IF
00216
00217
00218
00219 IF( N.EQ.0 )
00220 $ RETURN
00221
00222
00223
00224 UNFL = DLAMCH( 'Safe minimum' )
00225 OVFL = ONE / UNFL
00226 CALL DLABAD( UNFL, OVFL )
00227 ULP = DLAMCH( 'Precision' )
00228 SMLNUM = UNFL*( N / ULP )
00229
00230
00231
00232 DO 20 I = 1, N
00233 WORK( I+N ) = T( I, I )
00234 20 CONTINUE
00235
00236
00237
00238
00239 RWORK( 1 ) = ZERO
00240 DO 30 J = 2, N
00241 RWORK( J ) = DZASUM( J-1, T( 1, J ), 1 )
00242 30 CONTINUE
00243
00244 IF( RIGHTV ) THEN
00245
00246
00247
00248 IS = M
00249 DO 80 KI = N, 1, -1
00250
00251 IF( SOMEV ) THEN
00252 IF( .NOT.SELECT( KI ) )
00253 $ GO TO 80
00254 END IF
00255 SMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )
00256
00257 WORK( 1 ) = CMONE
00258
00259
00260
00261 DO 40 K = 1, KI - 1
00262 WORK( K ) = -T( K, KI )
00263 40 CONTINUE
00264
00265
00266
00267
00268 DO 50 K = 1, KI - 1
00269 T( K, K ) = T( K, K ) - T( KI, KI )
00270 IF( CABS1( T( K, K ) ).LT.SMIN )
00271 $ T( K, K ) = SMIN
00272 50 CONTINUE
00273
00274 IF( KI.GT.1 ) THEN
00275 CALL ZLATRS( 'Upper', 'No transpose', 'Non-unit', 'Y',
00276 $ KI-1, T, LDT, WORK( 1 ), SCALE, RWORK,
00277 $ INFO )
00278 WORK( KI ) = SCALE
00279 END IF
00280
00281
00282
00283 IF( .NOT.OVER ) THEN
00284 CALL ZCOPY( KI, WORK( 1 ), 1, VR( 1, IS ), 1 )
00285
00286 II = IZAMAX( KI, VR( 1, IS ), 1 )
00287 REMAX = ONE / CABS1( VR( II, IS ) )
00288 CALL ZDSCAL( KI, REMAX, VR( 1, IS ), 1 )
00289
00290 DO 60 K = KI + 1, N
00291 VR( K, IS ) = CMZERO
00292 60 CONTINUE
00293 ELSE
00294 IF( KI.GT.1 )
00295 $ CALL ZGEMV( 'N', N, KI-1, CMONE, VR, LDVR, WORK( 1 ),
00296 $ 1, DCMPLX( SCALE ), VR( 1, KI ), 1 )
00297
00298 II = IZAMAX( N, VR( 1, KI ), 1 )
00299 REMAX = ONE / CABS1( VR( II, KI ) )
00300 CALL ZDSCAL( N, REMAX, VR( 1, KI ), 1 )
00301 END IF
00302
00303
00304
00305 DO 70 K = 1, KI - 1
00306 T( K, K ) = WORK( K+N )
00307 70 CONTINUE
00308
00309 IS = IS - 1
00310 80 CONTINUE
00311 END IF
00312
00313 IF( LEFTV ) THEN
00314
00315
00316
00317 IS = 1
00318 DO 130 KI = 1, N
00319
00320 IF( SOMEV ) THEN
00321 IF( .NOT.SELECT( KI ) )
00322 $ GO TO 130
00323 END IF
00324 SMIN = MAX( ULP*( CABS1( T( KI, KI ) ) ), SMLNUM )
00325
00326 WORK( N ) = CMONE
00327
00328
00329
00330 DO 90 K = KI + 1, N
00331 WORK( K ) = -DCONJG( T( KI, K ) )
00332 90 CONTINUE
00333
00334
00335
00336
00337 DO 100 K = KI + 1, N
00338 T( K, K ) = T( K, K ) - T( KI, KI )
00339 IF( CABS1( T( K, K ) ).LT.SMIN )
00340 $ T( K, K ) = SMIN
00341 100 CONTINUE
00342
00343 IF( KI.LT.N ) THEN
00344 CALL ZLATRS( 'Upper', 'Conjugate transpose', 'Non-unit',
00345 $ 'Y', N-KI, T( KI+1, KI+1 ), LDT,
00346 $ WORK( KI+1 ), SCALE, RWORK, INFO )
00347 WORK( KI ) = SCALE
00348 END IF
00349
00350
00351
00352 IF( .NOT.OVER ) THEN
00353 CALL ZCOPY( N-KI+1, WORK( KI ), 1, VL( KI, IS ), 1 )
00354
00355 II = IZAMAX( N-KI+1, VL( KI, IS ), 1 ) + KI - 1
00356 REMAX = ONE / CABS1( VL( II, IS ) )
00357 CALL ZDSCAL( N-KI+1, REMAX, VL( KI, IS ), 1 )
00358
00359 DO 110 K = 1, KI - 1
00360 VL( K, IS ) = CMZERO
00361 110 CONTINUE
00362 ELSE
00363 IF( KI.LT.N )
00364 $ CALL ZGEMV( 'N', N, N-KI, CMONE, VL( 1, KI+1 ), LDVL,
00365 $ WORK( KI+1 ), 1, DCMPLX( SCALE ),
00366 $ VL( 1, KI ), 1 )
00367
00368 II = IZAMAX( N, VL( 1, KI ), 1 )
00369 REMAX = ONE / CABS1( VL( II, KI ) )
00370 CALL ZDSCAL( N, REMAX, VL( 1, KI ), 1 )
00371 END IF
00372
00373
00374
00375 DO 120 K = KI + 1, N
00376 T( K, K ) = WORK( K+N )
00377 120 CONTINUE
00378
00379 IS = IS + 1
00380 130 CONTINUE
00381 END IF
00382
00383 RETURN
00384
00385
00386
00387 END