238 SUBROUTINE sbdsqr( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
239 $ LDU, C, LDC, WORK, INFO )
247 INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU
250 REAL C( LDC, * ), D( * ), E( * ), U( LDU, * ),
251 $ vt( ldvt, * ), work( * )
258 parameter( zero = 0.0e0 )
260 parameter( one = 1.0e0 )
262 parameter( negone = -1.0e0 )
264 parameter( hndrth = 0.01e0 )
266 parameter( ten = 10.0e0 )
268 parameter( hndrd = 100.0e0 )
270 parameter( meigth = -0.125e0 )
272 parameter( maxitr = 6 )
275 LOGICAL LOWER, ROTATE
276 INTEGER I, IDIR, ISUB, ITER, ITERDIVN, J, LL, LLL, M,
277 $ maxitdivn, nm1, nm12, nm13, oldll, oldm
278 REAL ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,
279 $ oldcs, oldsn, r, shift, sigmn, sigmx, sinl,
280 $ sinr, sll, smax, smin, sminoa,
281 $ sn, thresh, tol, tolmul, unfl
286 EXTERNAL lsame, slamch
293 INTRINSIC abs, max, min, real, sign, sqrt
300 lower = lsame( uplo,
'L' )
301 IF( .NOT.lsame( uplo,
'U' ) .AND. .NOT.lower )
THEN
303 ELSE IF( n.LT.0 )
THEN
305 ELSE IF( ncvt.LT.0 )
THEN
307 ELSE IF( nru.LT.0 )
THEN
309 ELSE IF( ncc.LT.0 )
THEN
311 ELSE IF( ( ncvt.EQ.0 .AND. ldvt.LT.1 ) .OR.
312 $ ( ncvt.GT.0 .AND. ldvt.LT.max( 1, n ) ) )
THEN
314 ELSE IF( ldu.LT.max( 1, nru ) )
THEN
316 ELSE IF( ( ncc.EQ.0 .AND. ldc.LT.1 ) .OR.
317 $ ( ncc.GT.0 .AND. ldc.LT.max( 1, n ) ) )
THEN
321 CALL xerbla(
'SBDSQR', -info )
331 rotate = ( ncvt.GT.0 ) .OR. ( nru.GT.0 ) .OR. ( ncc.GT.0 )
335 IF( .NOT.rotate )
THEN
336 CALL slasq1( n, d, e, work, info )
340 IF( info .NE. 2 )
RETURN
351 eps = slamch(
'Epsilon' )
352 unfl = slamch(
'Safe minimum' )
359 CALL slartg( d( i ), e( i ), cs, sn, r )
362 d( i+1 ) = cs*d( i+1 )
370 $
CALL slasr(
'R',
'V',
'F', nru, n, work( 1 ), work( n ), u,
373 $
CALL slasr(
'L',
'V',
'F', n, ncc, work( 1 ), work( n ), c,
381 tolmul = max( ten, min( hndrd, eps**meigth ) )
388 smax = max( smax, abs( d( i ) ) )
391 smax = max( smax, abs( e( i ) ) )
394 IF( tol.GE.zero )
THEN
398 sminoa = abs( d( 1 ) )
403 mu = abs( d( i ) )*( mu / ( mu+abs( e( i-1 ) ) ) )
404 sminoa = min( sminoa, mu )
409 sminoa = sminoa / sqrt( real( n ) )
410 thresh = max( tol*sminoa, maxitr*(n*(n*unfl)) )
415 thresh = max( abs( tol )*smax, maxitr*(n*(n*unfl)) )
443 iterdivn = iterdivn + 1
444 IF( iterdivn.GE.maxitdivn )
450 IF( tol.LT.zero .AND. abs( d( m ) ).LE.thresh )
455 abss = abs( d( ll ) )
456 abse = abs( e( ll ) )
457 IF( tol.LT.zero .AND. abss.LE.thresh )
461 smax = max( smax, abss, abse )
486 CALL slasv2( d( m-1 ), e( m-1 ), d( m ), sigmn, sigmx, sinr,
495 $
CALL srot( ncvt, vt( m-1, 1 ), ldvt, vt( m, 1 ), ldvt, cosr,
498 $
CALL srot( nru, u( 1, m-1 ), 1, u( 1, m ), 1, cosl, sinl )
500 $
CALL srot( ncc, c( m-1, 1 ), ldc, c( m, 1 ), ldc, cosl,
509 IF( ll.GT.oldm .OR. m.LT.oldll )
THEN
510 IF( abs( d( ll ) ).GE.abs( d( m ) ) )
THEN
530 IF( abs( e( m-1 ) ).LE.abs( tol )*abs( d( m ) ) .OR.
531 $ ( tol.LT.zero .AND. abs( e( m-1 ) ).LE.thresh ) )
THEN
536 IF( tol.GE.zero )
THEN
543 DO 100 lll = ll, m - 1
544 IF( abs( e( lll ) ).LE.tol*mu )
THEN
548 mu = abs( d( lll+1 ) )*( mu / ( mu+abs( e( lll ) ) ) )
549 smin = min( smin, mu )
558 IF( abs( e( ll ) ).LE.abs( tol )*abs( d( ll ) ) .OR.
559 $ ( tol.LT.zero .AND. abs( e( ll ) ).LE.thresh ) )
THEN
564 IF( tol.GE.zero )
THEN
571 DO 110 lll = m - 1, ll, -1
572 IF( abs( e( lll ) ).LE.tol*mu )
THEN
576 mu = abs( d( lll ) )*( mu / ( mu+abs( e( lll ) ) ) )
577 smin = min( smin, mu )
587 IF( tol.GE.zero .AND. n*tol*( smin / smax ).LE.
588 $ max( eps, hndrth*tol ) )
THEN
599 CALL slas2( d( m-1 ), e( m-1 ), d( m ), shift, r )
602 CALL slas2( d( ll ), e( ll ), d( ll+1 ), shift, r )
607 IF( sll.GT.zero )
THEN
608 IF( ( shift / sll )**2.LT.eps )
619 IF( shift.EQ.zero )
THEN
628 CALL slartg( d( i )*cs, e( i ), cs, sn, r )
631 CALL slartg( oldcs*r, d( i+1 )*sn, oldcs, oldsn, d( i ) )
633 work( i-ll+1+nm1 ) = sn
634 work( i-ll+1+nm12 ) = oldcs
635 work( i-ll+1+nm13 ) = oldsn
644 $
CALL slasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
645 $ work( n ), vt( ll, 1 ), ldvt )
647 $
CALL slasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
648 $ work( nm13+1 ), u( 1, ll ), ldu )
650 $
CALL slasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
651 $ work( nm13+1 ), c( ll, 1 ), ldc )
655 IF( abs( e( m-1 ) ).LE.thresh )
665 DO 130 i = m, ll + 1, -1
666 CALL slartg( d( i )*cs, e( i-1 ), cs, sn, r )
669 CALL slartg( oldcs*r, d( i-1 )*sn, oldcs, oldsn, d( i ) )
671 work( i-ll+nm1 ) = -sn
672 work( i-ll+nm12 ) = oldcs
673 work( i-ll+nm13 ) = -oldsn
682 $
CALL slasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
683 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
685 $
CALL slasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
686 $ work( n ), u( 1, ll ), ldu )
688 $
CALL slasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
689 $ work( n ), c( ll, 1 ), ldc )
693 IF( abs( e( ll ) ).LE.thresh )
705 f = ( abs( d( ll ) )-shift )*
706 $ ( sign( one, d( ll ) )+shift / d( ll ) )
709 CALL slartg( f, g, cosr, sinr, r )
712 f = cosr*d( i ) + sinr*e( i )
713 e( i ) = cosr*e( i ) - sinr*d( i )
715 d( i+1 ) = cosr*d( i+1 )
716 CALL slartg( f, g, cosl, sinl, r )
718 f = cosl*e( i ) + sinl*d( i+1 )
719 d( i+1 ) = cosl*d( i+1 ) - sinl*e( i )
722 e( i+1 ) = cosl*e( i+1 )
724 work( i-ll+1 ) = cosr
725 work( i-ll+1+nm1 ) = sinr
726 work( i-ll+1+nm12 ) = cosl
727 work( i-ll+1+nm13 ) = sinl
734 $
CALL slasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
735 $ work( n ), vt( ll, 1 ), ldvt )
737 $
CALL slasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
738 $ work( nm13+1 ), u( 1, ll ), ldu )
740 $
CALL slasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
741 $ work( nm13+1 ), c( ll, 1 ), ldc )
745 IF( abs( e( m-1 ) ).LE.thresh )
753 f = ( abs( d( m ) )-shift )*( sign( one, d( m ) )+shift /
756 DO 150 i = m, ll + 1, -1
757 CALL slartg( f, g, cosr, sinr, r )
760 f = cosr*d( i ) + sinr*e( i-1 )
761 e( i-1 ) = cosr*e( i-1 ) - sinr*d( i )
763 d( i-1 ) = cosr*d( i-1 )
764 CALL slartg( f, g, cosl, sinl, r )
766 f = cosl*e( i-1 ) + sinl*d( i-1 )
767 d( i-1 ) = cosl*d( i-1 ) - sinl*e( i-1 )
770 e( i-2 ) = cosl*e( i-2 )
773 work( i-ll+nm1 ) = -sinr
774 work( i-ll+nm12 ) = cosl
775 work( i-ll+nm13 ) = -sinl
781 IF( abs( e( ll ) ).LE.thresh )
787 $
CALL slasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
788 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
790 $
CALL slasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
791 $ work( n ), u( 1, ll ), ldu )
793 $
CALL slasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
794 $ work( n ), c( ll, 1 ), ldc )
806 IF( d( i ).LT.zero )
THEN
812 $
CALL sscal( ncvt, negone, vt( i, 1 ), ldvt )
825 DO 180 j = 2, n + 1 - i
826 IF( d( j ).LE.smin )
THEN
831 IF( isub.NE.n+1-i )
THEN
835 d( isub ) = d( n+1-i )
838 $
CALL sswap( ncvt, vt( isub, 1 ), ldvt, vt( n+1-i, 1 ),
841 $
CALL sswap( nru, u( 1, isub ), 1, u( 1, n+1-i ), 1 )
843 $
CALL sswap( ncc, c( isub, 1 ), ldc, c( n+1-i, 1 ), ldc )
subroutine xerbla(srname, info)
subroutine sbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, work, info)
SBDSQR
subroutine slartg(f, g, c, s, r)
SLARTG generates a plane rotation with real cosine and real sine.
subroutine slas2(f, g, h, ssmin, ssmax)
SLAS2 computes singular values of a 2-by-2 triangular matrix.
subroutine slasq1(n, d, e, work, info)
SLASQ1 computes the singular values of a real square bidiagonal matrix. Used by sbdsqr.
subroutine slasr(side, pivot, direct, m, n, c, s, a, lda)
SLASR applies a sequence of plane rotations to a general rectangular matrix.
subroutine slasv2(f, g, h, ssmin, ssmax, snr, csr, snl, csl)
SLASV2 computes the singular value decomposition of a 2-by-2 triangular matrix.
subroutine srot(n, sx, incx, sy, incy, c, s)
SROT
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine sswap(n, sx, incx, sy, incy)
SSWAP