00001 SUBROUTINE SLAED0( ICOMPQ, QSIZ, N, D, E, Q, LDQ, QSTORE, LDQS,
00002 $ WORK, IWORK, INFO )
00003
00004
00005
00006
00007
00008
00009
00010 INTEGER ICOMPQ, INFO, LDQ, LDQS, N, QSIZ
00011
00012
00013 INTEGER IWORK( * )
00014 REAL D( * ), E( * ), Q( LDQ, * ), QSTORE( LDQS, * ),
00015 $ WORK( * )
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 REAL ZERO, ONE, TWO
00109 PARAMETER ( ZERO = 0.E0, ONE = 1.E0, TWO = 2.E0 )
00110
00111
00112 INTEGER CURLVL, CURPRB, CURR, I, IGIVCL, IGIVNM,
00113 $ IGIVPT, INDXQ, IPERM, IPRMPT, IQ, IQPTR, IWREM,
00114 $ J, K, LGN, MATSIZ, MSD2, SMLSIZ, SMM1, SPM1,
00115 $ SPM2, SUBMAT, SUBPBS, TLVLS
00116 REAL TEMP
00117
00118
00119 EXTERNAL SCOPY, SGEMM, SLACPY, SLAED1, SLAED7, SSTEQR,
00120 $ XERBLA
00121
00122
00123 INTEGER ILAENV
00124 EXTERNAL ILAENV
00125
00126
00127 INTRINSIC ABS, INT, LOG, MAX, REAL
00128
00129
00130
00131
00132
00133 INFO = 0
00134
00135 IF( ICOMPQ.LT.0 .OR. ICOMPQ.GT.2 ) THEN
00136 INFO = -1
00137 ELSE IF( ( ICOMPQ.EQ.1 ) .AND. ( QSIZ.LT.MAX( 0, N ) ) ) THEN
00138 INFO = -2
00139 ELSE IF( N.LT.0 ) THEN
00140 INFO = -3
00141 ELSE IF( LDQ.LT.MAX( 1, N ) ) THEN
00142 INFO = -7
00143 ELSE IF( LDQS.LT.MAX( 1, N ) ) THEN
00144 INFO = -9
00145 END IF
00146 IF( INFO.NE.0 ) THEN
00147 CALL XERBLA( 'SLAED0', -INFO )
00148 RETURN
00149 END IF
00150
00151
00152
00153 IF( N.EQ.0 )
00154 $ RETURN
00155
00156 SMLSIZ = ILAENV( 9, 'SLAED0', ' ', 0, 0, 0, 0 )
00157
00158
00159
00160
00161 IWORK( 1 ) = N
00162 SUBPBS = 1
00163 TLVLS = 0
00164 10 CONTINUE
00165 IF( IWORK( SUBPBS ).GT.SMLSIZ ) THEN
00166 DO 20 J = SUBPBS, 1, -1
00167 IWORK( 2*J ) = ( IWORK( J )+1 ) / 2
00168 IWORK( 2*J-1 ) = IWORK( J ) / 2
00169 20 CONTINUE
00170 TLVLS = TLVLS + 1
00171 SUBPBS = 2*SUBPBS
00172 GO TO 10
00173 END IF
00174 DO 30 J = 2, SUBPBS
00175 IWORK( J ) = IWORK( J ) + IWORK( J-1 )
00176 30 CONTINUE
00177
00178
00179
00180
00181 SPM1 = SUBPBS - 1
00182 DO 40 I = 1, SPM1
00183 SUBMAT = IWORK( I ) + 1
00184 SMM1 = SUBMAT - 1
00185 D( SMM1 ) = D( SMM1 ) - ABS( E( SMM1 ) )
00186 D( SUBMAT ) = D( SUBMAT ) - ABS( E( SMM1 ) )
00187 40 CONTINUE
00188
00189 INDXQ = 4*N + 3
00190 IF( ICOMPQ.NE.2 ) THEN
00191
00192
00193
00194
00195 TEMP = LOG( REAL( N ) ) / LOG( TWO )
00196 LGN = INT( TEMP )
00197 IF( 2**LGN.LT.N )
00198 $ LGN = LGN + 1
00199 IF( 2**LGN.LT.N )
00200 $ LGN = LGN + 1
00201 IPRMPT = INDXQ + N + 1
00202 IPERM = IPRMPT + N*LGN
00203 IQPTR = IPERM + N*LGN
00204 IGIVPT = IQPTR + N + 2
00205 IGIVCL = IGIVPT + N*LGN
00206
00207 IGIVNM = 1
00208 IQ = IGIVNM + 2*N*LGN
00209 IWREM = IQ + N**2 + 1
00210
00211
00212
00213 DO 50 I = 0, SUBPBS
00214 IWORK( IPRMPT+I ) = 1
00215 IWORK( IGIVPT+I ) = 1
00216 50 CONTINUE
00217 IWORK( IQPTR ) = 1
00218 END IF
00219
00220
00221
00222
00223 CURR = 0
00224 DO 70 I = 0, SPM1
00225 IF( I.EQ.0 ) THEN
00226 SUBMAT = 1
00227 MATSIZ = IWORK( 1 )
00228 ELSE
00229 SUBMAT = IWORK( I ) + 1
00230 MATSIZ = IWORK( I+1 ) - IWORK( I )
00231 END IF
00232 IF( ICOMPQ.EQ.2 ) THEN
00233 CALL SSTEQR( 'I', MATSIZ, D( SUBMAT ), E( SUBMAT ),
00234 $ Q( SUBMAT, SUBMAT ), LDQ, WORK, INFO )
00235 IF( INFO.NE.0 )
00236 $ GO TO 130
00237 ELSE
00238 CALL SSTEQR( 'I', MATSIZ, D( SUBMAT ), E( SUBMAT ),
00239 $ WORK( IQ-1+IWORK( IQPTR+CURR ) ), MATSIZ, WORK,
00240 $ INFO )
00241 IF( INFO.NE.0 )
00242 $ GO TO 130
00243 IF( ICOMPQ.EQ.1 ) THEN
00244 CALL SGEMM( 'N', 'N', QSIZ, MATSIZ, MATSIZ, ONE,
00245 $ Q( 1, SUBMAT ), LDQ, WORK( IQ-1+IWORK( IQPTR+
00246 $ CURR ) ), MATSIZ, ZERO, QSTORE( 1, SUBMAT ),
00247 $ LDQS )
00248 END IF
00249 IWORK( IQPTR+CURR+1 ) = IWORK( IQPTR+CURR ) + MATSIZ**2
00250 CURR = CURR + 1
00251 END IF
00252 K = 1
00253 DO 60 J = SUBMAT, IWORK( I+1 )
00254 IWORK( INDXQ+J ) = K
00255 K = K + 1
00256 60 CONTINUE
00257 70 CONTINUE
00258
00259
00260
00261
00262
00263
00264 CURLVL = 1
00265 80 CONTINUE
00266 IF( SUBPBS.GT.1 ) THEN
00267 SPM2 = SUBPBS - 2
00268 DO 90 I = 0, SPM2, 2
00269 IF( I.EQ.0 ) THEN
00270 SUBMAT = 1
00271 MATSIZ = IWORK( 2 )
00272 MSD2 = IWORK( 1 )
00273 CURPRB = 0
00274 ELSE
00275 SUBMAT = IWORK( I ) + 1
00276 MATSIZ = IWORK( I+2 ) - IWORK( I )
00277 MSD2 = MATSIZ / 2
00278 CURPRB = CURPRB + 1
00279 END IF
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 IF( ICOMPQ.EQ.2 ) THEN
00290 CALL SLAED1( MATSIZ, D( SUBMAT ), Q( SUBMAT, SUBMAT ),
00291 $ LDQ, IWORK( INDXQ+SUBMAT ),
00292 $ E( SUBMAT+MSD2-1 ), MSD2, WORK,
00293 $ IWORK( SUBPBS+1 ), INFO )
00294 ELSE
00295 CALL SLAED7( ICOMPQ, MATSIZ, QSIZ, TLVLS, CURLVL, CURPRB,
00296 $ D( SUBMAT ), QSTORE( 1, SUBMAT ), LDQS,
00297 $ IWORK( INDXQ+SUBMAT ), E( SUBMAT+MSD2-1 ),
00298 $ MSD2, WORK( IQ ), IWORK( IQPTR ),
00299 $ IWORK( IPRMPT ), IWORK( IPERM ),
00300 $ IWORK( IGIVPT ), IWORK( IGIVCL ),
00301 $ WORK( IGIVNM ), WORK( IWREM ),
00302 $ IWORK( SUBPBS+1 ), INFO )
00303 END IF
00304 IF( INFO.NE.0 )
00305 $ GO TO 130
00306 IWORK( I / 2+1 ) = IWORK( I+2 )
00307 90 CONTINUE
00308 SUBPBS = SUBPBS / 2
00309 CURLVL = CURLVL + 1
00310 GO TO 80
00311 END IF
00312
00313
00314
00315
00316
00317
00318 IF( ICOMPQ.EQ.1 ) THEN
00319 DO 100 I = 1, N
00320 J = IWORK( INDXQ+I )
00321 WORK( I ) = D( J )
00322 CALL SCOPY( QSIZ, QSTORE( 1, J ), 1, Q( 1, I ), 1 )
00323 100 CONTINUE
00324 CALL SCOPY( N, WORK, 1, D, 1 )
00325 ELSE IF( ICOMPQ.EQ.2 ) THEN
00326 DO 110 I = 1, N
00327 J = IWORK( INDXQ+I )
00328 WORK( I ) = D( J )
00329 CALL SCOPY( N, Q( 1, J ), 1, WORK( N*I+1 ), 1 )
00330 110 CONTINUE
00331 CALL SCOPY( N, WORK, 1, D, 1 )
00332 CALL SLACPY( 'A', N, N, WORK( N+1 ), N, Q, LDQ )
00333 ELSE
00334 DO 120 I = 1, N
00335 J = IWORK( INDXQ+I )
00336 WORK( I ) = D( J )
00337 120 CONTINUE
00338 CALL SCOPY( N, WORK, 1, D, 1 )
00339 END IF
00340 GO TO 140
00341
00342 130 CONTINUE
00343 INFO = SUBMAT*( N+1 ) + SUBMAT + MATSIZ - 1
00344
00345 140 CONTINUE
00346 RETURN
00347
00348
00349
00350 END