232 SUBROUTINE dgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
233 $ EPS, SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
240 DOUBLE PRECISION EPS, SFMIN, TOL
241 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
245 DOUBLE PRECISION A( LDA, * ), D( N ), SVA( N ), V( LDV, * ),
252 DOUBLE PRECISION ZERO, HALF, ONE
253 parameter( zero = 0.0d0, half = 0.5d0, one = 1.0d0 )
256 DOUBLE PRECISION AAPP, AAPP0, AAPQ, AAQQ, APOAQ, AQOAP, BIG,
257 $ bigtheta, cs, large, mxaapq, mxsinj, rootbig,
258 $ rooteps, rootsfmin, roottol, small, sn, t,
259 $ temp1, theta, thsign
260 INTEGER BLSKIP, EMPTSW, i, ibr, igl, IERR, IJBLSK,
261 $ iswrot, jbc, jgl, kbl, mvl, notrot, nblc, nblr,
262 $ p, pskipped, q, rowskip, swband
263 LOGICAL APPLV, ROTOK, RSVEC
266 DOUBLE PRECISION FASTR( 5 )
269 INTRINSIC dabs, max, dble, min, dsign, dsqrt
272 DOUBLE PRECISION DDOT, DNRM2
275 EXTERNAL idamax, lsame, ddot, dnrm2
286 applv = lsame( jobv,
'A' )
287 rsvec = lsame( jobv,
'V' )
288 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
290 ELSE IF( m.LT.0 )
THEN
292 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
294 ELSE IF( n1.LT.0 )
THEN
296 ELSE IF( lda.LT.m )
THEN
298 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
300 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
301 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
303 ELSE IF( tol.LE.eps )
THEN
305 ELSE IF( nsweep.LT.0 )
THEN
307 ELSE IF( lwork.LT.m )
THEN
315 CALL xerbla(
'DGSVJ1', -info )
321 ELSE IF( applv )
THEN
324 rsvec = rsvec .OR. applv
326 rooteps = dsqrt( eps )
327 rootsfmin = dsqrt( sfmin )
330 rootbig = one / rootsfmin
331 large = big / dsqrt( dble( m*n ) )
332 bigtheta = one / rooteps
333 roottol = dsqrt( tol )
347 IF( ( nblr*kbl ).NE.n1 )nblr = nblr + 1
351 nblc = ( n-n1 ) / kbl
352 IF( ( nblc*kbl ).NE.( n-n1 ) )nblc = nblc + 1
353 blskip = ( kbl**2 ) + 1
356 rowskip = min( 5, kbl )
372 DO 1993 i = 1, nsweep
382 DO 2000 ibr = 1, nblr
384 igl = ( ibr-1 )*kbl + 1
390 igl = ( ibr-1 )*kbl + 1
392 DO 2010 jbc = 1, nblc
394 jgl = n1 + ( jbc-1 )*kbl + 1
399 DO 2100 p = igl, min( igl+kbl-1, n1 )
403 IF( aapp.GT.zero )
THEN
407 DO 2200 q = jgl, min( jgl+kbl-1, n )
411 IF( aaqq.GT.zero )
THEN
418 IF( aaqq.GE.one )
THEN
419 IF( aapp.GE.aaqq )
THEN
420 rotok = ( small*aapp ).LE.aaqq
422 rotok = ( small*aaqq ).LE.aapp
424 IF( aapp.LT.( big / aaqq ) )
THEN
425 aapq = ( ddot( m, a( 1, p ), 1,
427 $ q ), 1 )*d( p )*d( q ) / aaqq )
430 CALL dcopy( m, a( 1, p ), 1, work,
432 CALL dlascl(
'G', 0, 0, aapp,
434 $ m, 1, work, lda, ierr )
435 aapq = ddot( m, work, 1, a( 1, q ),
439 IF( aapp.GE.aaqq )
THEN
440 rotok = aapp.LE.( aaqq / small )
442 rotok = aaqq.LE.( aapp / small )
444 IF( aapp.GT.( small / aaqq ) )
THEN
445 aapq = ( ddot( m, a( 1, p ), 1,
447 $ q ), 1 )*d( p )*d( q ) / aaqq )
450 CALL dcopy( m, a( 1, q ), 1, work,
452 CALL dlascl(
'G', 0, 0, aaqq,
454 $ m, 1, work, lda, ierr )
455 aapq = ddot( m, work, 1, a( 1, p ),
460 mxaapq = max( mxaapq, dabs( aapq ) )
464 IF( dabs( aapq ).GT.tol )
THEN
474 theta = -half*dabs(aqoap-apoaq) / aapq
475 IF( aaqq.GT.aapp0 )theta = -theta
477 IF( dabs( theta ).GT.bigtheta )
THEN
479 fastr( 3 ) = t*d( p ) / d( q )
480 fastr( 4 ) = -t*d( q ) / d( p )
481 CALL drotm( m, a( 1, p ), 1,
482 $ a( 1, q ), 1, fastr )
483 IF( rsvec )
CALL drotm( mvl,
487 sva( q ) = aaqq*dsqrt( max( zero,
488 $ one+t*apoaq*aapq ) )
489 aapp = aapp*dsqrt( max( zero,
490 $ one-t*aqoap*aapq ) )
491 mxsinj = max( mxsinj, dabs( t ) )
496 thsign = -dsign( one, aapq )
497 IF( aaqq.GT.aapp0 )thsign = -thsign
498 t = one / ( theta+thsign*
499 $ dsqrt( one+theta*theta ) )
500 cs = dsqrt( one / ( one+t*t ) )
502 mxsinj = max( mxsinj, dabs( sn ) )
503 sva( q ) = aaqq*dsqrt( max( zero,
504 $ one+t*apoaq*aapq ) )
505 aapp = aapp*dsqrt( max( zero,
506 $ one-t*aqoap*aapq ) )
508 apoaq = d( p ) / d( q )
509 aqoap = d( q ) / d( p )
510 IF( d( p ).GE.one )
THEN
512 IF( d( q ).GE.one )
THEN
514 fastr( 4 ) = -t*aqoap
517 CALL drotm( m, a( 1, p ),
521 IF( rsvec )
CALL drotm( mvl,
522 $ v( 1, p ), 1, v( 1, q ),
525 CALL daxpy( m, -t*aqoap,
528 CALL daxpy( m, cs*sn*apoaq,
545 IF( d( q ).GE.one )
THEN
546 CALL daxpy( m, t*apoaq,
566 IF( d( p ).GE.d( q ) )
THEN
567 CALL daxpy( m, -t*aqoap,
587 CALL daxpy( m, t*apoaq,
598 $ t*apoaq, v( 1, p ),
611 IF( aapp.GT.aaqq )
THEN
612 CALL dcopy( m, a( 1, p ), 1,
615 CALL dlascl(
'G', 0, 0, aapp,
617 $ m, 1, work, lda, ierr )
618 CALL dlascl(
'G', 0, 0, aaqq,
620 $ m, 1, a( 1, q ), lda,
622 temp1 = -aapq*d( p ) / d( q )
623 CALL daxpy( m, temp1, work, 1,
625 CALL dlascl(
'G', 0, 0, one,
627 $ m, 1, a( 1, q ), lda,
629 sva( q ) = aaqq*dsqrt( max( zero,
631 mxsinj = max( mxsinj, sfmin )
633 CALL dcopy( m, a( 1, q ), 1,
636 CALL dlascl(
'G', 0, 0, aaqq,
638 $ m, 1, work, lda, ierr )
639 CALL dlascl(
'G', 0, 0, aapp,
641 $ m, 1, a( 1, p ), lda,
643 temp1 = -aapq*d( q ) / d( p )
644 CALL daxpy( m, temp1, work, 1,
646 CALL dlascl(
'G', 0, 0, one,
648 $ m, 1, a( 1, p ), lda,
650 sva( p ) = aapp*dsqrt( max( zero,
652 mxsinj = max( mxsinj, sfmin )
659 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
661 IF( ( aaqq.LT.rootbig ) .AND.
662 $ ( aaqq.GT.rootsfmin ) )
THEN
663 sva( q ) = dnrm2( m, a( 1, q ),
669 CALL dlassq( m, a( 1, q ), 1, t,
671 sva( q ) = t*dsqrt( aaqq )*d( q )
674 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
675 IF( ( aapp.LT.rootbig ) .AND.
676 $ ( aapp.GT.rootsfmin ) )
THEN
677 aapp = dnrm2( m, a( 1, p ), 1 )*
682 CALL dlassq( m, a( 1, p ), 1, t,
684 aapp = t*dsqrt( aapp )*d( p )
692 pskipped = pskipped + 1
697 pskipped = pskipped + 1
702 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
708 IF( ( i.LE.swband ) .AND.
709 $ ( pskipped.GT.rowskip ) )
THEN
723 IF( aapp.EQ.zero )notrot = notrot +
724 $ min( jgl+kbl-1, n ) - jgl + 1
725 IF( aapp.LT.zero )notrot = 0
735 DO 2012 p = igl, min( igl+kbl-1, n )
736 sva( p ) = dabs( sva( p ) )
743 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
745 sva( n ) = dnrm2( m, a( 1, n ), 1 )*d( n )
749 CALL dlassq( m, a( 1, n ), 1, t, aapp )
750 sva( n ) = t*dsqrt( aapp )*d( n )
755 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
756 $ ( iswrot.LE.n ) ) )swband = i
758 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.dble( n )*tol ) .AND.
759 $ ( dble( n )*mxaapq*mxsinj.LT.tol ) )
THEN
764 IF( notrot.GE.emptsw )
GO TO 1994
783 q = idamax( n-p+1, sva( p ), 1 ) + p - 1
791 CALL dswap( m, a( 1, p ), 1, a( 1, q ), 1 )
792 IF( rsvec )
CALL dswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )