222 SUBROUTINE zbdsqr( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
223 $ ldu, c, ldc, rwork, info )
232 INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU
235 DOUBLE PRECISION D( * ), E( * ), RWORK( * )
236 COMPLEX*16 C( ldc, * ), U( ldu, * ), VT( ldvt, * )
242 DOUBLE PRECISION ZERO
243 parameter ( zero = 0.0d0 )
245 parameter ( one = 1.0d0 )
246 DOUBLE PRECISION NEGONE
247 parameter ( negone = -1.0d0 )
248 DOUBLE PRECISION HNDRTH
249 parameter ( hndrth = 0.01d0 )
251 parameter ( ten = 10.0d0 )
252 DOUBLE PRECISION HNDRD
253 parameter ( hndrd = 100.0d0 )
254 DOUBLE PRECISION MEIGTH
255 parameter ( meigth = -0.125d0 )
257 parameter ( maxitr = 6 )
260 LOGICAL LOWER, ROTATE
261 INTEGER I, IDIR, ISUB, ITER, J, LL, LLL, M, MAXIT, NM1,
262 $ nm12, nm13, oldll, oldm
263 DOUBLE PRECISION ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,
264 $ oldcs, oldsn, r, shift, sigmn, sigmx, sinl,
265 $ sinr, sll, smax, smin, sminl, sminoa,
266 $ sn, thresh, tol, tolmul, unfl
270 DOUBLE PRECISION DLAMCH
271 EXTERNAL lsame, dlamch
278 INTRINSIC abs, dble, max, min, sign, sqrt
285 lower = lsame( uplo,
'L' )
286 IF( .NOT.lsame( uplo,
'U' ) .AND. .NOT.lower )
THEN
288 ELSE IF( n.LT.0 )
THEN
290 ELSE IF( ncvt.LT.0 )
THEN
292 ELSE IF( nru.LT.0 )
THEN
294 ELSE IF( ncc.LT.0 )
THEN
296 ELSE IF( ( ncvt.EQ.0 .AND. ldvt.LT.1 ) .OR.
297 $ ( ncvt.GT.0 .AND. ldvt.LT.max( 1, n ) ) )
THEN
299 ELSE IF( ldu.LT.max( 1, nru ) )
THEN
301 ELSE IF( ( ncc.EQ.0 .AND. ldc.LT.1 ) .OR.
302 $ ( ncc.GT.0 .AND. ldc.LT.max( 1, n ) ) )
THEN
306 CALL xerbla(
'ZBDSQR', -info )
316 rotate = ( ncvt.GT.0 ) .OR. ( nru.GT.0 ) .OR. ( ncc.GT.0 )
320 IF( .NOT.rotate )
THEN
321 CALL dlasq1( n, d, e, rwork, info )
325 IF( info .NE. 2 )
RETURN
336 eps = dlamch(
'Epsilon' )
337 unfl = dlamch(
'Safe minimum' )
344 CALL dlartg( d( i ), e( i ), cs, sn, r )
347 d( i+1 ) = cs*d( i+1 )
355 $
CALL zlasr(
'R',
'V',
'F', nru, n, rwork( 1 ), rwork( n ),
358 $
CALL zlasr(
'L',
'V',
'F', n, ncc, rwork( 1 ), rwork( n ),
366 tolmul = max( ten, min( hndrd, eps**meigth ) )
373 smax = max( smax, abs( d( i ) ) )
376 smax = max( smax, abs( e( i ) ) )
379 IF( tol.GE.zero )
THEN
383 sminoa = abs( d( 1 ) )
388 mu = abs( d( i ) )*( mu / ( mu+abs( e( i-1 ) ) ) )
389 sminoa = min( sminoa, mu )
394 sminoa = sminoa / sqrt( dble( n ) )
395 thresh = max( tol*sminoa, maxitr*n*n*unfl )
400 thresh = max( abs( tol )*smax, maxitr*n*n*unfl )
429 IF( tol.LT.zero .AND. abs( d( m ) ).LE.thresh )
435 abss = abs( d( ll ) )
436 abse = abs( e( ll ) )
437 IF( tol.LT.zero .AND. abss.LE.thresh )
441 smin = min( smin, abss )
442 smax = max( smax, abss, abse )
467 CALL dlasv2( d( m-1 ), e( m-1 ), d( m ), sigmn, sigmx, sinr,
476 $
CALL zdrot( ncvt, vt( m-1, 1 ), ldvt, vt( m, 1 ), ldvt,
479 $
CALL zdrot( nru, u( 1, m-1 ), 1, u( 1, m ), 1, cosl, sinl )
481 $
CALL zdrot( ncc, c( m-1, 1 ), ldc, c( m, 1 ), ldc, cosl,
490 IF( ll.GT.oldm .OR. m.LT.oldll )
THEN
491 IF( abs( d( ll ) ).GE.abs( d( m ) ) )
THEN
511 IF( abs( e( m-1 ) ).LE.abs( tol )*abs( d( m ) ) .OR.
512 $ ( tol.LT.zero .AND. abs( e( m-1 ) ).LE.thresh ) )
THEN
517 IF( tol.GE.zero )
THEN
524 DO 100 lll = ll, m - 1
525 IF( abs( e( lll ) ).LE.tol*mu )
THEN
529 mu = abs( d( lll+1 ) )*( mu / ( mu+abs( e( lll ) ) ) )
530 sminl = min( sminl, mu )
539 IF( abs( e( ll ) ).LE.abs( tol )*abs( d( ll ) ) .OR.
540 $ ( tol.LT.zero .AND. abs( e( ll ) ).LE.thresh ) )
THEN
545 IF( tol.GE.zero )
THEN
552 DO 110 lll = m - 1, ll, -1
553 IF( abs( e( lll ) ).LE.tol*mu )
THEN
557 mu = abs( d( lll ) )*( mu / ( mu+abs( e( lll ) ) ) )
558 sminl = min( sminl, mu )
568 IF( tol.GE.zero .AND. n*tol*( sminl / smax ).LE.
569 $ max( eps, hndrth*tol ) )
THEN
580 CALL dlas2( d( m-1 ), e( m-1 ), d( m ), shift, r )
583 CALL dlas2( d( ll ), e( ll ), d( ll+1 ), shift, r )
588 IF( sll.GT.zero )
THEN
589 IF( ( shift / sll )**2.LT.eps )
600 IF( shift.EQ.zero )
THEN
609 CALL dlartg( d( i )*cs, e( i ), cs, sn, r )
612 CALL dlartg( oldcs*r, d( i+1 )*sn, oldcs, oldsn, d( i ) )
614 rwork( i-ll+1+nm1 ) = sn
615 rwork( i-ll+1+nm12 ) = oldcs
616 rwork( i-ll+1+nm13 ) = oldsn
625 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncvt, rwork( 1 ),
626 $ rwork( n ), vt( ll, 1 ), ldvt )
628 $
CALL zlasr(
'R',
'V',
'F', nru, m-ll+1, rwork( nm12+1 ),
629 $ rwork( nm13+1 ), u( 1, ll ), ldu )
631 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncc, rwork( nm12+1 ),
632 $ rwork( nm13+1 ), c( ll, 1 ), ldc )
636 IF( abs( e( m-1 ) ).LE.thresh )
646 DO 130 i = m, ll + 1, -1
647 CALL dlartg( d( i )*cs, e( i-1 ), cs, sn, r )
650 CALL dlartg( oldcs*r, d( i-1 )*sn, oldcs, oldsn, d( i ) )
652 rwork( i-ll+nm1 ) = -sn
653 rwork( i-ll+nm12 ) = oldcs
654 rwork( i-ll+nm13 ) = -oldsn
663 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncvt, rwork( nm12+1 ),
664 $ rwork( nm13+1 ), vt( ll, 1 ), ldvt )
666 $
CALL zlasr(
'R',
'V',
'B', nru, m-ll+1, rwork( 1 ),
667 $ rwork( n ), u( 1, ll ), ldu )
669 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncc, rwork( 1 ),
670 $ rwork( n ), c( ll, 1 ), ldc )
674 IF( abs( e( ll ) ).LE.thresh )
686 f = ( abs( d( ll ) )-shift )*
687 $ ( sign( one, d( ll ) )+shift / d( ll ) )
690 CALL dlartg( f, g, cosr, sinr, r )
693 f = cosr*d( i ) + sinr*e( i )
694 e( i ) = cosr*e( i ) - sinr*d( i )
696 d( i+1 ) = cosr*d( i+1 )
697 CALL dlartg( f, g, cosl, sinl, r )
699 f = cosl*e( i ) + sinl*d( i+1 )
700 d( i+1 ) = cosl*d( i+1 ) - sinl*e( i )
703 e( i+1 ) = cosl*e( i+1 )
705 rwork( i-ll+1 ) = cosr
706 rwork( i-ll+1+nm1 ) = sinr
707 rwork( i-ll+1+nm12 ) = cosl
708 rwork( i-ll+1+nm13 ) = sinl
715 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncvt, rwork( 1 ),
716 $ rwork( n ), vt( ll, 1 ), ldvt )
718 $
CALL zlasr(
'R',
'V',
'F', nru, m-ll+1, rwork( nm12+1 ),
719 $ rwork( nm13+1 ), u( 1, ll ), ldu )
721 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncc, rwork( nm12+1 ),
722 $ rwork( nm13+1 ), c( ll, 1 ), ldc )
726 IF( abs( e( m-1 ) ).LE.thresh )
734 f = ( abs( d( m ) )-shift )*( sign( one, d( m ) )+shift /
737 DO 150 i = m, ll + 1, -1
738 CALL dlartg( f, g, cosr, sinr, r )
741 f = cosr*d( i ) + sinr*e( i-1 )
742 e( i-1 ) = cosr*e( i-1 ) - sinr*d( i )
744 d( i-1 ) = cosr*d( i-1 )
745 CALL dlartg( f, g, cosl, sinl, r )
747 f = cosl*e( i-1 ) + sinl*d( i-1 )
748 d( i-1 ) = cosl*d( i-1 ) - sinl*e( i-1 )
751 e( i-2 ) = cosl*e( i-2 )
754 rwork( i-ll+nm1 ) = -sinr
755 rwork( i-ll+nm12 ) = cosl
756 rwork( i-ll+nm13 ) = -sinl
762 IF( abs( e( ll ) ).LE.thresh )
768 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncvt, rwork( nm12+1 ),
769 $ rwork( nm13+1 ), vt( ll, 1 ), ldvt )
771 $
CALL zlasr(
'R',
'V',
'B', nru, m-ll+1, rwork( 1 ),
772 $ rwork( n ), u( 1, ll ), ldu )
774 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncc, rwork( 1 ),
775 $ rwork( n ), c( ll, 1 ), ldc )
787 IF( d( i ).LT.zero )
THEN
793 $
CALL zdscal( ncvt, negone, vt( i, 1 ), ldvt )
806 DO 180 j = 2, n + 1 - i
807 IF( d( j ).LE.smin )
THEN
812 IF( isub.NE.n+1-i )
THEN
816 d( isub ) = d( n+1-i )
819 $
CALL zswap( ncvt, vt( isub, 1 ), ldvt, vt( n+1-i, 1 ),
822 $
CALL zswap( nru, u( 1, isub ), 1, u( 1, n+1-i ), 1 )
824 $
CALL zswap( ncc, c( isub, 1 ), ldc, c( n+1-i, 1 ), ldc )
subroutine zlasr(SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA)
ZLASR applies a sequence of plane rotations to a general rectangular matrix.
subroutine zswap(N, ZX, INCX, ZY, INCY)
ZSWAP
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine zdrot(N, CX, INCX, CY, INCY, C, S)
ZDROT
subroutine dlasq1(N, D, E, WORK, INFO)
DLASQ1 computes the singular values of a real square bidiagonal matrix. Used by sbdsqr.
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 zbdsqr(UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U, LDU, C, LDC, RWORK, INFO)
ZBDSQR
subroutine zdscal(N, DA, ZX, INCX)
ZDSCAL
subroutine dlartg(F, G, CS, SN, 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.