231 SUBROUTINE zbdsqr( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
232 $ LDU, C, LDC, RWORK, INFO )
240 INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU
243 DOUBLE PRECISION D( * ), E( * ), RWORK( * )
244 COMPLEX*16 C( LDC, * ), U( LDU, * ), VT( LDVT, * )
250 DOUBLE PRECISION ZERO
251 parameter( zero = 0.0d0 )
253 parameter( one = 1.0d0 )
254 DOUBLE PRECISION NEGONE
255 parameter( negone = -1.0d0 )
256 DOUBLE PRECISION HNDRTH
257 parameter( hndrth = 0.01d0 )
259 parameter( ten = 10.0d0 )
260 DOUBLE PRECISION HNDRD
261 parameter( hndrd = 100.0d0 )
262 DOUBLE PRECISION MEIGTH
263 parameter( meigth = -0.125d0 )
265 parameter( maxitr = 6 )
268 LOGICAL LOWER, ROTATE
269 INTEGER I, IDIR, ISUB, ITER, ITERDIVN, J, LL, LLL, M,
270 $ maxitdivn, nm1, nm12, nm13, oldll, oldm
271 DOUBLE PRECISION ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,
272 $ oldcs, oldsn, r, shift, sigmn, sigmx, sinl,
273 $ sinr, sll, smax, smin, sminoa,
274 $ sn, thresh, tol, tolmul, unfl
278 DOUBLE PRECISION DLAMCH
279 EXTERNAL lsame, dlamch
286 INTRINSIC abs, dble, max, min, sign, sqrt
293 lower = lsame( uplo,
'L' )
294 IF( .NOT.lsame( uplo,
'U' ) .AND. .NOT.lower )
THEN
296 ELSE IF( n.LT.0 )
THEN
298 ELSE IF( ncvt.LT.0 )
THEN
300 ELSE IF( nru.LT.0 )
THEN
302 ELSE IF( ncc.LT.0 )
THEN
304 ELSE IF( ( ncvt.EQ.0 .AND. ldvt.LT.1 ) .OR.
305 $ ( ncvt.GT.0 .AND. ldvt.LT.max( 1, n ) ) )
THEN
307 ELSE IF( ldu.LT.max( 1, nru ) )
THEN
309 ELSE IF( ( ncc.EQ.0 .AND. ldc.LT.1 ) .OR.
310 $ ( ncc.GT.0 .AND. ldc.LT.max( 1, n ) ) )
THEN
314 CALL xerbla(
'ZBDSQR', -info )
324 rotate = ( ncvt.GT.0 ) .OR. ( nru.GT.0 ) .OR. ( ncc.GT.0 )
328 IF( .NOT.rotate )
THEN
329 CALL dlasq1( n, d, e, rwork, info )
333 IF( info .NE. 2 )
RETURN
344 eps = dlamch(
'Epsilon' )
345 unfl = dlamch(
'Safe minimum' )
352 CALL dlartg( d( i ), e( i ), cs, sn, r )
355 d( i+1 ) = cs*d( i+1 )
363 $
CALL zlasr(
'R',
'V',
'F', nru, n, rwork( 1 ), rwork( n ),
366 $
CALL zlasr(
'L',
'V',
'F', n, ncc, rwork( 1 ), rwork( n ),
374 tolmul = max( ten, min( hndrd, eps**meigth ) )
381 smax = max( smax, abs( d( i ) ) )
384 smax = max( smax, abs( e( i ) ) )
387 IF( tol.GE.zero )
THEN
391 sminoa = abs( d( 1 ) )
396 mu = abs( d( i ) )*( mu / ( mu+abs( e( i-1 ) ) ) )
397 sminoa = min( sminoa, mu )
402 sminoa = sminoa / sqrt( dble( n ) )
403 thresh = max( tol*sminoa, maxitr*(n*(n*unfl)) )
408 thresh = max( abs( tol )*smax, maxitr*(n*(n*unfl)) )
435 iterdivn = iterdivn + 1
436 IF( iterdivn.GE.maxitdivn )
442 IF( tol.LT.zero .AND. abs( d( m ) ).LE.thresh )
447 abss = abs( d( ll ) )
448 abse = abs( e( ll ) )
449 IF( tol.LT.zero .AND. abss.LE.thresh )
453 smax = max( smax, abss, abse )
478 CALL dlasv2( d( m-1 ), e( m-1 ), d( m ), sigmn, sigmx, sinr,
487 $
CALL zdrot( ncvt, vt( m-1, 1 ), ldvt, vt( m, 1 ), ldvt,
490 $
CALL zdrot( nru, u( 1, m-1 ), 1, u( 1, m ), 1, cosl, sinl )
492 $
CALL zdrot( ncc, c( m-1, 1 ), ldc, c( m, 1 ), ldc, cosl,
501 IF( ll.GT.oldm .OR. m.LT.oldll )
THEN
502 IF( abs( d( ll ) ).GE.abs( d( m ) ) )
THEN
522 IF( abs( e( m-1 ) ).LE.abs( tol )*abs( d( m ) ) .OR.
523 $ ( tol.LT.zero .AND. abs( e( m-1 ) ).LE.thresh ) )
THEN
528 IF( tol.GE.zero )
THEN
535 DO 100 lll = ll, m - 1
536 IF( abs( e( lll ) ).LE.tol*mu )
THEN
540 mu = abs( d( lll+1 ) )*( mu / ( mu+abs( e( lll ) ) ) )
541 smin = min( smin, mu )
550 IF( abs( e( ll ) ).LE.abs( tol )*abs( d( ll ) ) .OR.
551 $ ( tol.LT.zero .AND. abs( e( ll ) ).LE.thresh ) )
THEN
556 IF( tol.GE.zero )
THEN
563 DO 110 lll = m - 1, ll, -1
564 IF( abs( e( lll ) ).LE.tol*mu )
THEN
568 mu = abs( d( lll ) )*( mu / ( mu+abs( e( lll ) ) ) )
569 smin = min( smin, mu )
579 IF( tol.GE.zero .AND. n*tol*( smin / smax ).LE.
580 $ max( eps, hndrth*tol ) )
THEN
591 CALL dlas2( d( m-1 ), e( m-1 ), d( m ), shift, r )
594 CALL dlas2( d( ll ), e( ll ), d( ll+1 ), shift, r )
599 IF( sll.GT.zero )
THEN
600 IF( ( shift / sll )**2.LT.eps )
611 IF( shift.EQ.zero )
THEN
620 CALL dlartg( d( i )*cs, e( i ), cs, sn, r )
623 CALL dlartg( oldcs*r, d( i+1 )*sn, oldcs, oldsn, d( i ) )
625 rwork( i-ll+1+nm1 ) = sn
626 rwork( i-ll+1+nm12 ) = oldcs
627 rwork( i-ll+1+nm13 ) = oldsn
636 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncvt, rwork( 1 ),
637 $ rwork( n ), vt( ll, 1 ), ldvt )
639 $
CALL zlasr(
'R',
'V',
'F', nru, m-ll+1, rwork( nm12+1 ),
640 $ rwork( nm13+1 ), u( 1, ll ), ldu )
642 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncc, rwork( nm12+1 ),
643 $ rwork( nm13+1 ), c( ll, 1 ), ldc )
647 IF( abs( e( m-1 ) ).LE.thresh )
657 DO 130 i = m, ll + 1, -1
658 CALL dlartg( d( i )*cs, e( i-1 ), cs, sn, r )
661 CALL dlartg( oldcs*r, d( i-1 )*sn, oldcs, oldsn, d( i ) )
663 rwork( i-ll+nm1 ) = -sn
664 rwork( i-ll+nm12 ) = oldcs
665 rwork( i-ll+nm13 ) = -oldsn
674 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncvt, rwork( nm12+1 ),
675 $ rwork( nm13+1 ), vt( ll, 1 ), ldvt )
677 $
CALL zlasr(
'R',
'V',
'B', nru, m-ll+1, rwork( 1 ),
678 $ rwork( n ), u( 1, ll ), ldu )
680 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncc, rwork( 1 ),
681 $ rwork( n ), c( ll, 1 ), ldc )
685 IF( abs( e( ll ) ).LE.thresh )
697 f = ( abs( d( ll ) )-shift )*
698 $ ( sign( one, d( ll ) )+shift / d( ll ) )
701 CALL dlartg( f, g, cosr, sinr, r )
704 f = cosr*d( i ) + sinr*e( i )
705 e( i ) = cosr*e( i ) - sinr*d( i )
707 d( i+1 ) = cosr*d( i+1 )
708 CALL dlartg( f, g, cosl, sinl, r )
710 f = cosl*e( i ) + sinl*d( i+1 )
711 d( i+1 ) = cosl*d( i+1 ) - sinl*e( i )
714 e( i+1 ) = cosl*e( i+1 )
716 rwork( i-ll+1 ) = cosr
717 rwork( i-ll+1+nm1 ) = sinr
718 rwork( i-ll+1+nm12 ) = cosl
719 rwork( i-ll+1+nm13 ) = sinl
726 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncvt, rwork( 1 ),
727 $ rwork( n ), vt( ll, 1 ), ldvt )
729 $
CALL zlasr(
'R',
'V',
'F', nru, m-ll+1, rwork( nm12+1 ),
730 $ rwork( nm13+1 ), u( 1, ll ), ldu )
732 $
CALL zlasr(
'L',
'V',
'F', m-ll+1, ncc, rwork( nm12+1 ),
733 $ rwork( nm13+1 ), c( ll, 1 ), ldc )
737 IF( abs( e( m-1 ) ).LE.thresh )
745 f = ( abs( d( m ) )-shift )*( sign( one, d( m ) )+shift /
748 DO 150 i = m, ll + 1, -1
749 CALL dlartg( f, g, cosr, sinr, r )
752 f = cosr*d( i ) + sinr*e( i-1 )
753 e( i-1 ) = cosr*e( i-1 ) - sinr*d( i )
755 d( i-1 ) = cosr*d( i-1 )
756 CALL dlartg( f, g, cosl, sinl, r )
758 f = cosl*e( i-1 ) + sinl*d( i-1 )
759 d( i-1 ) = cosl*d( i-1 ) - sinl*e( i-1 )
762 e( i-2 ) = cosl*e( i-2 )
765 rwork( i-ll+nm1 ) = -sinr
766 rwork( i-ll+nm12 ) = cosl
767 rwork( i-ll+nm13 ) = -sinl
773 IF( abs( e( ll ) ).LE.thresh )
779 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncvt, rwork( nm12+1 ),
780 $ rwork( nm13+1 ), vt( ll, 1 ), ldvt )
782 $
CALL zlasr(
'R',
'V',
'B', nru, m-ll+1, rwork( 1 ),
783 $ rwork( n ), u( 1, ll ), ldu )
785 $
CALL zlasr(
'L',
'V',
'B', m-ll+1, ncc, rwork( 1 ),
786 $ rwork( n ), c( ll, 1 ), ldc )
798 IF( d( i ).LT.zero )
THEN
804 $
CALL zdscal( ncvt, negone, vt( i, 1 ), ldvt )
817 DO 180 j = 2, n + 1 - i
818 IF( d( j ).LE.smin )
THEN
823 IF( isub.NE.n+1-i )
THEN
827 d( isub ) = d( n+1-i )
830 $
CALL zswap( ncvt, vt( isub, 1 ), ldvt, vt( n+1-i, 1 ),
833 $
CALL zswap( nru, u( 1, isub ), 1, u( 1, n+1-i ), 1 )
835 $
CALL zswap( ncc, c( isub, 1 ), ldc, c( n+1-i, 1 ), ldc )
subroutine xerbla(srname, info)
subroutine zbdsqr(uplo, n, ncvt, nru, ncc, d, e, vt, ldvt, u, ldu, c, ldc, rwork, info)
ZBDSQR
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 zlasr(side, pivot, direct, m, n, c, s, a, lda)
ZLASR 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 zdrot(n, zx, incx, zy, incy, c, s)
ZDROT
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP