232 SUBROUTINE zgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
233 $ EPS, SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
241 DOUBLE PRECISION EPS, SFMIN, TOL
242 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
246 COMPLEX*16 A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK )
247 DOUBLE PRECISION SVA( N )
253 DOUBLE PRECISION ZERO, HALF, ONE
254 parameter( zero = 0.0d0, half = 0.5d0, one = 1.0d0)
257 COMPLEX*16 AAPQ, OMPQ
258 DOUBLE PRECISION AAPP, AAPP0, AAPQ1, AAQQ, APOAQ, AQOAP, BIG,
259 $ bigtheta, cs, 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
269 INTRINSIC abs, conjg, max, dble, min, sign, sqrt
272 DOUBLE PRECISION DZNRM2
276 EXTERNAL idamax, lsame, zdotc, dznrm2
288 applv = lsame( jobv,
'A' )
289 rsvec = lsame( jobv,
'V' )
290 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
292 ELSE IF( m.LT.0 )
THEN
294 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
296 ELSE IF( n1.LT.0 )
THEN
298 ELSE IF( lda.LT.m )
THEN
300 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
302 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
303 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
305 ELSE IF( tol.LE.eps )
THEN
307 ELSE IF( nsweep.LT.0 )
THEN
309 ELSE IF( lwork.LT.m )
THEN
317 CALL xerbla(
'ZGSVJ1', -info )
323 ELSE IF( applv )
THEN
326 rsvec = rsvec .OR. applv
328 rooteps = sqrt( eps )
329 rootsfmin = sqrt( sfmin )
332 rootbig = one / rootsfmin
334 bigtheta = one / rooteps
335 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
389 DO 2000 ibr = 1, nblr
391 igl = ( ibr-1 )*kbl + 1
397 igl = ( ibr-1 )*kbl + 1
400 DO 2010 jbc = 1, nblc
402 jgl = ( jbc-1 )*kbl + n1 + 1
407 DO 2100 p = igl, min( igl+kbl-1, n1 )
410 IF( aapp.GT.zero )
THEN
414 DO 2200 q = jgl, min( jgl+kbl-1, n )
417 IF( aaqq.GT.zero )
THEN
424 IF( aaqq.GE.one )
THEN
425 IF( aapp.GE.aaqq )
THEN
426 rotok = ( small*aapp ).LE.aaqq
428 rotok = ( small*aaqq ).LE.aapp
430 IF( aapp.LT.( big / aaqq ) )
THEN
431 aapq = ( zdotc( m, a( 1, p ), 1,
432 $ a( 1, q ), 1 ) / aaqq ) / aapp
434 CALL zcopy( m, a( 1, p ), 1,
436 CALL zlascl(
'G', 0, 0, aapp,
439 aapq = zdotc( m, work, 1,
440 $ a( 1, q ), 1 ) / aaqq
443 IF( aapp.GE.aaqq )
THEN
444 rotok = aapp.LE.( aaqq / small )
446 rotok = aaqq.LE.( aapp / small )
448 IF( aapp.GT.( small / aaqq ) )
THEN
449 aapq = ( zdotc( m, a( 1, p ), 1,
450 $ a( 1, q ), 1 ) / max(aaqq,aapp) )
453 CALL zcopy( m, a( 1, q ), 1,
455 CALL zlascl(
'G', 0, 0, aaqq,
458 aapq = zdotc( m, a( 1, p ), 1,
465 mxaapq = max( mxaapq, -aapq1 )
469 IF( abs( aapq1 ).GT.tol )
THEN
470 ompq = aapq / abs(aapq)
480 theta = -half*abs( aqoap-apoaq )/ aapq1
481 IF( aaqq.GT.aapp0 )theta = -theta
483 IF( abs( theta ).GT.bigtheta )
THEN
486 CALL zrot( m, a(1,p), 1, a(1,q),
488 $ cs, conjg(ompq)*t )
490 CALL zrot( mvl, v(1,p), 1,
491 $ v(1,q), 1, cs, conjg(ompq)*t )
493 sva( q ) = aaqq*sqrt( max( zero,
494 $ one+t*apoaq*aapq1 ) )
495 aapp = aapp*sqrt( max( zero,
496 $ one-t*aqoap*aapq1 ) )
497 mxsinj = max( mxsinj, abs( t ) )
502 thsign = -sign( one, aapq1 )
503 IF( aaqq.GT.aapp0 )thsign = -thsign
504 t = one / ( theta+thsign*
505 $ sqrt( one+theta*theta ) )
506 cs = sqrt( one / ( one+t*t ) )
508 mxsinj = max( mxsinj, abs( sn ) )
509 sva( q ) = aaqq*sqrt( max( zero,
510 $ one+t*apoaq*aapq1 ) )
511 aapp = aapp*sqrt( max( zero,
512 $ one-t*aqoap*aapq1 ) )
514 CALL zrot( m, a(1,p), 1, a(1,q),
516 $ cs, conjg(ompq)*sn )
518 CALL zrot( mvl, v(1,p), 1,
519 $ v(1,q), 1, cs, conjg(ompq)*sn )
526 IF( aapp.GT.aaqq )
THEN
527 CALL zcopy( m, a( 1, p ), 1,
529 CALL zlascl(
'G', 0, 0, aapp,
533 CALL zlascl(
'G', 0, 0, aaqq,
535 $ m, 1, a( 1, q ), lda,
537 CALL zaxpy( m, -aapq, work,
539 CALL zlascl(
'G', 0, 0, one,
541 $ m, 1, a( 1, q ), lda,
543 sva( q ) = aaqq*sqrt( max( zero,
544 $ one-aapq1*aapq1 ) )
545 mxsinj = max( mxsinj, sfmin )
547 CALL zcopy( m, a( 1, q ), 1,
549 CALL zlascl(
'G', 0, 0, aaqq,
553 CALL zlascl(
'G', 0, 0, aapp,
555 $ m, 1, a( 1, p ), lda,
557 CALL zaxpy( m, -conjg(aapq),
558 $ work, 1, a( 1, p ), 1 )
559 CALL zlascl(
'G', 0, 0, one,
561 $ m, 1, a( 1, p ), lda,
563 sva( p ) = aapp*sqrt( max( zero,
564 $ one-aapq1*aapq1 ) )
565 mxsinj = max( mxsinj, sfmin )
572 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
574 IF( ( aaqq.LT.rootbig ) .AND.
575 $ ( aaqq.GT.rootsfmin ) )
THEN
576 sva( q ) = dznrm2( m, a( 1, q ),
581 CALL zlassq( m, a( 1, q ), 1, t,
583 sva( q ) = t*sqrt( aaqq )
586 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
587 IF( ( aapp.LT.rootbig ) .AND.
588 $ ( aapp.GT.rootsfmin ) )
THEN
589 aapp = dznrm2( m, a( 1, p ), 1 )
593 CALL zlassq( m, a( 1, p ), 1, t,
595 aapp = t*sqrt( aapp )
603 pskipped = pskipped + 1
608 pskipped = pskipped + 1
612 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
618 IF( ( i.LE.swband ) .AND.
619 $ ( pskipped.GT.rowskip ) )
THEN
633 IF( aapp.EQ.zero )notrot = notrot +
634 $ min( jgl+kbl-1, n ) - jgl + 1
635 IF( aapp.LT.zero )notrot = 0
645 DO 2012 p = igl, min( igl+kbl-1, n )
646 sva( p ) = abs( sva( p ) )
653 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
655 sva( n ) = dznrm2( m, a( 1, n ), 1 )
659 CALL zlassq( m, a( 1, n ), 1, t, aapp )
660 sva( n ) = t*sqrt( aapp )
665 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
666 $ ( iswrot.LE.n ) ) )swband = i
668 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( dble( n ) )*
669 $ tol ) .AND. ( dble( n )*mxaapq*mxsinj.LT.tol ) )
THEN
673 IF( notrot.GE.emptsw )
GO TO 1994
692 q = idamax( n-p+1, sva( p ), 1 ) + p - 1
700 CALL zswap( m, a( 1, p ), 1, a( 1, q ), 1 )
701 IF( rsvec )
CALL zswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )