234 SUBROUTINE sgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
235 $ EPS, SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
243 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
247 REAL A( LDA, * ), D( N ), SVA( N ), V( LDV, * ),
255 parameter( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
258 REAL 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
271 INTRINSIC abs, max, float, min, sign, sqrt
277 EXTERNAL isamax, lsame, sdot, snrm2
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(
'SGSVJ1', -info )
322 ELSE IF( applv )
THEN
325 rsvec = rsvec .OR. applv
327 rooteps = sqrt( eps )
328 rootsfmin = sqrt( sfmin )
331 rootbig = one / rootsfmin
332 large = big / sqrt( float( m*n ) )
333 bigtheta = one / rooteps
334 roottol = sqrt( 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 = ( sdot( m, a( 1, p ), 1, a( 1,
427 $ q ), 1 )*d( p )*d( q ) / aaqq )
430 CALL scopy( m, a( 1, p ), 1, work, 1 )
431 CALL slascl(
'G', 0, 0, aapp, d( p ),
432 $ m, 1, work, lda, ierr )
433 aapq = sdot( 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 = ( sdot( m, a( 1, p ), 1, a( 1,
444 $ q ), 1 )*d( p )*d( q ) / aaqq )
447 CALL scopy( m, a( 1, q ), 1, work, 1 )
448 CALL slascl(
'G', 0, 0, aaqq, d( q ),
449 $ m, 1, work, lda, ierr )
450 aapq = sdot( m, work, 1, a( 1, p ),
455 mxaapq = max( mxaapq, abs( aapq ) )
459 IF( abs( aapq ).GT.tol )
THEN
469 theta = -half*abs( aqoap-apoaq ) / aapq
470 IF( aaqq.GT.aapp0 )theta = -theta
472 IF( abs( theta ).GT.bigtheta )
THEN
474 fastr( 3 ) = t*d( p ) / d( q )
475 fastr( 4 ) = -t*d( q ) / d( p )
476 CALL srotm( m, a( 1, p ), 1,
477 $ a( 1, q ), 1, fastr )
478 IF( rsvec )
CALL srotm( mvl,
482 sva( q ) = aaqq*sqrt( max( zero,
483 $ one+t*apoaq*aapq ) )
484 aapp = aapp*sqrt( max( zero,
485 $ one-t*aqoap*aapq ) )
486 mxsinj = max( mxsinj, abs( t ) )
491 thsign = -sign( one, aapq )
492 IF( aaqq.GT.aapp0 )thsign = -thsign
493 t = one / ( theta+thsign*
494 $ sqrt( one+theta*theta ) )
495 cs = sqrt( one / ( one+t*t ) )
497 mxsinj = max( mxsinj, abs( sn ) )
498 sva( q ) = aaqq*sqrt( max( zero,
499 $ one+t*apoaq*aapq ) )
500 aapp = aapp*sqrt( 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 srotm( m, a( 1, p ), 1,
515 IF( rsvec )
CALL srotm( mvl,
516 $ v( 1, p ), 1, v( 1, q ),
519 CALL saxpy( m, -t*aqoap,
522 CALL saxpy( m, cs*sn*apoaq,
526 CALL saxpy( mvl, -t*aqoap,
538 IF( d( q ).GE.one )
THEN
539 CALL saxpy( m, t*apoaq,
542 CALL saxpy( m, -cs*sn*aqoap,
546 CALL saxpy( mvl, t*apoaq,
557 IF( d( p ).GE.d( q ) )
THEN
558 CALL saxpy( m, -t*aqoap,
561 CALL saxpy( m, cs*sn*apoaq,
577 CALL saxpy( m, t*apoaq,
588 $ t*apoaq, v( 1, p ),
601 IF( aapp.GT.aaqq )
THEN
602 CALL scopy( m, a( 1, p ), 1, work,
604 CALL slascl(
'G', 0, 0, aapp, one,
605 $ m, 1, work, lda, ierr )
606 CALL slascl(
'G', 0, 0, aaqq, one,
607 $ m, 1, a( 1, q ), lda,
609 temp1 = -aapq*d( p ) / d( q )
610 CALL saxpy( m, temp1, work, 1,
612 CALL slascl(
'G', 0, 0, one, aaqq,
613 $ m, 1, a( 1, q ), lda,
615 sva( q ) = aaqq*sqrt( max( zero,
617 mxsinj = max( mxsinj, sfmin )
619 CALL scopy( m, a( 1, q ), 1, work,
621 CALL slascl(
'G', 0, 0, aaqq, one,
622 $ m, 1, work, lda, ierr )
623 CALL slascl(
'G', 0, 0, aapp, one,
624 $ m, 1, a( 1, p ), lda,
626 temp1 = -aapq*d( q ) / d( p )
627 CALL saxpy( m, temp1, work, 1,
629 CALL slascl(
'G', 0, 0, one, aapp,
630 $ m, 1, a( 1, p ), lda,
632 sva( p ) = aapp*sqrt( 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 ) = snrm2( m, a( 1, q ), 1 )*
650 CALL slassq( m, a( 1, q ), 1, t,
652 sva( q ) = t*sqrt( aaqq )*d( q )
655 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
656 IF( ( aapp.LT.rootbig ) .AND.
657 $ ( aapp.GT.rootsfmin ) )
THEN
658 aapp = snrm2( m, a( 1, p ), 1 )*
663 CALL slassq( m, a( 1, p ), 1, t,
665 aapp = t*sqrt( 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 ) = abs( sva( p ) )
724 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
726 sva( n ) = snrm2( m, a( 1, n ), 1 )*d( n )
730 CALL slassq( m, a( 1, n ), 1, t, aapp )
731 sva( n ) = t*sqrt( 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.float( n )*tol ) .AND.
740 $ ( float( n )*mxaapq*mxsinj.LT.tol ) )
THEN
745 IF( notrot.GE.emptsw )
GO TO 1994
764 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
772 CALL sswap( m, a( 1, p ), 1, a( 1, q ), 1 )
773 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 sgsvj1(jobv, m, n, n1, a, lda, d, sva, mv, v, ldv, eps, sfmin, tol, nsweep, work, lwork, info)
SGSVJ1 pre-processor for the routine sgesvj, applies Jacobi rotations targeting only particular pivot...
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