216 SUBROUTINE sgsvj0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS,
217 $ SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
224 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP
229 REAL A( LDA, * ), SVA( N ), D( N ), V( LDV, * ),
237 parameter( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
240 REAL AAPP, AAPP0, AAPQ, AAQQ, APOAQ, AQOAP, BIG,
241 $ bigtheta, cs, mxaapq, mxsinj, rootbig, rooteps,
242 $ rootsfmin, roottol, small, sn, t, temp1, theta,
244 INTEGER BLSKIP, EMPTSW, i, ibr, IERR, igl, IJBLSK, ir1,
245 $ iswrot, jbc, jgl, kbl, lkahead, mvl, nbl,
246 $ notrot, p, pskipped, q, rowskip, swband
247 LOGICAL APPLV, ROTOK, RSVEC
253 INTRINSIC abs, max, float, min, sign, sqrt
259 EXTERNAL isamax, lsame, sdot, snrm2
269 applv = lsame( jobv,
'A' )
270 rsvec = lsame( jobv,
'V' )
271 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
273 ELSE IF( m.LT.0 )
THEN
275 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
277 ELSE IF( lda.LT.m )
THEN
279 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
281 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
282 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
284 ELSE IF( tol.LE.eps )
THEN
286 ELSE IF( nsweep.LT.0 )
THEN
288 ELSE IF( lwork.LT.m )
THEN
296 CALL xerbla(
'SGSVJ0', -info )
302 ELSE IF( applv )
THEN
305 rsvec = rsvec .OR. applv
307 rooteps = sqrt( eps )
308 rootsfmin = sqrt( sfmin )
311 rootbig = one / rootsfmin
312 bigtheta = one / rooteps
313 roottol = sqrt( tol )
317 emptsw = ( n*( n-1 ) ) / 2
337 IF( ( nbl*kbl ).NE.n )nbl = nbl + 1
339 blskip = ( kbl**2 ) + 1
342 rowskip = min( 5, kbl )
350 DO 1993 i = 1, nsweep
362 igl = ( ibr-1 )*kbl + 1
364 DO 1002 ir1 = 0, min( lkahead, nbl-ibr )
368 DO 2001 p = igl, min( igl+kbl-1, n-1 )
371 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
373 CALL sswap( m, a( 1, p ), 1, a( 1, q ), 1 )
374 IF( rsvec )
CALL sswap( mvl, v( 1, p ), 1,
398 IF( ( sva( p ).LT.rootbig ) .AND.
399 $ ( sva( p ).GT.rootsfmin ) )
THEN
400 sva( p ) = snrm2( m, a( 1, p ), 1 )*d( p )
404 CALL slassq( m, a( 1, p ), 1, temp1, aapp )
405 sva( p ) = temp1*sqrt( aapp )*d( p )
413 IF( aapp.GT.zero )
THEN
417 DO 2002 q = p + 1, min( igl+kbl-1, n )
421 IF( aaqq.GT.zero )
THEN
424 IF( aaqq.GE.one )
THEN
425 rotok = ( small*aapp ).LE.aaqq
426 IF( aapp.LT.( big / aaqq ) )
THEN
427 aapq = ( sdot( m, a( 1, p ), 1, a( 1,
428 $ q ), 1 )*d( p )*d( q ) / aaqq )
431 CALL scopy( m, a( 1, p ), 1, work, 1 )
432 CALL slascl(
'G', 0, 0, aapp, d( p ),
433 $ m, 1, work, lda, ierr )
434 aapq = sdot( m, work, 1, a( 1, q ),
438 rotok = aapp.LE.( aaqq / small )
439 IF( aapp.GT.( small / aaqq ) )
THEN
440 aapq = ( sdot( m, a( 1, p ), 1, a( 1,
441 $ q ), 1 )*d( p )*d( q ) / aaqq )
444 CALL scopy( m, a( 1, q ), 1, work, 1 )
445 CALL slascl(
'G', 0, 0, aaqq, d( q ),
446 $ m, 1, work, lda, ierr )
447 aapq = sdot( m, work, 1, a( 1, p ),
452 mxaapq = max( mxaapq, abs( aapq ) )
456 IF( abs( aapq ).GT.tol )
THEN
471 theta = -half*abs( aqoap-apoaq ) / aapq
473 IF( abs( theta ).GT.bigtheta )
THEN
476 fastr( 3 ) = t*d( p ) / d( q )
477 fastr( 4 ) = -t*d( q ) / d( p )
478 CALL srotm( m, a( 1, p ), 1,
479 $ a( 1, q ), 1, fastr )
480 IF( rsvec )
CALL srotm( mvl,
484 sva( q ) = aaqq*sqrt( max( zero,
485 $ one+t*apoaq*aapq ) )
486 aapp = aapp*sqrt( max( zero,
487 $ one-t*aqoap*aapq ) )
488 mxsinj = max( mxsinj, abs( t ) )
494 thsign = -sign( one, aapq )
495 t = one / ( theta+thsign*
496 $ sqrt( one+theta*theta ) )
497 cs = sqrt( one / ( one+t*t ) )
500 mxsinj = max( mxsinj, abs( sn ) )
501 sva( q ) = aaqq*sqrt( max( zero,
502 $ one+t*apoaq*aapq ) )
503 aapp = aapp*sqrt( max( zero,
504 $ one-t*aqoap*aapq ) )
506 apoaq = d( p ) / d( q )
507 aqoap = d( q ) / d( p )
508 IF( d( p ).GE.one )
THEN
509 IF( d( q ).GE.one )
THEN
511 fastr( 4 ) = -t*aqoap
514 CALL srotm( m, a( 1, p ), 1,
517 IF( rsvec )
CALL srotm( mvl,
518 $ v( 1, p ), 1, v( 1, q ),
521 CALL saxpy( m, -t*aqoap,
524 CALL saxpy( m, cs*sn*apoaq,
530 CALL saxpy( mvl, -t*aqoap,
540 IF( d( q ).GE.one )
THEN
541 CALL saxpy( m, t*apoaq,
544 CALL saxpy( m, -cs*sn*aqoap,
550 CALL saxpy( mvl, t*apoaq,
559 IF( d( p ).GE.d( q ) )
THEN
560 CALL saxpy( m, -t*aqoap,
563 CALL saxpy( m, cs*sn*apoaq,
579 CALL saxpy( m, t*apoaq,
590 $ t*apoaq, v( 1, p ),
604 CALL scopy( m, a( 1, p ), 1, work, 1 )
605 CALL slascl(
'G', 0, 0, aapp, one, m,
606 $ 1, work, lda, ierr )
607 CALL slascl(
'G', 0, 0, aaqq, one, m,
608 $ 1, a( 1, q ), lda, ierr )
609 temp1 = -aapq*d( p ) / d( q )
610 CALL saxpy( m, temp1, work, 1,
612 CALL slascl(
'G', 0, 0, one, aaqq, m,
613 $ 1, a( 1, q ), lda, ierr )
614 sva( q ) = aaqq*sqrt( max( zero,
616 mxsinj = max( mxsinj, sfmin )
622 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
624 IF( ( aaqq.LT.rootbig ) .AND.
625 $ ( aaqq.GT.rootsfmin ) )
THEN
626 sva( q ) = snrm2( m, a( 1, q ), 1 )*
631 CALL slassq( m, a( 1, q ), 1, t,
633 sva( q ) = t*sqrt( aaqq )*d( q )
636 IF( ( aapp / aapp0 ).LE.rooteps )
THEN
637 IF( ( aapp.LT.rootbig ) .AND.
638 $ ( aapp.GT.rootsfmin ) )
THEN
639 aapp = snrm2( m, a( 1, p ), 1 )*
644 CALL slassq( m, a( 1, p ), 1, t,
646 aapp = t*sqrt( aapp )*d( p )
653 IF( ir1.EQ.0 )notrot = notrot + 1
654 pskipped = pskipped + 1
658 IF( ir1.EQ.0 )notrot = notrot + 1
659 pskipped = pskipped + 1
662 IF( ( i.LE.swband ) .AND.
663 $ ( pskipped.GT.rowskip ) )
THEN
664 IF( ir1.EQ.0 )aapp = -aapp
679 IF( ( ir1.EQ.0 ) .AND. ( aapp.EQ.zero ) )
680 $ notrot = notrot + min( igl+kbl-1, n ) - p
692 igl = ( ibr-1 )*kbl + 1
694 DO 2010 jbc = ibr + 1, nbl
696 jgl = ( jbc-1 )*kbl + 1
701 DO 2100 p = igl, min( igl+kbl-1, n )
705 IF( aapp.GT.zero )
THEN
709 DO 2200 q = jgl, min( jgl+kbl-1, n )
713 IF( aaqq.GT.zero )
THEN
720 IF( aaqq.GE.one )
THEN
721 IF( aapp.GE.aaqq )
THEN
722 rotok = ( small*aapp ).LE.aaqq
724 rotok = ( small*aaqq ).LE.aapp
726 IF( aapp.LT.( big / aaqq ) )
THEN
727 aapq = ( sdot( m, a( 1, p ), 1, a( 1,
728 $ q ), 1 )*d( p )*d( q ) / aaqq )
731 CALL scopy( m, a( 1, p ), 1, work, 1 )
732 CALL slascl(
'G', 0, 0, aapp, d( p ),
733 $ m, 1, work, lda, ierr )
734 aapq = sdot( m, work, 1, a( 1, q ),
738 IF( aapp.GE.aaqq )
THEN
739 rotok = aapp.LE.( aaqq / small )
741 rotok = aaqq.LE.( aapp / small )
743 IF( aapp.GT.( small / aaqq ) )
THEN
744 aapq = ( sdot( m, a( 1, p ), 1, a( 1,
745 $ q ), 1 )*d( p )*d( q ) / aaqq )
748 CALL scopy( m, a( 1, q ), 1, work, 1 )
749 CALL slascl(
'G', 0, 0, aaqq, d( q ),
750 $ m, 1, work, lda, ierr )
751 aapq = sdot( m, work, 1, a( 1, p ),
756 mxaapq = max( mxaapq, abs( aapq ) )
760 IF( abs( aapq ).GT.tol )
THEN
770 theta = -half*abs( aqoap-apoaq ) / aapq
771 IF( aaqq.GT.aapp0 )theta = -theta
773 IF( abs( theta ).GT.bigtheta )
THEN
775 fastr( 3 ) = t*d( p ) / d( q )
776 fastr( 4 ) = -t*d( q ) / d( p )
777 CALL srotm( m, a( 1, p ), 1,
778 $ a( 1, q ), 1, fastr )
779 IF( rsvec )
CALL srotm( mvl,
783 sva( q ) = aaqq*sqrt( max( zero,
784 $ one+t*apoaq*aapq ) )
785 aapp = aapp*sqrt( max( zero,
786 $ one-t*aqoap*aapq ) )
787 mxsinj = max( mxsinj, abs( t ) )
792 thsign = -sign( one, aapq )
793 IF( aaqq.GT.aapp0 )thsign = -thsign
794 t = one / ( theta+thsign*
795 $ sqrt( one+theta*theta ) )
796 cs = sqrt( one / ( one+t*t ) )
798 mxsinj = max( mxsinj, abs( sn ) )
799 sva( q ) = aaqq*sqrt( max( zero,
800 $ one+t*apoaq*aapq ) )
801 aapp = aapp*sqrt( max( zero,
802 $ one-t*aqoap*aapq ) )
804 apoaq = d( p ) / d( q )
805 aqoap = d( q ) / d( p )
806 IF( d( p ).GE.one )
THEN
808 IF( d( q ).GE.one )
THEN
810 fastr( 4 ) = -t*aqoap
813 CALL srotm( m, a( 1, p ), 1,
816 IF( rsvec )
CALL srotm( mvl,
817 $ v( 1, p ), 1, v( 1, q ),
820 CALL saxpy( m, -t*aqoap,
823 CALL saxpy( m, cs*sn*apoaq,
827 CALL saxpy( mvl, -t*aqoap,
839 IF( d( q ).GE.one )
THEN
840 CALL saxpy( m, t*apoaq,
843 CALL saxpy( m, -cs*sn*aqoap,
847 CALL saxpy( mvl, t*apoaq,
858 IF( d( p ).GE.d( q ) )
THEN
859 CALL saxpy( m, -t*aqoap,
862 CALL saxpy( m, cs*sn*apoaq,
878 CALL saxpy( m, t*apoaq,
889 $ t*apoaq, v( 1, p ),
902 IF( aapp.GT.aaqq )
THEN
903 CALL scopy( m, a( 1, p ), 1, work,
905 CALL slascl(
'G', 0, 0, aapp, one,
906 $ m, 1, work, lda, ierr )
907 CALL slascl(
'G', 0, 0, aaqq, one,
908 $ m, 1, a( 1, q ), lda,
910 temp1 = -aapq*d( p ) / d( q )
911 CALL saxpy( m, temp1, work, 1,
913 CALL slascl(
'G', 0, 0, one, aaqq,
914 $ m, 1, a( 1, q ), lda,
916 sva( q ) = aaqq*sqrt( max( zero,
918 mxsinj = max( mxsinj, sfmin )
920 CALL scopy( m, a( 1, q ), 1, work,
922 CALL slascl(
'G', 0, 0, aaqq, one,
923 $ m, 1, work, lda, ierr )
924 CALL slascl(
'G', 0, 0, aapp, one,
925 $ m, 1, a( 1, p ), lda,
927 temp1 = -aapq*d( q ) / d( p )
928 CALL saxpy( m, temp1, work, 1,
930 CALL slascl(
'G', 0, 0, one, aapp,
931 $ m, 1, a( 1, p ), lda,
933 sva( p ) = aapp*sqrt( max( zero,
935 mxsinj = max( mxsinj, sfmin )
942 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
944 IF( ( aaqq.LT.rootbig ) .AND.
945 $ ( aaqq.GT.rootsfmin ) )
THEN
946 sva( q ) = snrm2( m, a( 1, q ), 1 )*
951 CALL slassq( m, a( 1, q ), 1, t,
953 sva( q ) = t*sqrt( aaqq )*d( q )
956 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
957 IF( ( aapp.LT.rootbig ) .AND.
958 $ ( aapp.GT.rootsfmin ) )
THEN
959 aapp = snrm2( m, a( 1, p ), 1 )*
964 CALL slassq( m, a( 1, p ), 1, t,
966 aapp = t*sqrt( aapp )*d( p )
973 pskipped = pskipped + 1
978 pskipped = pskipped + 1
982 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
988 IF( ( i.LE.swband ) .AND.
989 $ ( pskipped.GT.rowskip ) )
THEN
1002 IF( aapp.EQ.zero )notrot = notrot +
1003 $ min( jgl+kbl-1, n ) - jgl + 1
1004 IF( aapp.LT.zero )notrot = 0
1013 DO 2012 p = igl, min( igl+kbl-1, n )
1014 sva( p ) = abs( sva( p ) )
1021 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
1023 sva( n ) = snrm2( m, a( 1, n ), 1 )*d( n )
1027 CALL slassq( m, a( 1, n ), 1, t, aapp )
1028 sva( n ) = t*sqrt( aapp )*d( n )
1033 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
1034 $ ( iswrot.LE.n ) ) )swband = i
1036 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.float( n )*tol ) .AND.
1037 $ ( float( n )*mxaapq*mxsinj.LT.tol ) )
THEN
1041 IF( notrot.GE.emptsw )
GO TO 1994
1058 DO 5991 p = 1, n - 1
1059 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
1067 CALL sswap( m, a( 1, p ), 1, a( 1, q ), 1 )
1068 IF( rsvec )
CALL sswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
subroutine xerbla(srname, info)
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
subroutine sgsvj0(jobv, m, n, a, lda, d, sva, mv, v, ldv, eps, sfmin, tol, nsweep, work, lwork, info)
SGSVJ0 pre-processor for the routine sgesvj.
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine slassq(n, x, incx, scale, sumsq)
SLASSQ updates a sum of squares represented in scaled form.
subroutine srotm(n, sx, incx, sy, incy, sparam)
SROTM
subroutine sswap(n, sx, incx, sy, incy)
SSWAP