234 SUBROUTINE dgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
235 $ EPS, SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
242 DOUBLE PRECISION EPS, SFMIN, TOL
243 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
247 DOUBLE PRECISION A( LDA, * ), D( N ), SVA( N ), V( LDV, * ),
254 DOUBLE PRECISION ZERO, HALF, ONE
255 parameter( zero = 0.0d0, half = 0.5d0, one = 1.0d0 )
258 DOUBLE PRECISION AAPP, AAPP0, AAPQ, AAQQ, APOAQ, AQOAP, BIG,
259 $ bigtheta, cs, large, mxaapq, mxsinj, rootbig,
260 $ rooteps, rootsfmin, roottol, small, sn, t,
261 $ temp1, theta, thsign
262 INTEGER BLSKIP, EMPTSW, i, ibr, igl, IERR, IJBLSK,
263 $ iswrot, jbc, jgl, kbl, mvl, notrot, nblc, nblr,
264 $ p, pskipped, q, rowskip, swband
265 LOGICAL APPLV, ROTOK, RSVEC
268 DOUBLE PRECISION FASTR( 5 )
271 INTRINSIC dabs, max, dble, min, dsign, dsqrt
274 DOUBLE PRECISION DDOT, DNRM2
277 EXTERNAL idamax, lsame, ddot, dnrm2
287 applv = lsame( jobv,
'A' )
288 rsvec = lsame( jobv,
'V' )
289 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
291 ELSE IF( m.LT.0 )
THEN
293 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
295 ELSE IF( n1.LT.0 )
THEN
297 ELSE IF( lda.LT.m )
THEN
299 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
301 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
302 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
304 ELSE IF( tol.LE.eps )
THEN
306 ELSE IF( nsweep.LT.0 )
THEN
308 ELSE IF( lwork.LT.m )
THEN
316 CALL xerbla(
'DGSVJ1', -info )
322 ELSE IF( applv )
THEN
325 rsvec = rsvec .OR. applv
327 rooteps = dsqrt( eps )
328 rootsfmin = dsqrt( sfmin )
331 rootbig = one / rootsfmin
332 large = big / dsqrt( dble( m*n ) )
333 bigtheta = one / rooteps
334 roottol = dsqrt( tol )
348 IF( ( nblr*kbl ).NE.n1 )nblr = nblr + 1
352 nblc = ( n-n1 ) / kbl
353 IF( ( nblc*kbl ).NE.( n-n1 ) )nblc = nblc + 1
354 blskip = ( kbl**2 ) + 1
357 rowskip = min( 5, kbl )
373 DO 1993 i = 1, nsweep
383 DO 2000 ibr = 1, nblr
385 igl = ( ibr-1 )*kbl + 1
391 igl = ( ibr-1 )*kbl + 1
393 DO 2010 jbc = 1, nblc
395 jgl = n1 + ( jbc-1 )*kbl + 1
400 DO 2100 p = igl, min( igl+kbl-1, n1 )
404 IF( aapp.GT.zero )
THEN
408 DO 2200 q = jgl, min( jgl+kbl-1, n )
412 IF( aaqq.GT.zero )
THEN
419 IF( aaqq.GE.one )
THEN
420 IF( aapp.GE.aaqq )
THEN
421 rotok = ( small*aapp ).LE.aaqq
423 rotok = ( small*aaqq ).LE.aapp
425 IF( aapp.LT.( big / aaqq ) )
THEN
426 aapq = ( ddot( m, a( 1, p ), 1, a( 1,
427 $ q ), 1 )*d( p )*d( q ) / aaqq )
430 CALL dcopy( m, a( 1, p ), 1, work, 1 )
431 CALL dlascl(
'G', 0, 0, aapp, d( p ),
432 $ m, 1, work, lda, ierr )
433 aapq = ddot( m, work, 1, a( 1, q ),
437 IF( aapp.GE.aaqq )
THEN
438 rotok = aapp.LE.( aaqq / small )
440 rotok = aaqq.LE.( aapp / small )
442 IF( aapp.GT.( small / aaqq ) )
THEN
443 aapq = ( ddot( m, a( 1, p ), 1, a( 1,
444 $ q ), 1 )*d( p )*d( q ) / aaqq )
447 CALL dcopy( m, a( 1, q ), 1, work, 1 )
448 CALL dlascl(
'G', 0, 0, aaqq, d( q ),
449 $ m, 1, work, lda, ierr )
450 aapq = ddot( m, work, 1, a( 1, p ),
455 mxaapq = max( mxaapq, dabs( aapq ) )
459 IF( dabs( aapq ).GT.tol )
THEN
469 theta = -half*dabs(aqoap-apoaq) / aapq
470 IF( aaqq.GT.aapp0 )theta = -theta
472 IF( dabs( theta ).GT.bigtheta )
THEN
474 fastr( 3 ) = t*d( p ) / d( q )
475 fastr( 4 ) = -t*d( q ) / d( p )
476 CALL drotm( m, a( 1, p ), 1,
477 $ a( 1, q ), 1, fastr )
478 IF( rsvec )
CALL drotm( mvl,
482 sva( q ) = aaqq*dsqrt( max( zero,
483 $ one+t*apoaq*aapq ) )
484 aapp = aapp*dsqrt( max( zero,
485 $ one-t*aqoap*aapq ) )
486 mxsinj = max( mxsinj, dabs( t ) )
491 thsign = -dsign( one, aapq )
492 IF( aaqq.GT.aapp0 )thsign = -thsign
493 t = one / ( theta+thsign*
494 $ dsqrt( one+theta*theta ) )
495 cs = dsqrt( one / ( one+t*t ) )
497 mxsinj = max( mxsinj, dabs( sn ) )
498 sva( q ) = aaqq*dsqrt( max( zero,
499 $ one+t*apoaq*aapq ) )
500 aapp = aapp*dsqrt( max( zero,
501 $ one-t*aqoap*aapq ) )
503 apoaq = d( p ) / d( q )
504 aqoap = d( q ) / d( p )
505 IF( d( p ).GE.one )
THEN
507 IF( d( q ).GE.one )
THEN
509 fastr( 4 ) = -t*aqoap
512 CALL drotm( m, a( 1, p ), 1,
515 IF( rsvec )
CALL drotm( mvl,
516 $ v( 1, p ), 1, v( 1, q ),
519 CALL daxpy( m, -t*aqoap,
522 CALL daxpy( m, cs*sn*apoaq,
526 CALL daxpy( mvl, -t*aqoap,
538 IF( d( q ).GE.one )
THEN
539 CALL daxpy( m, t*apoaq,
542 CALL daxpy( m, -cs*sn*aqoap,
546 CALL daxpy( mvl, t*apoaq,
557 IF( d( p ).GE.d( q ) )
THEN
558 CALL daxpy( m, -t*aqoap,
561 CALL daxpy( m, cs*sn*apoaq,
577 CALL daxpy( m, t*apoaq,
588 $ t*apoaq, v( 1, p ),
601 IF( aapp.GT.aaqq )
THEN
602 CALL dcopy( m, a( 1, p ), 1, work,
604 CALL dlascl(
'G', 0, 0, aapp, one,
605 $ m, 1, work, lda, ierr )
606 CALL dlascl(
'G', 0, 0, aaqq, one,
607 $ m, 1, a( 1, q ), lda,
609 temp1 = -aapq*d( p ) / d( q )
610 CALL daxpy( m, temp1, work, 1,
612 CALL dlascl(
'G', 0, 0, one, aaqq,
613 $ m, 1, a( 1, q ), lda,
615 sva( q ) = aaqq*dsqrt( max( zero,
617 mxsinj = max( mxsinj, sfmin )
619 CALL dcopy( m, a( 1, q ), 1, work,
621 CALL dlascl(
'G', 0, 0, aaqq, one,
622 $ m, 1, work, lda, ierr )
623 CALL dlascl(
'G', 0, 0, aapp, one,
624 $ m, 1, a( 1, p ), lda,
626 temp1 = -aapq*d( q ) / d( p )
627 CALL daxpy( m, temp1, work, 1,
629 CALL dlascl(
'G', 0, 0, one, aapp,
630 $ m, 1, a( 1, p ), lda,
632 sva( p ) = aapp*dsqrt( max( zero,
634 mxsinj = max( mxsinj, sfmin )
641 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
643 IF( ( aaqq.LT.rootbig ) .AND.
644 $ ( aaqq.GT.rootsfmin ) )
THEN
645 sva( q ) = dnrm2( m, a( 1, q ), 1 )*
650 CALL dlassq( m, a( 1, q ), 1, t,
652 sva( q ) = t*dsqrt( aaqq )*d( q )
655 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
656 IF( ( aapp.LT.rootbig ) .AND.
657 $ ( aapp.GT.rootsfmin ) )
THEN
658 aapp = dnrm2( m, a( 1, p ), 1 )*
663 CALL dlassq( m, a( 1, p ), 1, t,
665 aapp = t*dsqrt( aapp )*d( p )
673 pskipped = pskipped + 1
678 pskipped = pskipped + 1
683 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
689 IF( ( i.LE.swband ) .AND.
690 $ ( pskipped.GT.rowskip ) )
THEN
704 IF( aapp.EQ.zero )notrot = notrot +
705 $ min( jgl+kbl-1, n ) - jgl + 1
706 IF( aapp.LT.zero )notrot = 0
716 DO 2012 p = igl, min( igl+kbl-1, n )
717 sva( p ) = dabs( sva( p ) )
724 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
726 sva( n ) = dnrm2( m, a( 1, n ), 1 )*d( n )
730 CALL dlassq( m, a( 1, n ), 1, t, aapp )
731 sva( n ) = t*dsqrt( aapp )*d( n )
736 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
737 $ ( iswrot.LE.n ) ) )swband = i
739 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.dble( n )*tol ) .AND.
740 $ ( dble( n )*mxaapq*mxsinj.LT.tol ) )
THEN
745 IF( notrot.GE.emptsw )
GO TO 1994
764 q = idamax( n-p+1, sva( p ), 1 ) + p - 1
772 CALL dswap( m, a( 1, p ), 1, a( 1, q ), 1 )
773 IF( rsvec )
CALL dswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
subroutine xerbla(srname, info)
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgsvj1(jobv, m, n, n1, a, lda, d, sva, mv, v, ldv, eps, sfmin, tol, nsweep, work, lwork, info)
DGSVJ1 pre-processor for the routine dgesvj, applies Jacobi rotations targeting only particular pivot...
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine dlassq(n, x, incx, scale, sumsq)
DLASSQ updates a sum of squares represented in scaled form.
subroutine drotm(n, dx, incx, dy, incy, dparam)
DROTM
subroutine dswap(n, dx, incx, dy, incy)
DSWAP