1 SUBROUTINE dbdsqr( UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U,
2 $ LDU, C, LDC, WORK, INFO )
11 INTEGER INFO, LDC, LDU, LDVT, N, NCC, NCVT, NRU
14 DOUBLE PRECISION C( LDC, * ), D( * ), E( * ), U( LDU, * ),
15 $ vt( ldvt, * ), work( * )
135 DOUBLE PRECISION ZERO
136 parameter( zero = 0.0d0 )
138 parameter( one = 1.0d0 )
139 DOUBLE PRECISION NEGONE
140 parameter( negone = -1.0d0 )
141 DOUBLE PRECISION HNDRTH
142 parameter( hndrth = 0.01d0 )
144 parameter( ten = 10.0d0 )
145 DOUBLE PRECISION HNDRD
146 parameter( hndrd = 100.0d0 )
147 DOUBLE PRECISION MEIGTH
148 parameter( meigth = -0.125d0 )
150 parameter( maxitr = 6 )
153 LOGICAL LOWER, ROTATE
154 INTEGER I, IDIR, ISUB, ITER, J, LL, LLL, M, MAXIT, NM1,
155 $ nm12, nm13, oldll, oldm
156 DOUBLE PRECISION ABSE, ABSS, COSL, COSR, CS, EPS, F, G, H, MU,
157 $ oldcs, oldsn, r, shift, sigmn, sigmx, sinl,
158 $ sinr, sll, smax, smin, sminl, sminlo, sminoa,
159 $ sn, thresh, tol, tolmul, unfl
163 DOUBLE PRECISION DLAMCH
164 EXTERNAL lsame, dlamch
171 INTRINSIC abs, dble, max, min, sign, sqrt
178 lower = lsame( uplo,
'L' )
179 IF( .NOT.lsame( uplo,
'U' ) .AND. .NOT.lower )
THEN
181 ELSE IF( n.LT.0 )
THEN
183 ELSE IF( ncvt.LT.0 )
THEN
185 ELSE IF( nru.LT.0 )
THEN
187 ELSE IF( ncc.LT.0 )
THEN
189 ELSE IF( ( ncvt.EQ.0 .AND. ldvt.LT.1 ) .OR.
190 $ ( ncvt.GT.0 .AND. ldvt.LT.max( 1, n ) ) )
THEN
192 ELSE IF( ldu.LT.max( 1, nru ) )
THEN
194 ELSE IF( ( ncc.EQ.0 .AND. ldc.LT.1 ) .OR.
195 $ ( ncc.GT.0 .AND. ldc.LT.max( 1, n ) ) )
THEN
199 CALL xerbla(
'DBDSQR', -info )
209 rotate = ( ncvt.GT.0 ) .OR. ( nru.GT.0 ) .OR. ( ncc.GT.0 )
213 IF( .NOT.rotate )
THEN
214 CALL dlasq1( n, d, e, work, info )
225 eps = dlamch(
'Epsilon' )
226 unfl = dlamch(
'Safe minimum' )
233 CALL dlartg( d( i ), e( i ), cs, sn, r )
236 d( i+1 ) = cs*d( i+1 )
244 $
CALL dlasr(
'R',
'V',
'F', nru, n, work( 1 ), work( n ), u,
247 $
CALL dlasr(
'L',
'V',
'F', n, ncc, work( 1 ), work( n ), c,
255 tolmul = max( ten, min( hndrd, eps**meigth ) )
262 smax = max( smax, abs( d( i ) ) )
265 smax = max( smax, abs( e( i ) ) )
268 IF( tol.GE.zero )
THEN
272 sminoa = abs( d( 1 ) )
277 mu = abs( d( i ) )*( mu / ( mu+abs( e( i-1 ) ) ) )
278 sminoa = min( sminoa, mu )
283 sminoa = sminoa / sqrt( dble( n ) )
284 thresh = max( tol*sminoa, maxitr*n*n*unfl )
289 thresh = max( abs( tol )*smax, maxitr*n*n*unfl )
318 IF( tol.LT.zero .AND. abs( d( m ) ).LE.thresh )
324 abss = abs( d( ll ) )
325 abse = abs( e( ll ) )
326 IF( tol.LT.zero .AND. abss.LE.thresh )
330 smin = min( smin, abss )
331 smax = max( smax, abss, abse )
356 CALL dlasv2( d( m-1 ), e( m-1 ), d( m ), sigmn, sigmx, sinr,
365 $
CALL drot( ncvt, vt( m-1, 1 ), ldvt, vt( m, 1 ), ldvt, cosr,
368 $
CALL drot( nru, u( 1, m-1 ), 1, u( 1, m ), 1, cosl, sinl )
370 $
CALL drot( ncc, c( m-1, 1 ), ldc, c( m, 1 ), ldc, cosl,
379 IF( ll.GT.oldm .OR. m.LT.oldll )
THEN
380 IF( abs( d( ll ) ).GE.abs( d( m ) ) )
THEN
400 IF( abs( e( m-1 ) ).LE.abs( tol )*abs( d( m ) ) .OR.
401 $ ( tol.LT.zero .AND. abs( e( m-1 ) ).LE.thresh ) )
THEN
406 IF( tol.GE.zero )
THEN
413 DO 100 lll = ll, m - 1
414 IF( abs( e( lll ) ).LE.tol*mu )
THEN
419 mu = abs( d( lll+1 ) )*( mu / ( mu+abs( e( lll ) ) ) )
420 sminl = min( sminl, mu )
429 IF( abs( e( ll ) ).LE.abs( tol )*abs( d( ll ) ) .OR.
430 $ ( tol.LT.zero .AND. abs( e( ll ) ).LE.thresh ) )
THEN
435 IF( tol.GE.zero )
THEN
442 DO 110 lll = m - 1, ll, -1
443 IF( abs( e( lll ) ).LE.tol*mu )
THEN
448 mu = abs( d( lll ) )*( mu / ( mu+abs( e( lll ) ) ) )
449 sminl = min( sminl, mu )
459 IF( tol.GE.zero .AND. n*tol*( sminl / smax ).LE.
460 $ max( eps, hndrth*tol ) )
THEN
471 CALL dlas2( d( m-1 ), e( m-1 ), d( m ), shift, r )
474 CALL dlas2( d( ll ), e( ll ), d( ll+1 ), shift, r )
479 IF( sll.GT.zero )
THEN
480 IF( ( shift / sll )**2.LT.eps )
491 IF( shift.EQ.zero )
THEN
500 CALL dlartg( d( i )*cs, e( i ), cs, sn, r )
503 CALL dlartg( oldcs*r, d( i+1 )*sn, oldcs, oldsn, d( i ) )
505 work( i-ll+1+nm1 ) = sn
506 work( i-ll+1+nm12 ) = oldcs
507 work( i-ll+1+nm13 ) = oldsn
516 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
517 $ work( n ), vt( ll, 1 ), ldvt )
519 $
CALL dlasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
520 $ work( nm13+1 ), u( 1, ll ), ldu )
522 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
523 $ work( nm13+1 ), c( ll, 1 ), ldc )
527 IF( abs( e( m-1 ) ).LE.thresh )
537 DO 130 i = m, ll + 1, -1
538 CALL dlartg( d( i )*cs, e( i-1 ), cs, sn, r )
541 CALL dlartg( oldcs*r, d( i-1 )*sn, oldcs, oldsn, d( i ) )
543 work( i-ll+nm1 ) = -sn
544 work( i-ll+nm12 ) = oldcs
545 work( i-ll+nm13 ) = -oldsn
554 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
555 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
557 $
CALL dlasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
558 $ work( n ), u( 1, ll ), ldu )
560 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
561 $ work( n ), c( ll, 1 ), ldc )
565 IF( abs( e( ll ) ).LE.thresh )
577 f = ( abs( d( ll ) )-shift )*
578 $ ( sign( one, d( ll ) )+shift / d( ll ) )
581 CALL dlartg( f, g, cosr, sinr, r )
584 f = cosr*d( i ) + sinr*e( i )
585 e( i ) = cosr*e( i ) - sinr*d( i )
587 d( i+1 ) = cosr*d( i+1 )
588 CALL dlartg( f, g, cosl, sinl, r )
590 f = cosl*e( i ) + sinl*d( i+1 )
591 d( i+1 ) = cosl*d( i+1 ) - sinl*e( i )
594 e( i+1 ) = cosl*e( i+1 )
596 work( i-ll+1 ) = cosr
597 work( i-ll+1+nm1 ) = sinr
598 work( i-ll+1+nm12 ) = cosl
599 work( i-ll+1+nm13 ) = sinl
606 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncvt, work( 1 ),
607 $ work( n ), vt( ll, 1 ), ldvt )
609 $
CALL dlasr(
'R',
'V',
'F', nru, m-ll+1, work( nm12+1 ),
610 $ work( nm13+1 ), u( 1, ll ), ldu )
612 $
CALL dlasr(
'L',
'V',
'F', m-ll+1, ncc, work( nm12+1 ),
613 $ work( nm13+1 ), c( ll, 1 ), ldc )
617 IF( abs( e( m-1 ) ).LE.thresh )
625 f = ( abs( d( m ) )-shift )*( sign( one, d( m ) )+shift /
628 DO 150 i = m, ll + 1, -1
629 CALL dlartg( f, g, cosr, sinr, r )
632 f = cosr*d( i ) + sinr*e( i-1 )
633 e( i-1 ) = cosr*e( i-1 ) - sinr*d( i )
635 d( i-1 ) = cosr*d( i-1 )
636 CALL dlartg( f, g, cosl, sinl, r )
638 f = cosl*e( i-1 ) + sinl*d( i-1 )
639 d( i-1 ) = cosl*d( i-1 ) - sinl*e( i-1 )
642 e( i-2 ) = cosl*e( i-2 )
645 work( i-ll+nm1 ) = -sinr
646 work( i-ll+nm12 ) = cosl
647 work( i-ll+nm13 ) = -sinl
653 IF( abs( e( ll ) ).LE.thresh )
659 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncvt, work( nm12+1 ),
660 $ work( nm13+1 ), vt( ll, 1 ), ldvt )
662 $
CALL dlasr(
'R',
'V',
'B', nru, m-ll+1, work( 1 ),
663 $ work( n ), u( 1, ll ), ldu )
665 $
CALL dlasr(
'L',
'V',
'B', m-ll+1, ncc, work( 1 ),
666 $ work( n ), c( ll, 1 ), ldc )
678 IF( d( i ).LT.zero )
THEN
684 $
CALL dscal( ncvt, negone, vt( i, 1 ), ldvt )
697 DO 180 j = 2, n + 1 - i
698 IF( d( j ).LE.smin )
THEN
703 IF( isub.NE.n+1-i )
THEN
707 d( isub ) = d( n+1-i )
710 $
CALL dswap( ncvt, vt( isub, 1 ), ldvt, vt( n+1-i, 1 ),
713 $
CALL dswap( nru, u( 1, isub ), 1, u( 1, n+1-i ), 1 )
715 $
CALL dswap( ncc, c( isub, 1 ), ldc, c( n+1-i, 1 ), ldc )
subroutine dbdsqr(UPLO, N, NCVT, NRU, NCC, D, E, VT, LDVT, U, LDU, C, LDC, WORK, INFO)
subroutine dlartg(F, G, CS, SN, R)
subroutine dlas2(F, G, H, SSMIN, SSMAX)
subroutine dlasq1(N, D, E, WORK, INFO)
subroutine dlasr(SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA)
subroutine dlasv2(F, G, H, SSMIN, SSMAX, SNR, CSR, SNL, CSL)
subroutine drot(n, dx, incx, dy, incy, c, s)
subroutine dscal(n, da, dx, incx)
subroutine dswap(n, dx, incx, dy, incy)
subroutine xerbla(SRNAME, INFO)