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