228 INTEGER info, lda, ldv, lwork, m, mv, n, nsweep
233 COMPLEX a( lda, * ), d( n ), v( ldv, * ), work( lwork )
241 parameter ( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
243 parameter( czero = (0.0e0, 0.0e0), cone = (1.0e0, 0.0e0) )
247 REAL aapp, aapp0, aapq1, aaqq, apoaq, aqoap, big,
248 $ bigtheta, cs, mxaapq, mxsinj, rootbig, rooteps,
249 $ rootsfmin, roottol, small, sn, t, temp1, theta,
251 INTEGER blskip, emptsw, i, ibr, ierr, igl, ijblsk, ir1,
252 $ iswrot, jbc, jgl, kbl, lkahead, mvl, nbl,
253 $ notrot, p, pskipped, q, rowskip, swband
254 LOGICAL applv, rotok, rsvec
258 INTRINSIC abs, amax1, conjg, float, min0, sign, sqrt
279 applv =
lsame( jobv,
'A' )
280 rsvec =
lsame( jobv,
'V' )
281 IF( .NOT.( rsvec .OR. applv .OR.
lsame( jobv,
'N' ) ) )
THEN
283 ELSE IF( m.LT.0 )
THEN
285 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
287 ELSE IF( lda.LT.m )
THEN
289 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
291 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
292 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
294 ELSE IF( tol.LE.eps )
THEN
296 ELSE IF( nsweep.LT.0 )
THEN
298 ELSE IF( lwork.LT.m )
THEN
306 CALL xerbla(
'CGSVJ0', -info )
312 ELSE IF( applv )
THEN
315 rsvec = rsvec .OR. applv
317 rooteps = sqrt( eps )
318 rootsfmin = sqrt( sfmin )
321 rootbig = one / rootsfmin
322 bigtheta = one / rooteps
323 roottol = sqrt( tol )
327 emptsw = ( n*( n-1 ) ) / 2
348 IF( ( nbl*kbl ).NE.n )nbl = nbl + 1
353 rowskip = min0( 5, kbl )
367 DO 1993 i = 1, nsweep
385 igl = ( ibr-1 )*kbl + 1
387 DO 1002 ir1 = 0, min0( lkahead, nbl-ibr )
391 DO 2001 p = igl, min0( igl+kbl-1, n-1 )
395 q =
isamax( n-p+1, sva( p ), 1 ) + p - 1
397 CALL cswap( m, a( 1, p ), 1, a( 1, q ), 1 )
398 IF( rsvec )
CALL cswap( mvl, v( 1, p ), 1,
422 IF( ( sva( p ).LT.rootbig ) .AND.
423 $ ( sva( p ).GT.rootsfmin ) )
THEN
424 sva( p ) =
scnrm2( m, a( 1, p ), 1 )
428 CALL classq( m, a( 1, p ), 1, temp1, aapp )
429 sva( p ) = temp1*sqrt( aapp )
436 IF( aapp.GT.zero )
THEN
440 DO 2002 q = p + 1, min0( igl+kbl-1, n )
444 IF( aaqq.GT.zero )
THEN
447 IF( aaqq.GE.one )
THEN
448 rotok = ( small*aapp ).LE.aaqq
449 IF( aapp.LT.( big / aaqq ) )
THEN
450 aapq = (
cdotc( m, a( 1, p ), 1,
451 $ a( 1, q ), 1 ) / aaqq ) / aapp
453 CALL ccopy( m, a( 1, p ), 1,
455 CALL clascl(
'G', 0, 0, aapp, one,
456 $ m, 1, work, lda, ierr )
457 aapq =
cdotc( m, work, 1,
458 $ a( 1, q ), 1 ) / aaqq
461 rotok = aapp.LE.( aaqq / small )
462 IF( aapp.GT.( small / aaqq ) )
THEN
463 aapq = (
cdotc( m, a( 1, p ), 1,
464 $ a( 1, q ), 1 ) / aaqq ) / aapp
466 CALL ccopy( m, a( 1, q ), 1,
468 CALL clascl(
'G', 0, 0, aaqq,
471 aapq =
cdotc( m, a( 1, p ), 1,
476 ompq = aapq / abs(aapq)
479 mxaapq = amax1( mxaapq, -aapq1 )
483 IF( abs( aapq1 ).GT.tol )
THEN
498 theta = -half*abs( aqoap-apoaq )/aapq1
500 IF( abs( theta ).GT.bigtheta )
THEN
505 CALL crot( m, a(1,p), 1, a(1,q), 1,
506 $ cs, conjg(ompq)*t )
508 CALL crot( mvl, v(1,p), 1,
509 $ v(1,q), 1, cs, conjg(ompq)*t )
512 sva( q ) = aaqq*sqrt( amax1( zero,
513 $ one+t*apoaq*aapq1 ) )
514 aapp = aapp*sqrt( amax1( zero,
515 $ one-t*aqoap*aapq1 ) )
516 mxsinj = amax1( mxsinj, abs( t ) )
522 thsign = -sign( one, aapq1 )
523 t = one / ( theta+thsign*
524 $ sqrt( one+theta*theta ) )
525 cs = sqrt( one / ( one+t*t ) )
528 mxsinj = amax1( mxsinj, abs( sn ) )
529 sva( q ) = aaqq*sqrt( amax1( zero,
530 $ one+t*apoaq*aapq1 ) )
531 aapp = aapp*sqrt( amax1( zero,
532 $ one-t*aqoap*aapq1 ) )
534 CALL crot( m, a(1,p), 1, a(1,q), 1,
535 $ cs, conjg(ompq)*sn )
537 CALL crot( mvl, v(1,p), 1,
538 $ v(1,q), 1, cs, conjg(ompq)*sn )
545 CALL ccopy( m, a( 1, p ), 1,
547 CALL clascl(
'G', 0, 0, aapp, one, m,
550 CALL clascl(
'G', 0, 0, aaqq, one, m,
551 $ 1, a( 1, q ), lda, ierr )
552 CALL caxpy( m, -aapq, work, 1,
554 CALL clascl(
'G', 0, 0, one, aaqq, m,
555 $ 1, a( 1, q ), lda, ierr )
556 sva( q ) = aaqq*sqrt( amax1( zero,
557 $ one-aapq1*aapq1 ) )
558 mxsinj = amax1( mxsinj, sfmin )
565 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
567 IF( ( aaqq.LT.rootbig ) .AND.
568 $ ( aaqq.GT.rootsfmin ) )
THEN
569 sva( q ) =
scnrm2( m, a( 1, q ), 1 )
573 CALL classq( m, a( 1, q ), 1, t,
575 sva( q ) = t*sqrt( aaqq )
578 IF( ( aapp / aapp0 ).LE.rooteps )
THEN
579 IF( ( aapp.LT.rootbig ) .AND.
580 $ ( aapp.GT.rootsfmin ) )
THEN
581 aapp =
scnrm2( m, a( 1, p ), 1 )
585 CALL classq( m, a( 1, p ), 1, t,
587 aapp = t*sqrt( aapp )
594 IF( ir1.EQ.0 )notrot = notrot + 1
596 pskipped = pskipped + 1
600 IF( ir1.EQ.0 )notrot = notrot + 1
601 pskipped = pskipped + 1
604 IF( ( i.LE.swband ) .AND.
605 $ ( pskipped.GT.rowskip ) )
THEN
606 IF( ir1.EQ.0 )aapp = -aapp
621 IF( ( ir1.EQ.0 ) .AND. ( aapp.EQ.zero ) )
622 $ notrot = notrot + min0( igl+kbl-1, n ) - p
633 igl = ( ibr-1 )*kbl + 1
635 DO 2010 jbc = ibr + 1, nbl
637 jgl = ( jbc-1 )*kbl + 1
642 DO 2100 p = igl, min0( igl+kbl-1, n )
645 IF( aapp.GT.zero )
THEN
649 DO 2200 q = jgl, min0( jgl+kbl-1, n )
652 IF( aaqq.GT.zero )
THEN
659 IF( aaqq.GE.one )
THEN
660 IF( aapp.GE.aaqq )
THEN
661 rotok = ( small*aapp ).LE.aaqq
663 rotok = ( small*aaqq ).LE.aapp
665 IF( aapp.LT.( big / aaqq ) )
THEN
666 aapq = (
cdotc( m, a( 1, p ), 1,
667 $ a( 1, q ), 1 ) / aaqq ) / aapp
669 CALL ccopy( m, a( 1, p ), 1,
671 CALL clascl(
'G', 0, 0, aapp,
674 aapq =
cdotc( m, work, 1,
675 $ a( 1, q ), 1 ) / aaqq
678 IF( aapp.GE.aaqq )
THEN
679 rotok = aapp.LE.( aaqq / small )
681 rotok = aaqq.LE.( aapp / small )
683 IF( aapp.GT.( small / aaqq ) )
THEN
684 aapq = (
cdotc( m, a( 1, p ), 1,
685 $ a( 1, q ), 1 ) / aaqq ) / aapp
687 CALL ccopy( m, a( 1, q ), 1,
689 CALL clascl(
'G', 0, 0, aaqq,
692 aapq =
cdotc( m, a( 1, p ), 1,
697 ompq = aapq / abs(aapq)
700 mxaapq = amax1( mxaapq, -aapq1 )
704 IF( abs( aapq1 ).GT.tol )
THEN
714 theta = -half*abs( aqoap-apoaq )/ aapq1
715 IF( aaqq.GT.aapp0 )theta = -theta
717 IF( abs( theta ).GT.bigtheta )
THEN
720 CALL crot( m, a(1,p), 1, a(1,q), 1,
721 $ cs, conjg(ompq)*t )
723 CALL crot( mvl, v(1,p), 1,
724 $ v(1,q), 1, cs, conjg(ompq)*t )
726 sva( q ) = aaqq*sqrt( amax1( zero,
727 $ one+t*apoaq*aapq1 ) )
728 aapp = aapp*sqrt( amax1( zero,
729 $ one-t*aqoap*aapq1 ) )
730 mxsinj = amax1( mxsinj, abs( t ) )
735 thsign = -sign( one, aapq1 )
736 IF( aaqq.GT.aapp0 )thsign = -thsign
737 t = one / ( theta+thsign*
738 $ sqrt( one+theta*theta ) )
739 cs = sqrt( one / ( one+t*t ) )
741 mxsinj = amax1( mxsinj, abs( sn ) )
742 sva( q ) = aaqq*sqrt( amax1( zero,
743 $ one+t*apoaq*aapq1 ) )
744 aapp = aapp*sqrt( amax1( zero,
745 $ one-t*aqoap*aapq1 ) )
747 CALL crot( m, a(1,p), 1, a(1,q), 1,
748 $ cs, conjg(ompq)*sn )
750 CALL crot( mvl, v(1,p), 1,
751 $ v(1,q), 1, cs, conjg(ompq)*sn )
758 IF( aapp.GT.aaqq )
THEN
759 CALL ccopy( m, a( 1, p ), 1,
761 CALL clascl(
'G', 0, 0, aapp, one,
764 CALL clascl(
'G', 0, 0, aaqq, one,
765 $ m, 1, a( 1, q ), lda,
767 CALL caxpy( m, -aapq, work,
769 CALL clascl(
'G', 0, 0, one, aaqq,
770 $ m, 1, a( 1, q ), lda,
772 sva( q ) = aaqq*sqrt( amax1( zero,
773 $ one-aapq1*aapq1 ) )
774 mxsinj = amax1( mxsinj, sfmin )
776 CALL ccopy( m, a( 1, q ), 1,
778 CALL clascl(
'G', 0, 0, aaqq, one,
781 CALL clascl(
'G', 0, 0, aapp, one,
782 $ m, 1, a( 1, p ), lda,
784 CALL caxpy( m, -conjg(aapq),
785 $ work, 1, a( 1, p ), 1 )
786 CALL clascl(
'G', 0, 0, one, aapp,
787 $ m, 1, a( 1, p ), lda,
789 sva( p ) = aapp*sqrt( amax1( zero,
790 $ one-aapq1*aapq1 ) )
791 mxsinj = amax1( mxsinj, sfmin )
798 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
800 IF( ( aaqq.LT.rootbig ) .AND.
801 $ ( aaqq.GT.rootsfmin ) )
THEN
802 sva( q ) =
scnrm2( m, a( 1, q ), 1)
806 CALL classq( m, a( 1, q ), 1, t,
808 sva( q ) = t*sqrt( aaqq )
811 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
812 IF( ( aapp.LT.rootbig ) .AND.
813 $ ( aapp.GT.rootsfmin ) )
THEN
814 aapp =
scnrm2( m, a( 1, p ), 1 )
818 CALL classq( m, a( 1, p ), 1, t,
820 aapp = t*sqrt( aapp )
828 pskipped = pskipped + 1
833 pskipped = pskipped + 1
837 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
843 IF( ( i.LE.swband ) .AND.
844 $ ( pskipped.GT.rowskip ) )
THEN
858 IF( aapp.EQ.zero )notrot = notrot +
859 $ min0( jgl+kbl-1, n ) - jgl + 1
860 IF( aapp.LT.zero )notrot = 0
870 DO 2012 p = igl, min0( igl+kbl-1, n )
871 sva( p ) = abs( sva( p ) )
878 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
880 sva( n ) =
scnrm2( m, a( 1, n ), 1 )
884 CALL classq( m, a( 1, n ), 1, t, aapp )
885 sva( n ) = t*sqrt( aapp )
890 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
891 $ ( iswrot.LE.n ) ) )swband = i
893 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( float( n ) )*
894 $ tol ) .AND. ( float( n )*mxaapq*mxsinj.LT.tol ) )
THEN
898 IF( notrot.GE.emptsw )
GO TO 1994
917 q =
isamax( n-p+1, sva( p ), 1 ) + p - 1
925 CALL cswap( m, a( 1, p ), 1, a( 1, q ), 1 )
926 IF( rsvec )
CALL cswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
real function scnrm2(N, X, INCX)
SCNRM2
integer function isamax(N, SX, INCX)
ISAMAX
subroutine clascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine classq(N, X, INCX, SCALE, SUMSQ)
CLASSQ updates a sum of squares represented in scaled form.
subroutine xerbla(SRNAME, INFO)
XERBLA
complex function cdotc(N, CX, INCX, CY, INCY)
CDOTC
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine cswap(N, CX, INCX, CY, INCY)
CSWAP
subroutine caxpy(N, CA, CX, INCX, CY, INCY)
CAXPY
logical function lsame(CA, CB)
LSAME
subroutine csscal(N, SA, CX, INCX)
CSSCAL
subroutine crot(N, CX, INCX, CY, INCY, C, S)
CROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors...