00001 SUBROUTINE SBDSDC( UPLO, COMPQ, N, D, E, U, LDU, VT, LDVT, Q, IQ,
00002 $ WORK, IWORK, INFO )
00003
00004
00005
00006
00007
00008
00009
00010 CHARACTER COMPQ, UPLO
00011 INTEGER INFO, LDU, LDVT, N
00012
00013
00014 INTEGER IQ( * ), IWORK( * )
00015 REAL D( * ), E( * ), Q( * ), U( LDU, * ),
00016 $ VT( LDVT, * ), WORK( * )
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
00136
00137 REAL ZERO, ONE, TWO
00138 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
00139
00140
00141 INTEGER DIFL, DIFR, GIVCOL, GIVNUM, GIVPTR, I, IC,
00142 $ ICOMPQ, IERR, II, IS, IU, IUPLO, IVT, J, K, KK,
00143 $ MLVL, NM1, NSIZE, PERM, POLES, QSTART, SMLSIZ,
00144 $ SMLSZP, SQRE, START, WSTART, Z
00145 REAL CS, EPS, ORGNRM, P, R, SN
00146
00147
00148 LOGICAL LSAME
00149 INTEGER ILAENV
00150 REAL SLAMCH, SLANST
00151 EXTERNAL SLAMCH, SLANST, ILAENV, LSAME
00152
00153
00154 EXTERNAL SCOPY, SLARTG, SLASCL, SLASD0, SLASDA, SLASDQ,
00155 $ SLASET, SLASR, SSWAP, XERBLA
00156
00157
00158 INTRINSIC REAL, ABS, INT, LOG, SIGN
00159
00160
00161
00162
00163
00164 INFO = 0
00165
00166 IUPLO = 0
00167 IF( LSAME( UPLO, 'U' ) )
00168 $ IUPLO = 1
00169 IF( LSAME( UPLO, 'L' ) )
00170 $ IUPLO = 2
00171 IF( LSAME( COMPQ, 'N' ) ) THEN
00172 ICOMPQ = 0
00173 ELSE IF( LSAME( COMPQ, 'P' ) ) THEN
00174 ICOMPQ = 1
00175 ELSE IF( LSAME( COMPQ, 'I' ) ) THEN
00176 ICOMPQ = 2
00177 ELSE
00178 ICOMPQ = -1
00179 END IF
00180 IF( IUPLO.EQ.0 ) THEN
00181 INFO = -1
00182 ELSE IF( ICOMPQ.LT.0 ) THEN
00183 INFO = -2
00184 ELSE IF( N.LT.0 ) THEN
00185 INFO = -3
00186 ELSE IF( ( LDU.LT.1 ) .OR. ( ( ICOMPQ.EQ.2 ) .AND. ( LDU.LT.
00187 $ N ) ) ) THEN
00188 INFO = -7
00189 ELSE IF( ( LDVT.LT.1 ) .OR. ( ( ICOMPQ.EQ.2 ) .AND. ( LDVT.LT.
00190 $ N ) ) ) THEN
00191 INFO = -9
00192 END IF
00193 IF( INFO.NE.0 ) THEN
00194 CALL XERBLA( 'SBDSDC', -INFO )
00195 RETURN
00196 END IF
00197
00198
00199
00200 IF( N.EQ.0 )
00201 $ RETURN
00202 SMLSIZ = ILAENV( 9, 'SBDSDC', ' ', 0, 0, 0, 0 )
00203 IF( N.EQ.1 ) THEN
00204 IF( ICOMPQ.EQ.1 ) THEN
00205 Q( 1 ) = SIGN( ONE, D( 1 ) )
00206 Q( 1+SMLSIZ*N ) = ONE
00207 ELSE IF( ICOMPQ.EQ.2 ) THEN
00208 U( 1, 1 ) = SIGN( ONE, D( 1 ) )
00209 VT( 1, 1 ) = ONE
00210 END IF
00211 D( 1 ) = ABS( D( 1 ) )
00212 RETURN
00213 END IF
00214 NM1 = N - 1
00215
00216
00217
00218
00219 WSTART = 1
00220 QSTART = 3
00221 IF( ICOMPQ.EQ.1 ) THEN
00222 CALL SCOPY( N, D, 1, Q( 1 ), 1 )
00223 CALL SCOPY( N-1, E, 1, Q( N+1 ), 1 )
00224 END IF
00225 IF( IUPLO.EQ.2 ) THEN
00226 QSTART = 5
00227 WSTART = 2*N - 1
00228 DO 10 I = 1, N - 1
00229 CALL SLARTG( D( I ), E( I ), CS, SN, R )
00230 D( I ) = R
00231 E( I ) = SN*D( I+1 )
00232 D( I+1 ) = CS*D( I+1 )
00233 IF( ICOMPQ.EQ.1 ) THEN
00234 Q( I+2*N ) = CS
00235 Q( I+3*N ) = SN
00236 ELSE IF( ICOMPQ.EQ.2 ) THEN
00237 WORK( I ) = CS
00238 WORK( NM1+I ) = -SN
00239 END IF
00240 10 CONTINUE
00241 END IF
00242
00243
00244
00245 IF( ICOMPQ.EQ.0 ) THEN
00246 CALL SLASDQ( 'U', 0, N, 0, 0, 0, D, E, VT, LDVT, U, LDU, U,
00247 $ LDU, WORK( WSTART ), INFO )
00248 GO TO 40
00249 END IF
00250
00251
00252
00253
00254 IF( N.LE.SMLSIZ ) THEN
00255 IF( ICOMPQ.EQ.2 ) THEN
00256 CALL SLASET( 'A', N, N, ZERO, ONE, U, LDU )
00257 CALL SLASET( 'A', N, N, ZERO, ONE, VT, LDVT )
00258 CALL SLASDQ( 'U', 0, N, N, N, 0, D, E, VT, LDVT, U, LDU, U,
00259 $ LDU, WORK( WSTART ), INFO )
00260 ELSE IF( ICOMPQ.EQ.1 ) THEN
00261 IU = 1
00262 IVT = IU + N
00263 CALL SLASET( 'A', N, N, ZERO, ONE, Q( IU+( QSTART-1 )*N ),
00264 $ N )
00265 CALL SLASET( 'A', N, N, ZERO, ONE, Q( IVT+( QSTART-1 )*N ),
00266 $ N )
00267 CALL SLASDQ( 'U', 0, N, N, N, 0, D, E,
00268 $ Q( IVT+( QSTART-1 )*N ), N,
00269 $ Q( IU+( QSTART-1 )*N ), N,
00270 $ Q( IU+( QSTART-1 )*N ), N, WORK( WSTART ),
00271 $ INFO )
00272 END IF
00273 GO TO 40
00274 END IF
00275
00276 IF( ICOMPQ.EQ.2 ) THEN
00277 CALL SLASET( 'A', N, N, ZERO, ONE, U, LDU )
00278 CALL SLASET( 'A', N, N, ZERO, ONE, VT, LDVT )
00279 END IF
00280
00281
00282
00283 ORGNRM = SLANST( 'M', N, D, E )
00284 IF( ORGNRM.EQ.ZERO )
00285 $ RETURN
00286 CALL SLASCL( 'G', 0, 0, ORGNRM, ONE, N, 1, D, N, IERR )
00287 CALL SLASCL( 'G', 0, 0, ORGNRM, ONE, NM1, 1, E, NM1, IERR )
00288
00289 EPS = SLAMCH( 'Epsilon' )
00290
00291 MLVL = INT( LOG( REAL( N ) / REAL( SMLSIZ+1 ) ) / LOG( TWO ) ) + 1
00292 SMLSZP = SMLSIZ + 1
00293
00294 IF( ICOMPQ.EQ.1 ) THEN
00295 IU = 1
00296 IVT = 1 + SMLSIZ
00297 DIFL = IVT + SMLSZP
00298 DIFR = DIFL + MLVL
00299 Z = DIFR + MLVL*2
00300 IC = Z + MLVL
00301 IS = IC + 1
00302 POLES = IS + 1
00303 GIVNUM = POLES + 2*MLVL
00304
00305 K = 1
00306 GIVPTR = 2
00307 PERM = 3
00308 GIVCOL = PERM + MLVL
00309 END IF
00310
00311 DO 20 I = 1, N
00312 IF( ABS( D( I ) ).LT.EPS ) THEN
00313 D( I ) = SIGN( EPS, D( I ) )
00314 END IF
00315 20 CONTINUE
00316
00317 START = 1
00318 SQRE = 0
00319
00320 DO 30 I = 1, NM1
00321 IF( ( ABS( E( I ) ).LT.EPS ) .OR. ( I.EQ.NM1 ) ) THEN
00322
00323
00324
00325
00326 IF( I.LT.NM1 ) THEN
00327
00328
00329
00330 NSIZE = I - START + 1
00331 ELSE IF( ABS( E( I ) ).GE.EPS ) THEN
00332
00333
00334
00335 NSIZE = N - START + 1
00336 ELSE
00337
00338
00339
00340
00341
00342 NSIZE = I - START + 1
00343 IF( ICOMPQ.EQ.2 ) THEN
00344 U( N, N ) = SIGN( ONE, D( N ) )
00345 VT( N, N ) = ONE
00346 ELSE IF( ICOMPQ.EQ.1 ) THEN
00347 Q( N+( QSTART-1 )*N ) = SIGN( ONE, D( N ) )
00348 Q( N+( SMLSIZ+QSTART-1 )*N ) = ONE
00349 END IF
00350 D( N ) = ABS( D( N ) )
00351 END IF
00352 IF( ICOMPQ.EQ.2 ) THEN
00353 CALL SLASD0( NSIZE, SQRE, D( START ), E( START ),
00354 $ U( START, START ), LDU, VT( START, START ),
00355 $ LDVT, SMLSIZ, IWORK, WORK( WSTART ), INFO )
00356 ELSE
00357 CALL SLASDA( ICOMPQ, SMLSIZ, NSIZE, SQRE, D( START ),
00358 $ E( START ), Q( START+( IU+QSTART-2 )*N ), N,
00359 $ Q( START+( IVT+QSTART-2 )*N ),
00360 $ IQ( START+K*N ), Q( START+( DIFL+QSTART-2 )*
00361 $ N ), Q( START+( DIFR+QSTART-2 )*N ),
00362 $ Q( START+( Z+QSTART-2 )*N ),
00363 $ Q( START+( POLES+QSTART-2 )*N ),
00364 $ IQ( START+GIVPTR*N ), IQ( START+GIVCOL*N ),
00365 $ N, IQ( START+PERM*N ),
00366 $ Q( START+( GIVNUM+QSTART-2 )*N ),
00367 $ Q( START+( IC+QSTART-2 )*N ),
00368 $ Q( START+( IS+QSTART-2 )*N ),
00369 $ WORK( WSTART ), IWORK, INFO )
00370 END IF
00371 IF( INFO.NE.0 ) THEN
00372 RETURN
00373 END IF
00374 START = I + 1
00375 END IF
00376 30 CONTINUE
00377
00378
00379
00380 CALL SLASCL( 'G', 0, 0, ONE, ORGNRM, N, 1, D, N, IERR )
00381 40 CONTINUE
00382
00383
00384
00385 DO 60 II = 2, N
00386 I = II - 1
00387 KK = I
00388 P = D( I )
00389 DO 50 J = II, N
00390 IF( D( J ).GT.P ) THEN
00391 KK = J
00392 P = D( J )
00393 END IF
00394 50 CONTINUE
00395 IF( KK.NE.I ) THEN
00396 D( KK ) = D( I )
00397 D( I ) = P
00398 IF( ICOMPQ.EQ.1 ) THEN
00399 IQ( I ) = KK
00400 ELSE IF( ICOMPQ.EQ.2 ) THEN
00401 CALL SSWAP( N, U( 1, I ), 1, U( 1, KK ), 1 )
00402 CALL SSWAP( N, VT( I, 1 ), LDVT, VT( KK, 1 ), LDVT )
00403 END IF
00404 ELSE IF( ICOMPQ.EQ.1 ) THEN
00405 IQ( I ) = I
00406 END IF
00407 60 CONTINUE
00408
00409
00410
00411 IF( ICOMPQ.EQ.1 ) THEN
00412 IF( IUPLO.EQ.1 ) THEN
00413 IQ( N ) = 1
00414 ELSE
00415 IQ( N ) = 0
00416 END IF
00417 END IF
00418
00419
00420
00421
00422 IF( ( IUPLO.EQ.2 ) .AND. ( ICOMPQ.EQ.2 ) )
00423 $ CALL SLASR( 'L', 'V', 'B', N, N, WORK( 1 ), WORK( N ), U, LDU )
00424
00425 RETURN
00426
00427
00428
00429 END