194 SUBROUTINE dbdsdc( UPLO, COMPQ, N, D, E, U, LDU, VT, LDVT, Q,
196 $ WORK, IWORK, INFO )
203 CHARACTER COMPQ, UPLO
204 INTEGER INFO, LDU, LDVT, N
207 INTEGER IQ( * ), IWORK( * )
208 DOUBLE PRECISION D( * ), E( * ), Q( * ), U( LDU, * ),
209 $ vt( ldvt, * ), work( * )
218 DOUBLE PRECISION ZERO, ONE, TWO
219 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0, two = 2.0d+0 )
222 INTEGER DIFL, DIFR, GIVCOL, GIVNUM, GIVPTR, I, IC,
223 $ ICOMPQ, IERR, II, IS, IU, IUPLO, IVT, J, K, KK,
224 $ mlvl, nm1, nsize, perm, poles, qstart, smlsiz,
225 $ smlszp, sqre, start, wstart, z
226 DOUBLE PRECISION CS, EPS, ORGNRM, P, R, SN
231 DOUBLE PRECISION DLAMCH, DLANST
232 EXTERNAL lsame, ilaenv, dlamch, dlanst
240 INTRINSIC abs, dble, int, log, sign
249 IF( lsame( uplo,
'U' ) )
251 IF( lsame( uplo,
'L' ) )
253 IF( lsame( compq,
'N' ) )
THEN
255 ELSE IF( lsame( compq,
'P' ) )
THEN
257 ELSE IF( lsame( compq,
'I' ) )
THEN
262 IF( iuplo.EQ.0 )
THEN
264 ELSE IF( icompq.LT.0 )
THEN
266 ELSE IF( n.LT.0 )
THEN
268 ELSE IF( ( ldu.LT.1 ) .OR. ( ( icompq.EQ.2 ) .AND. ( ldu.LT.
271 ELSE IF( ( ldvt.LT.1 ) .OR. ( ( icompq.EQ.2 ) .AND. ( ldvt.LT.
276 CALL xerbla(
'DBDSDC', -info )
284 smlsiz = ilaenv( 9,
'DBDSDC',
' ', 0, 0, 0, 0 )
286 IF( icompq.EQ.1 )
THEN
287 q( 1 ) = sign( one, d( 1 ) )
288 q( 1+smlsiz*n ) = one
289 ELSE IF( icompq.EQ.2 )
THEN
290 u( 1, 1 ) = sign( one, d( 1 ) )
293 d( 1 ) = abs( d( 1 ) )
303 IF( icompq.EQ.1 )
THEN
304 CALL dcopy( n, d, 1, q( 1 ), 1 )
305 CALL dcopy( n-1, e, 1, q( n+1 ), 1 )
307 IF( iuplo.EQ.2 )
THEN
309 IF( icompq .EQ. 2 ) wstart = 2*n - 1
311 CALL dlartg( d( i ), e( i ), cs, sn, r )
314 d( i+1 ) = cs*d( i+1 )
315 IF( icompq.EQ.1 )
THEN
318 ELSE IF( icompq.EQ.2 )
THEN
327 IF( icompq.EQ.0 )
THEN
331 CALL dlasdq(
'U', 0, n, 0, 0, 0, d, e, vt, ldvt, u, ldu, u,
332 $ ldu, work( 1 ), info )
339 IF( n.LE.smlsiz )
THEN
340 IF( icompq.EQ.2 )
THEN
341 CALL dlaset(
'A', n, n, zero, one, u, ldu )
342 CALL dlaset(
'A', n, n, zero, one, vt, ldvt )
343 CALL dlasdq(
'U', 0, n, n, n, 0, d, e, vt, ldvt, u, ldu,
345 $ ldu, work( wstart ), info )
346 ELSE IF( icompq.EQ.1 )
THEN
349 CALL dlaset(
'A', n, n, zero, one,
350 $ q( iu+( qstart-1 )*n ),
352 CALL dlaset(
'A', n, n, zero, one,
353 $ q( ivt+( qstart-1 )*n ),
355 CALL dlasdq(
'U', 0, n, n, n, 0, d, e,
356 $ q( ivt+( qstart-1 )*n ), n,
357 $ q( iu+( qstart-1 )*n ), n,
358 $ q( iu+( qstart-1 )*n ), n, work( wstart ),
364 IF( icompq.EQ.2 )
THEN
365 CALL dlaset(
'A', n, n, zero, one, u, ldu )
366 CALL dlaset(
'A', n, n, zero, one, vt, ldvt )
371 orgnrm = dlanst(
'M', n, d, e )
374 CALL dlascl(
'G', 0, 0, orgnrm, one, n, 1, d, n, ierr )
375 CALL dlascl(
'G', 0, 0, orgnrm, one, nm1, 1, e, nm1, ierr )
377 eps = (0.9d+0)*dlamch(
'Epsilon' )
379 mlvl = int( log( dble( n ) / dble( smlsiz+1 ) ) / log( two ) ) + 1
382 IF( icompq.EQ.1 )
THEN
391 givnum = poles + 2*mlvl
400 IF( abs( d( i ) ).LT.eps )
THEN
401 d( i ) = sign( eps, d( i ) )
409 IF( ( abs( e( i ) ).LT.eps ) .OR. ( i.EQ.nm1 ) )
THEN
418 nsize = i - start + 1
419 ELSE IF( abs( e( i ) ).GE.eps )
THEN
423 nsize = n - start + 1
430 nsize = i - start + 1
431 IF( icompq.EQ.2 )
THEN
432 u( n, n ) = sign( one, d( n ) )
434 ELSE IF( icompq.EQ.1 )
THEN
435 q( n+( qstart-1 )*n ) = sign( one, d( n ) )
436 q( n+( smlsiz+qstart-1 )*n ) = one
438 d( n ) = abs( d( n ) )
440 IF( icompq.EQ.2 )
THEN
441 CALL dlasd0( nsize, sqre, d( start ), e( start ),
442 $ u( start, start ), ldu, vt( start, start ),
443 $ ldvt, smlsiz, iwork, work( wstart ), info )
445 CALL dlasda( icompq, smlsiz, nsize, sqre, d( start ),
446 $ e( start ), q( start+( iu+qstart-2 )*n ), n,
447 $ q( start+( ivt+qstart-2 )*n ),
448 $ iq( start+k*n ), q( start+( difl+qstart-2 )*
449 $ n ), q( start+( difr+qstart-2 )*n ),
450 $ q( start+( z+qstart-2 )*n ),
451 $ q( start+( poles+qstart-2 )*n ),
452 $ iq( start+givptr*n ), iq( start+givcol*n ),
453 $ n, iq( start+perm*n ),
454 $ q( start+( givnum+qstart-2 )*n ),
455 $ q( start+( ic+qstart-2 )*n ),
456 $ q( start+( is+qstart-2 )*n ),
457 $ work( wstart ), iwork, info )
468 CALL dlascl(
'G', 0, 0, one, orgnrm, n, 1, d, n, ierr )
478 IF( d( j ).GT.p )
THEN
486 IF( icompq.EQ.1 )
THEN
488 ELSE IF( icompq.EQ.2 )
THEN
489 CALL dswap( n, u( 1, i ), 1, u( 1, kk ), 1 )
490 CALL dswap( n, vt( i, 1 ), ldvt, vt( kk, 1 ), ldvt )
492 ELSE IF( icompq.EQ.1 )
THEN
499 IF( icompq.EQ.1 )
THEN
500 IF( iuplo.EQ.1 )
THEN
510 IF( ( iuplo.EQ.2 ) .AND. ( icompq.EQ.2 ) )
511 $
CALL dlasr(
'L',
'V',
'B', n, n, work( 1 ), work( n ), u,