239 SUBROUTINE dbdsqr( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
240 $ LDU, C, LDC, WORK, INFO )
248 INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU
251 DOUBLE PRECISION C( LDC, * ), D( * ), E( * ), U( LDU, * ),
252 $ vt( ldvt, * ), work( * )
258 DOUBLE PRECISION ZERO
259 parameter( zero = 0.0d0 )
261 parameter( one = 1.0d0 )
262 DOUBLE PRECISION NEGONE
263 parameter( negone = -1.0d0 )
264 DOUBLE PRECISION HNDRTH
265 parameter( hndrth = 0.01d0 )
267 parameter( ten = 10.0d0 )
268 DOUBLE PRECISION HNDRD
269 parameter( hndrd = 100.0d0 )
270 DOUBLE PRECISION MEIGTH
271 parameter( meigth = -0.125d0 )
273 parameter( maxitr = 6 )
276 LOGICAL LOWER, ROTATE
277 INTEGER I, IDIR, ISUB, ITER, ITERDIVN, J, LL, LLL, M,
278 $ maxitdivn, nm1, nm12, nm13, oldll, oldm
279 DOUBLE PRECISION ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,
280 $ oldcs, oldsn, r, shift, sigmn, sigmx, sinl,
281 $ sinr, sll, smax, smin, sminoa,
282 $ sn, thresh, tol, tolmul, unfl
286 DOUBLE PRECISION DLAMCH
287 EXTERNAL lsame, dlamch
294 INTRINSIC abs, dble, max, min, sign, sqrt
301 lower = lsame( uplo,
'L' )
302 IF( .NOT.lsame( uplo,
'U' ) .AND. .NOT.lower )
THEN
304 ELSE IF( n.LT.0 )
THEN
306 ELSE IF( ncvt.LT.0 )
THEN
308 ELSE IF( nru.LT.0 )
THEN
310 ELSE IF( ncc.LT.0 )
THEN
312 ELSE IF( ( ncvt.EQ.0 .AND. ldvt.LT.1 ) .OR.
313 $ ( ncvt.GT.0 .AND. ldvt.LT.max( 1, n ) ) )
THEN
315 ELSE IF( ldu.LT.max( 1, nru ) )
THEN
317 ELSE IF( ( ncc.EQ.0 .AND. ldc.LT.1 ) .OR.
318 $ ( ncc.GT.0 .AND. ldc.LT.max( 1, n ) ) )
THEN
322 CALL xerbla(
'DBDSQR', -info )
332 rotate = ( ncvt.GT.0 ) .OR. ( nru.GT.0 ) .OR. ( ncc.GT.0 )
336 IF( .NOT.rotate )
THEN
337 CALL dlasq1( n, d, e, work, info )
341 IF( info .NE. 2 )
RETURN
352 eps = dlamch(
'Epsilon' )
353 unfl = dlamch(
'Safe minimum' )
360 CALL dlartg( d( i ), e( i ), cs, sn, r )
363 d( i+1 ) = cs*d( i+1 )
371 $
CALL dlasr(
'R',
'V',
'F', nru, n, work( 1 ), work( n ), u,
374 $
CALL dlasr(
'L',
'V',
'F', n, ncc, work( 1 ), work( n ), c,
382 tolmul = max( ten, min( hndrd, eps**meigth ) )
389 smax = max( smax, abs( d( i ) ) )
392 smax = max( smax, abs( e( i ) ) )
395 IF( tol.GE.zero )
THEN
399 sminoa = abs( d( 1 ) )
404 mu = abs( d( i ) )*( mu / ( mu+abs( e( i-1 ) ) ) )
405 sminoa = min( sminoa, mu )
410 sminoa = sminoa / sqrt( dble( n ) )
411 thresh = max( tol*sminoa, maxitr*(n*(n*unfl)) )
416 thresh = max( abs( tol )*smax, maxitr*(n*(n*unfl)) )
444 iterdivn = iterdivn + 1
445 IF( iterdivn.GE.maxitdivn )
451 IF( tol.LT.zero .AND. abs( d( m ) ).LE.thresh )
456 abss = abs( d( ll ) )
457 abse = abs( e( ll ) )
458 IF( tol.LT.zero .AND. abss.LE.thresh )
462 smax = max( smax, abss, abse )
487 CALL dlasv2( d( m-1 ), e( m-1 ), d( m ), sigmn, sigmx, sinr,
496 $
CALL drot( ncvt, vt( m-1, 1 ), ldvt, vt( m, 1 ), ldvt, cosr,
499 $
CALL drot( nru, u( 1, m-1 ), 1, u( 1, m ), 1, cosl, sinl )
501 $
CALL drot( ncc, c( m-1, 1 ), ldc, c( m, 1 ), ldc, cosl,
510 IF( ll.GT.oldm .OR. m.LT.oldll )
THEN
511 IF( abs( d( ll ) ).GE.abs( d( m ) ) )
THEN
531 IF( abs( e( m-1 ) ).LE.abs( tol )*abs( d( m ) ) .OR.
532 $ ( tol.LT.zero .AND. abs( e( m-1 ) ).LE.thresh ) )
THEN
537 IF( tol.GE.zero )
THEN
544 DO 100 lll = ll, m - 1
545 IF( abs( e( lll ) ).LE.tol*mu )
THEN
549 mu = abs( d( lll+1 ) )*( mu / ( mu+abs( e( lll ) ) ) )
550 smin = min( smin, mu )
559 IF( abs( e( ll ) ).LE.abs( tol )*abs( d( ll ) ) .OR.
560 $ ( tol.LT.zero .AND. abs( e( ll ) ).LE.thresh ) )
THEN
565 IF( tol.GE.zero )
THEN
572 DO 110 lll = m - 1, ll, -1
573 IF( abs( e( lll ) ).LE.tol*mu )
THEN
577 mu = abs( d( lll ) )*( mu / ( mu+abs( e( lll ) ) ) )
578 smin = min( smin, mu )
588 IF( tol.GE.zero .AND. n*tol*( smin / smax ).LE.
589 $ max( eps, hndrth*tol ) )
THEN
600 CALL dlas2( d( m-1 ), e( m-1 ), d( m ), shift, r )
603 CALL dlas2( d( ll ), e( ll ), d( ll+1 ), shift, r )
608 IF( sll.GT.zero )
THEN
609 IF( ( shift / sll )**2.LT.eps )
620 IF( shift.EQ.zero )
THEN
629 CALL dlartg( d( i )*cs, e( i ), cs, sn, r )
632 CALL dlartg( oldcs*r, d( i+1 )*sn, oldcs, oldsn, d( i ) )
634 work( i-ll+1+nm1 ) = sn
635 work( i-ll+1+nm12 ) = oldcs
636 work( i-ll+1+nm13 ) = oldsn
645 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
646 $ work( n ), vt( ll, 1 ), ldvt )
648 $
CALL dlasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
649 $ work( nm13+1 ), u( 1, ll ), ldu )
651 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
652 $ work( nm13+1 ), c( ll, 1 ), ldc )
656 IF( abs( e( m-1 ) ).LE.thresh )
666 DO 130 i = m, ll + 1, -1
667 CALL dlartg( d( i )*cs, e( i-1 ), cs, sn, r )
670 CALL dlartg( oldcs*r, d( i-1 )*sn, oldcs, oldsn, d( i ) )
672 work( i-ll+nm1 ) = -sn
673 work( i-ll+nm12 ) = oldcs
674 work( i-ll+nm13 ) = -oldsn
683 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
684 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
686 $
CALL dlasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
687 $ work( n ), u( 1, ll ), ldu )
689 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
690 $ work( n ), c( ll, 1 ), ldc )
694 IF( abs( e( ll ) ).LE.thresh )
706 f = ( abs( d( ll ) )-shift )*
707 $ ( sign( one, d( ll ) )+shift / d( ll ) )
710 CALL dlartg( f, g, cosr, sinr, r )
713 f = cosr*d( i ) + sinr*e( i )
714 e( i ) = cosr*e( i ) - sinr*d( i )
716 d( i+1 ) = cosr*d( i+1 )
717 CALL dlartg( f, g, cosl, sinl, r )
719 f = cosl*e( i ) + sinl*d( i+1 )
720 d( i+1 ) = cosl*d( i+1 ) - sinl*e( i )
723 e( i+1 ) = cosl*e( i+1 )
725 work( i-ll+1 ) = cosr
726 work( i-ll+1+nm1 ) = sinr
727 work( i-ll+1+nm12 ) = cosl
728 work( i-ll+1+nm13 ) = sinl
735 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
736 $ work( n ), vt( ll, 1 ), ldvt )
738 $
CALL dlasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
739 $ work( nm13+1 ), u( 1, ll ), ldu )
741 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
742 $ work( nm13+1 ), c( ll, 1 ), ldc )
746 IF( abs( e( m-1 ) ).LE.thresh )
754 f = ( abs( d( m ) )-shift )*( sign( one, d( m ) )+shift /
757 DO 150 i = m, ll + 1, -1
758 CALL dlartg( f, g, cosr, sinr, r )
761 f = cosr*d( i ) + sinr*e( i-1 )
762 e( i-1 ) = cosr*e( i-1 ) - sinr*d( i )
764 d( i-1 ) = cosr*d( i-1 )
765 CALL dlartg( f, g, cosl, sinl, r )
767 f = cosl*e( i-1 ) + sinl*d( i-1 )
768 d( i-1 ) = cosl*d( i-1 ) - sinl*e( i-1 )
771 e( i-2 ) = cosl*e( i-2 )
774 work( i-ll+nm1 ) = -sinr
775 work( i-ll+nm12 ) = cosl
776 work( i-ll+nm13 ) = -sinl
782 IF( abs( e( ll ) ).LE.thresh )
788 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
789 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
791 $
CALL dlasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
792 $ work( n ), u( 1, ll ), ldu )
794 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
795 $ work( n ), c( ll, 1 ), ldc )
807 IF( d( i ).LT.zero )
THEN
813 $
CALL dscal( ncvt, negone, vt( i, 1 ), ldvt )
826 DO 180 j = 2, n + 1 - i
827 IF( d( j ).LE.smin )
THEN
832 IF( isub.NE.n+1-i )
THEN
836 d( isub ) = d( n+1-i )
839 $
CALL dswap( ncvt, vt( isub, 1 ), ldvt, vt( n+1-i, 1 ),
842 $
CALL dswap( nru, u( 1, isub ), 1, u( 1, n+1-i ), 1 )
844 $
CALL dswap( ncc, c( isub, 1 ), ldc, c( n+1-i, 1 ), ldc )
subroutine xerbla(srname, info)
subroutine dbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
DBDSQR
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
subroutine dlas2(f, g, h, ssmin, ssmax)
DLAS2 computes singular values of a 2-by-2 triangular matrix.
subroutine dlasq1(n, d, e, work, info)
DLASQ1 computes the singular values of a real square bidiagonal matrix. Used by sbdsqr.
subroutine dlasr(side, pivot, direct, m, n, c, s, a, lda)
DLASR applies a sequence of plane rotations to a general rectangular matrix.
subroutine dlasv2(f, g, h, ssmin, ssmax, snr, csr, snl, csl)
DLASV2 computes the singular value decomposition of a 2-by-2 triangular matrix.
subroutine drot(n, dx, incx, dy, incy, c, s)
DROT
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dswap(n, dx, incx, dy, incy)
DSWAP