216 SUBROUTINE zgsvj0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS,
217 $ SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
225 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP
226 DOUBLE PRECISION EPS, SFMIN, TOL
230 COMPLEX*16 A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK )
231 DOUBLE PRECISION SVA( N )
237 DOUBLE PRECISION ZERO, HALF, ONE
238 parameter( zero = 0.0d0, half = 0.5d0, one = 1.0d0)
239 COMPLEX*16 CZERO, CONE
240 parameter( czero = (0.0d0, 0.0d0), cone = (1.0d0, 0.0d0) )
243 COMPLEX*16 AAPQ, OMPQ
244 DOUBLE PRECISION AAPP, AAPP0, AAPQ1, AAQQ, APOAQ, AQOAP, BIG,
245 $ bigtheta, cs, mxaapq, mxsinj, rootbig, rooteps,
246 $ rootsfmin, roottol, small, sn, t, temp1, theta,
248 INTEGER BLSKIP, EMPTSW, i, ibr, IERR, igl, IJBLSK, ir1,
249 $ iswrot, jbc, jgl, kbl, lkahead, mvl, nbl,
250 $ notrot, p, pskipped, q, rowskip, swband
251 LOGICAL APPLV, ROTOK, RSVEC
255 INTRINSIC abs, max, conjg, dble, min, sign, sqrt
258 DOUBLE PRECISION DZNRM2
262 EXTERNAL idamax, lsame, zdotc, dznrm2
276 applv = lsame( jobv,
'A' )
277 rsvec = lsame( jobv,
'V' )
278 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
280 ELSE IF( m.LT.0 )
THEN
282 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
284 ELSE IF( lda.LT.m )
THEN
286 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
288 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
289 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
291 ELSE IF( tol.LE.eps )
THEN
293 ELSE IF( nsweep.LT.0 )
THEN
295 ELSE IF( lwork.LT.m )
THEN
303 CALL xerbla(
'ZGSVJ0', -info )
309 ELSE IF( applv )
THEN
312 rsvec = rsvec .OR. applv
314 rooteps = sqrt( eps )
315 rootsfmin = sqrt( sfmin )
318 rootbig = one / rootsfmin
319 bigtheta = one / rooteps
320 roottol = sqrt( tol )
324 emptsw = ( n*( n-1 ) ) / 2
345 IF( ( nbl*kbl ).NE.n )nbl = nbl + 1
350 rowskip = min( 5, kbl )
364 DO 1993 i = 1, nsweep
382 igl = ( ibr-1 )*kbl + 1
384 DO 1002 ir1 = 0, min( lkahead, nbl-ibr )
388 DO 2001 p = igl, min( igl+kbl-1, n-1 )
392 q = idamax( n-p+1, sva( p ), 1 ) + p - 1
394 CALL zswap( m, a( 1, p ), 1, a( 1, q ), 1 )
395 IF( rsvec )
CALL zswap( mvl, v( 1, p ), 1,
419 IF( ( sva( p ).LT.rootbig ) .AND.
420 $ ( sva( p ).GT.rootsfmin ) )
THEN
421 sva( p ) = dznrm2( m, a( 1, p ), 1 )
425 CALL zlassq( m, a( 1, p ), 1, temp1, aapp )
426 sva( p ) = temp1*sqrt( aapp )
433 IF( aapp.GT.zero )
THEN
437 DO 2002 q = p + 1, min( igl+kbl-1, n )
441 IF( aaqq.GT.zero )
THEN
444 IF( aaqq.GE.one )
THEN
445 rotok = ( small*aapp ).LE.aaqq
446 IF( aapp.LT.( big / aaqq ) )
THEN
447 aapq = ( zdotc( m, a( 1, p ), 1,
448 $ a( 1, q ), 1 ) / aaqq ) / aapp
450 CALL zcopy( m, a( 1, p ), 1,
452 CALL zlascl(
'G', 0, 0, aapp, one,
453 $ m, 1, work, lda, ierr )
454 aapq = zdotc( m, work, 1,
455 $ a( 1, q ), 1 ) / aaqq
458 rotok = aapp.LE.( aaqq / small )
459 IF( aapp.GT.( small / aaqq ) )
THEN
460 aapq = ( zdotc( m, a( 1, p ), 1,
461 $ a( 1, q ), 1 ) / aapp ) / aaqq
463 CALL zcopy( m, a( 1, q ), 1,
465 CALL zlascl(
'G', 0, 0, aaqq,
468 aapq = zdotc( m, a( 1, p ), 1,
475 mxaapq = max( mxaapq, -aapq1 )
479 IF( abs( aapq1 ).GT.tol )
THEN
480 ompq = aapq / abs(aapq)
495 theta = -half*abs( aqoap-apoaq )/aapq1
497 IF( abs( theta ).GT.bigtheta )
THEN
502 CALL zrot( m, a(1,p), 1, a(1,q), 1,
503 $ cs, conjg(ompq)*t )
505 CALL zrot( mvl, v(1,p), 1,
506 $ v(1,q), 1, cs, conjg(ompq)*t )
509 sva( q ) = aaqq*sqrt( max( zero,
510 $ one+t*apoaq*aapq1 ) )
511 aapp = aapp*sqrt( max( zero,
512 $ one-t*aqoap*aapq1 ) )
513 mxsinj = max( mxsinj, abs( t ) )
519 thsign = -sign( one, aapq1 )
520 t = one / ( theta+thsign*
521 $ sqrt( one+theta*theta ) )
522 cs = sqrt( one / ( one+t*t ) )
525 mxsinj = max( mxsinj, abs( sn ) )
526 sva( q ) = aaqq*sqrt( max( zero,
527 $ one+t*apoaq*aapq1 ) )
528 aapp = aapp*sqrt( max( zero,
529 $ one-t*aqoap*aapq1 ) )
531 CALL zrot( m, a(1,p), 1, a(1,q), 1,
532 $ cs, conjg(ompq)*sn )
534 CALL zrot( mvl, v(1,p), 1,
535 $ v(1,q), 1, cs, conjg(ompq)*sn )
542 CALL zcopy( m, a( 1, p ), 1,
544 CALL zlascl(
'G', 0, 0, aapp, one, m,
547 CALL zlascl(
'G', 0, 0, aaqq, one, m,
548 $ 1, a( 1, q ), lda, ierr )
549 CALL zaxpy( m, -aapq, work, 1,
551 CALL zlascl(
'G', 0, 0, one, aaqq, m,
552 $ 1, a( 1, q ), lda, ierr )
553 sva( q ) = aaqq*sqrt( max( zero,
554 $ one-aapq1*aapq1 ) )
555 mxsinj = max( mxsinj, sfmin )
562 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
564 IF( ( aaqq.LT.rootbig ) .AND.
565 $ ( aaqq.GT.rootsfmin ) )
THEN
566 sva( q ) = dznrm2( m, a( 1, q ), 1 )
570 CALL zlassq( m, a( 1, q ), 1, t,
572 sva( q ) = t*sqrt( aaqq )
575 IF( ( aapp / aapp0 ).LE.rooteps )
THEN
576 IF( ( aapp.LT.rootbig ) .AND.
577 $ ( aapp.GT.rootsfmin ) )
THEN
578 aapp = dznrm2( m, a( 1, p ), 1 )
582 CALL zlassq( m, a( 1, p ), 1, t,
584 aapp = t*sqrt( aapp )
591 IF( ir1.EQ.0 )notrot = notrot + 1
593 pskipped = pskipped + 1
597 IF( ir1.EQ.0 )notrot = notrot + 1
598 pskipped = pskipped + 1
601 IF( ( i.LE.swband ) .AND.
602 $ ( pskipped.GT.rowskip ) )
THEN
603 IF( ir1.EQ.0 )aapp = -aapp
618 IF( ( ir1.EQ.0 ) .AND. ( aapp.EQ.zero ) )
619 $ notrot = notrot + min( igl+kbl-1, n ) - p
630 igl = ( ibr-1 )*kbl + 1
632 DO 2010 jbc = ibr + 1, nbl
634 jgl = ( jbc-1 )*kbl + 1
639 DO 2100 p = igl, min( igl+kbl-1, n )
642 IF( aapp.GT.zero )
THEN
646 DO 2200 q = jgl, min( jgl+kbl-1, n )
649 IF( aaqq.GT.zero )
THEN
656 IF( aaqq.GE.one )
THEN
657 IF( aapp.GE.aaqq )
THEN
658 rotok = ( small*aapp ).LE.aaqq
660 rotok = ( small*aaqq ).LE.aapp
662 IF( aapp.LT.( big / aaqq ) )
THEN
663 aapq = ( zdotc( m, a( 1, p ), 1,
664 $ a( 1, q ), 1 ) / aaqq ) / aapp
666 CALL zcopy( m, a( 1, p ), 1,
668 CALL zlascl(
'G', 0, 0, aapp,
671 aapq = zdotc( m, work, 1,
672 $ a( 1, q ), 1 ) / aaqq
675 IF( aapp.GE.aaqq )
THEN
676 rotok = aapp.LE.( aaqq / small )
678 rotok = aaqq.LE.( aapp / small )
680 IF( aapp.GT.( small / aaqq ) )
THEN
681 aapq = ( zdotc( m, a( 1, p ), 1,
682 $ a( 1, q ), 1 ) / max(aaqq,aapp) )
685 CALL zcopy( m, a( 1, q ), 1,
687 CALL zlascl(
'G', 0, 0, aaqq,
690 aapq = zdotc( m, a( 1, p ), 1,
697 mxaapq = max( mxaapq, -aapq1 )
701 IF( abs( aapq1 ).GT.tol )
THEN
702 ompq = aapq / abs(aapq)
712 theta = -half*abs( aqoap-apoaq )/ aapq1
713 IF( aaqq.GT.aapp0 )theta = -theta
715 IF( abs( theta ).GT.bigtheta )
THEN
718 CALL zrot( m, a(1,p), 1, a(1,q), 1,
719 $ cs, conjg(ompq)*t )
721 CALL zrot( mvl, v(1,p), 1,
722 $ v(1,q), 1, cs, conjg(ompq)*t )
724 sva( q ) = aaqq*sqrt( max( zero,
725 $ one+t*apoaq*aapq1 ) )
726 aapp = aapp*sqrt( max( zero,
727 $ one-t*aqoap*aapq1 ) )
728 mxsinj = max( mxsinj, abs( t ) )
733 thsign = -sign( one, aapq1 )
734 IF( aaqq.GT.aapp0 )thsign = -thsign
735 t = one / ( theta+thsign*
736 $ sqrt( one+theta*theta ) )
737 cs = sqrt( one / ( one+t*t ) )
739 mxsinj = max( mxsinj, abs( sn ) )
740 sva( q ) = aaqq*sqrt( max( zero,
741 $ one+t*apoaq*aapq1 ) )
742 aapp = aapp*sqrt( max( zero,
743 $ one-t*aqoap*aapq1 ) )
745 CALL zrot( m, a(1,p), 1, a(1,q), 1,
746 $ cs, conjg(ompq)*sn )
748 CALL zrot( mvl, v(1,p), 1,
749 $ v(1,q), 1, cs, conjg(ompq)*sn )
756 IF( aapp.GT.aaqq )
THEN
757 CALL zcopy( m, a( 1, p ), 1,
759 CALL zlascl(
'G', 0, 0, aapp, one,
762 CALL zlascl(
'G', 0, 0, aaqq, one,
763 $ m, 1, a( 1, q ), lda,
765 CALL zaxpy( m, -aapq, work,
767 CALL zlascl(
'G', 0, 0, one, aaqq,
768 $ m, 1, a( 1, q ), lda,
770 sva( q ) = aaqq*sqrt( max( zero,
771 $ one-aapq1*aapq1 ) )
772 mxsinj = max( mxsinj, sfmin )
774 CALL zcopy( m, a( 1, q ), 1,
776 CALL zlascl(
'G', 0, 0, aaqq, one,
779 CALL zlascl(
'G', 0, 0, aapp, one,
780 $ m, 1, a( 1, p ), lda,
782 CALL zaxpy( m, -conjg(aapq),
783 $ work, 1, a( 1, p ), 1 )
784 CALL zlascl(
'G', 0, 0, one, aapp,
785 $ m, 1, a( 1, p ), lda,
787 sva( p ) = aapp*sqrt( max( zero,
788 $ one-aapq1*aapq1 ) )
789 mxsinj = max( mxsinj, sfmin )
796 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
798 IF( ( aaqq.LT.rootbig ) .AND.
799 $ ( aaqq.GT.rootsfmin ) )
THEN
800 sva( q ) = dznrm2( m, a( 1, q ), 1)
804 CALL zlassq( m, a( 1, q ), 1, t,
806 sva( q ) = t*sqrt( aaqq )
809 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
810 IF( ( aapp.LT.rootbig ) .AND.
811 $ ( aapp.GT.rootsfmin ) )
THEN
812 aapp = dznrm2( m, a( 1, p ), 1 )
816 CALL zlassq( m, a( 1, p ), 1, t,
818 aapp = t*sqrt( aapp )
826 pskipped = pskipped + 1
831 pskipped = pskipped + 1
835 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
841 IF( ( i.LE.swband ) .AND.
842 $ ( pskipped.GT.rowskip ) )
THEN
856 IF( aapp.EQ.zero )notrot = notrot +
857 $ min( jgl+kbl-1, n ) - jgl + 1
858 IF( aapp.LT.zero )notrot = 0
868 DO 2012 p = igl, min( igl+kbl-1, n )
869 sva( p ) = abs( sva( p ) )
876 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
878 sva( n ) = dznrm2( m, a( 1, n ), 1 )
882 CALL zlassq( m, a( 1, n ), 1, t, aapp )
883 sva( n ) = t*sqrt( aapp )
888 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
889 $ ( iswrot.LE.n ) ) )swband = i
891 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( dble( n ) )*
892 $ tol ) .AND. ( dble( n )*mxaapq*mxsinj.LT.tol ) )
THEN
896 IF( notrot.GE.emptsw )
GO TO 1994
915 q = idamax( n-p+1, sva( p ), 1 ) + p - 1
923 CALL zswap( m, a( 1, p ), 1, a( 1, q ), 1 )
924 IF( rsvec )
CALL zswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
subroutine xerbla(srname, info)
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine zgsvj0(jobv, m, n, a, lda, d, sva, mv, v, ldv, eps, sfmin, tol, nsweep, work, lwork, info)
ZGSVJ0 pre-processor for the routine zgesvj.
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlassq(n, x, incx, scale, sumsq)
ZLASSQ updates a sum of squares represented in scaled form.
subroutine zrot(n, cx, incx, cy, incy, c, s)
ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP