00001 SUBROUTINE DSTEVX( JOBZ, RANGE, N, D, E, VL, VU, IL, IU, ABSTOL,
00002 $ M, W, Z, LDZ, WORK, IWORK, IFAIL, INFO )
00003
00004
00005
00006
00007
00008
00009
00010 CHARACTER JOBZ, RANGE
00011 INTEGER IL, INFO, IU, LDZ, M, N
00012 DOUBLE PRECISION ABSTOL, VL, VU
00013
00014
00015 INTEGER IFAIL( * ), IWORK( * )
00016 DOUBLE PRECISION D( * ), E( * ), W( * ), WORK( * ), Z( LDZ, * )
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
00138
00139 LOGICAL ALLEIG, INDEIG, TEST, VALEIG, WANTZ
00140 CHARACTER ORDER
00141 INTEGER I, IMAX, INDIBL, INDISP, INDIWO, INDWRK,
00142 $ ISCALE, ITMP1, J, JJ, NSPLIT
00143 DOUBLE PRECISION BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA, SMLNUM,
00144 $ TMP1, TNRM, VLL, VUU
00145
00146
00147 LOGICAL LSAME
00148 DOUBLE PRECISION DLAMCH, DLANST
00149 EXTERNAL LSAME, DLAMCH, DLANST
00150
00151
00152 EXTERNAL DCOPY, DSCAL, DSTEBZ, DSTEIN, DSTEQR, DSTERF,
00153 $ DSWAP, XERBLA
00154
00155
00156 INTRINSIC MAX, MIN, SQRT
00157
00158
00159
00160
00161
00162 WANTZ = LSAME( JOBZ, 'V' )
00163 ALLEIG = LSAME( RANGE, 'A' )
00164 VALEIG = LSAME( RANGE, 'V' )
00165 INDEIG = LSAME( RANGE, 'I' )
00166
00167 INFO = 0
00168 IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
00169 INFO = -1
00170 ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
00171 INFO = -2
00172 ELSE IF( N.LT.0 ) THEN
00173 INFO = -3
00174 ELSE
00175 IF( VALEIG ) THEN
00176 IF( N.GT.0 .AND. VU.LE.VL )
00177 $ INFO = -7
00178 ELSE IF( INDEIG ) THEN
00179 IF( IL.LT.1 .OR. IL.GT.MAX( 1, N ) ) THEN
00180 INFO = -8
00181 ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
00182 INFO = -9
00183 END IF
00184 END IF
00185 END IF
00186 IF( INFO.EQ.0 ) THEN
00187 IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) )
00188 $ INFO = -14
00189 END IF
00190
00191 IF( INFO.NE.0 ) THEN
00192 CALL XERBLA( 'DSTEVX', -INFO )
00193 RETURN
00194 END IF
00195
00196
00197
00198 M = 0
00199 IF( N.EQ.0 )
00200 $ RETURN
00201
00202 IF( N.EQ.1 ) THEN
00203 IF( ALLEIG .OR. INDEIG ) THEN
00204 M = 1
00205 W( 1 ) = D( 1 )
00206 ELSE
00207 IF( VL.LT.D( 1 ) .AND. VU.GE.D( 1 ) ) THEN
00208 M = 1
00209 W( 1 ) = D( 1 )
00210 END IF
00211 END IF
00212 IF( WANTZ )
00213 $ Z( 1, 1 ) = ONE
00214 RETURN
00215 END IF
00216
00217
00218
00219 SAFMIN = DLAMCH( 'Safe minimum' )
00220 EPS = DLAMCH( 'Precision' )
00221 SMLNUM = SAFMIN / EPS
00222 BIGNUM = ONE / SMLNUM
00223 RMIN = SQRT( SMLNUM )
00224 RMAX = MIN( SQRT( BIGNUM ), ONE / SQRT( SQRT( SAFMIN ) ) )
00225
00226
00227
00228 ISCALE = 0
00229 IF( VALEIG ) THEN
00230 VLL = VL
00231 VUU = VU
00232 ELSE
00233 VLL = ZERO
00234 VUU = ZERO
00235 END IF
00236 TNRM = DLANST( 'M', N, D, E )
00237 IF( TNRM.GT.ZERO .AND. TNRM.LT.RMIN ) THEN
00238 ISCALE = 1
00239 SIGMA = RMIN / TNRM
00240 ELSE IF( TNRM.GT.RMAX ) THEN
00241 ISCALE = 1
00242 SIGMA = RMAX / TNRM
00243 END IF
00244 IF( ISCALE.EQ.1 ) THEN
00245 CALL DSCAL( N, SIGMA, D, 1 )
00246 CALL DSCAL( N-1, SIGMA, E( 1 ), 1 )
00247 IF( VALEIG ) THEN
00248 VLL = VL*SIGMA
00249 VUU = VU*SIGMA
00250 END IF
00251 END IF
00252
00253
00254
00255
00256
00257 TEST = .FALSE.
00258 IF( INDEIG ) THEN
00259 IF( IL.EQ.1 .AND. IU.EQ.N ) THEN
00260 TEST = .TRUE.
00261 END IF
00262 END IF
00263 IF( ( ALLEIG .OR. TEST ) .AND. ( ABSTOL.LE.ZERO ) ) THEN
00264 CALL DCOPY( N, D, 1, W, 1 )
00265 CALL DCOPY( N-1, E( 1 ), 1, WORK( 1 ), 1 )
00266 INDWRK = N + 1
00267 IF( .NOT.WANTZ ) THEN
00268 CALL DSTERF( N, W, WORK, INFO )
00269 ELSE
00270 CALL DSTEQR( 'I', N, W, WORK, Z, LDZ, WORK( INDWRK ), INFO )
00271 IF( INFO.EQ.0 ) THEN
00272 DO 10 I = 1, N
00273 IFAIL( I ) = 0
00274 10 CONTINUE
00275 END IF
00276 END IF
00277 IF( INFO.EQ.0 ) THEN
00278 M = N
00279 GO TO 20
00280 END IF
00281 INFO = 0
00282 END IF
00283
00284
00285
00286 IF( WANTZ ) THEN
00287 ORDER = 'B'
00288 ELSE
00289 ORDER = 'E'
00290 END IF
00291 INDWRK = 1
00292 INDIBL = 1
00293 INDISP = INDIBL + N
00294 INDIWO = INDISP + N
00295 CALL DSTEBZ( RANGE, ORDER, N, VLL, VUU, IL, IU, ABSTOL, D, E, M,
00296 $ NSPLIT, W, IWORK( INDIBL ), IWORK( INDISP ),
00297 $ WORK( INDWRK ), IWORK( INDIWO ), INFO )
00298
00299 IF( WANTZ ) THEN
00300 CALL DSTEIN( N, D, E, M, W, IWORK( INDIBL ), IWORK( INDISP ),
00301 $ Z, LDZ, WORK( INDWRK ), IWORK( INDIWO ), IFAIL,
00302 $ INFO )
00303 END IF
00304
00305
00306
00307 20 CONTINUE
00308 IF( ISCALE.EQ.1 ) THEN
00309 IF( INFO.EQ.0 ) THEN
00310 IMAX = M
00311 ELSE
00312 IMAX = INFO - 1
00313 END IF
00314 CALL DSCAL( IMAX, ONE / SIGMA, W, 1 )
00315 END IF
00316
00317
00318
00319
00320 IF( WANTZ ) THEN
00321 DO 40 J = 1, M - 1
00322 I = 0
00323 TMP1 = W( J )
00324 DO 30 JJ = J + 1, M
00325 IF( W( JJ ).LT.TMP1 ) THEN
00326 I = JJ
00327 TMP1 = W( JJ )
00328 END IF
00329 30 CONTINUE
00330
00331 IF( I.NE.0 ) THEN
00332 ITMP1 = IWORK( INDIBL+I-1 )
00333 W( I ) = W( J )
00334 IWORK( INDIBL+I-1 ) = IWORK( INDIBL+J-1 )
00335 W( J ) = TMP1
00336 IWORK( INDIBL+J-1 ) = ITMP1
00337 CALL DSWAP( N, Z( 1, I ), 1, Z( 1, J ), 1 )
00338 IF( INFO.NE.0 ) THEN
00339 ITMP1 = IFAIL( I )
00340 IFAIL( I ) = IFAIL( J )
00341 IFAIL( J ) = ITMP1
00342 END IF
00343 END IF
00344 40 CONTINUE
00345 END IF
00346
00347 RETURN
00348
00349
00350
00351 END