232 SUBROUTINE cgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
233 $ EPS, SFMIN, TOL, NSWEEP, WORK, LWORK, INFO )
241 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
245 COMPLEX A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK )
253 parameter( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
257 REAL AAPP, AAPP0, AAPQ1, AAQQ, APOAQ, AQOAP, BIG,
258 $ bigtheta, cs, mxaapq, mxsinj, rootbig,
259 $ rooteps, rootsfmin, roottol, small, sn, t,
260 $ temp1, theta, thsign
261 INTEGER BLSKIP, EMPTSW, i, ibr, igl, IERR, IJBLSK,
262 $ iswrot, jbc, jgl, kbl, mvl, notrot, nblc, nblr,
263 $ p, pskipped, q, rowskip, swband
264 LOGICAL APPLV, ROTOK, RSVEC
268 INTRINSIC abs, max, conjg, real, min, sign, sqrt
275 EXTERNAL isamax, lsame, cdotc, scnrm2
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(
'CGSVJ1', -info )
322 ELSE IF( applv )
THEN
325 rsvec = rsvec .OR. applv
327 rooteps = sqrt( eps )
328 rootsfmin = sqrt( sfmin )
331 rootbig = one / rootsfmin
333 bigtheta = one / rooteps
334 roottol = sqrt( tol )
347 IF( ( nblr*kbl ).NE.n1 )nblr = nblr + 1
351 nblc = ( n-n1 ) / kbl
352 IF( ( nblc*kbl ).NE.( n-n1 ) )nblc = nblc + 1
353 blskip = ( kbl**2 ) + 1
356 rowskip = min( 5, kbl )
372 DO 1993 i = 1, nsweep
388 DO 2000 ibr = 1, nblr
390 igl = ( ibr-1 )*kbl + 1
396 igl = ( ibr-1 )*kbl + 1
399 DO 2010 jbc = 1, nblc
401 jgl = ( jbc-1 )*kbl + n1 + 1
406 DO 2100 p = igl, min( igl+kbl-1, n1 )
409 IF( aapp.GT.zero )
THEN
413 DO 2200 q = jgl, min( jgl+kbl-1, n )
416 IF( aaqq.GT.zero )
THEN
423 IF( aaqq.GE.one )
THEN
424 IF( aapp.GE.aaqq )
THEN
425 rotok = ( small*aapp ).LE.aaqq
427 rotok = ( small*aaqq ).LE.aapp
429 IF( aapp.LT.( big / aaqq ) )
THEN
430 aapq = ( cdotc( m, a( 1, p ), 1,
431 $ a( 1, q ), 1 ) / aaqq ) / aapp
433 CALL ccopy( m, a( 1, p ), 1,
435 CALL clascl(
'G', 0, 0, aapp,
438 aapq = cdotc( m, work, 1,
439 $ a( 1, q ), 1 ) / aaqq
442 IF( aapp.GE.aaqq )
THEN
443 rotok = aapp.LE.( aaqq / small )
445 rotok = aaqq.LE.( aapp / small )
447 IF( aapp.GT.( small / aaqq ) )
THEN
448 aapq = ( cdotc( m, a( 1, p ), 1,
449 $ a( 1, q ), 1 ) / max(aaqq,aapp) )
452 CALL ccopy( m, a( 1, q ), 1,
454 CALL clascl(
'G', 0, 0, aaqq,
457 aapq = cdotc( m, a( 1, p ), 1,
464 mxaapq = max( mxaapq, -aapq1 )
468 IF( abs( aapq1 ).GT.tol )
THEN
469 ompq = aapq / abs(aapq)
479 theta = -half*abs( aqoap-apoaq )/ aapq1
480 IF( aaqq.GT.aapp0 )theta = -theta
482 IF( abs( theta ).GT.bigtheta )
THEN
485 CALL crot( m, a(1,p), 1, a(1,q),
487 $ cs, conjg(ompq)*t )
489 CALL crot( mvl, v(1,p), 1,
490 $ v(1,q), 1, cs, conjg(ompq)*t )
492 sva( q ) = aaqq*sqrt( max( zero,
493 $ one+t*apoaq*aapq1 ) )
494 aapp = aapp*sqrt( max( zero,
495 $ one-t*aqoap*aapq1 ) )
496 mxsinj = max( mxsinj, abs( t ) )
501 thsign = -sign( one, aapq1 )
502 IF( aaqq.GT.aapp0 )thsign = -thsign
503 t = one / ( theta+thsign*
504 $ sqrt( one+theta*theta ) )
505 cs = sqrt( one / ( one+t*t ) )
507 mxsinj = max( mxsinj, abs( sn ) )
508 sva( q ) = aaqq*sqrt( max( zero,
509 $ one+t*apoaq*aapq1 ) )
510 aapp = aapp*sqrt( max( zero,
511 $ one-t*aqoap*aapq1 ) )
513 CALL crot( m, a(1,p), 1, a(1,q),
515 $ cs, conjg(ompq)*sn )
517 CALL crot( mvl, v(1,p), 1,
518 $ v(1,q), 1, cs, conjg(ompq)*sn )
525 IF( aapp.GT.aaqq )
THEN
526 CALL ccopy( m, a( 1, p ), 1,
528 CALL clascl(
'G', 0, 0, aapp,
532 CALL clascl(
'G', 0, 0, aaqq,
534 $ m, 1, a( 1, q ), lda,
536 CALL caxpy( m, -aapq, work,
538 CALL clascl(
'G', 0, 0, one,
540 $ m, 1, a( 1, q ), lda,
542 sva( q ) = aaqq*sqrt( max( zero,
543 $ one-aapq1*aapq1 ) )
544 mxsinj = max( mxsinj, sfmin )
546 CALL ccopy( m, a( 1, q ), 1,
548 CALL clascl(
'G', 0, 0, aaqq,
552 CALL clascl(
'G', 0, 0, aapp,
554 $ m, 1, a( 1, p ), lda,
556 CALL caxpy( m, -conjg(aapq),
557 $ work, 1, a( 1, p ), 1 )
558 CALL clascl(
'G', 0, 0, one,
560 $ m, 1, a( 1, p ), lda,
562 sva( p ) = aapp*sqrt( max( zero,
563 $ one-aapq1*aapq1 ) )
564 mxsinj = max( mxsinj, sfmin )
571 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
573 IF( ( aaqq.LT.rootbig ) .AND.
574 $ ( aaqq.GT.rootsfmin ) )
THEN
575 sva( q ) = scnrm2( m, a( 1, q ),
580 CALL classq( m, a( 1, q ), 1, t,
582 sva( q ) = t*sqrt( aaqq )
585 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
586 IF( ( aapp.LT.rootbig ) .AND.
587 $ ( aapp.GT.rootsfmin ) )
THEN
588 aapp = scnrm2( m, a( 1, p ), 1 )
592 CALL classq( m, a( 1, p ), 1, t,
594 aapp = t*sqrt( aapp )
602 pskipped = pskipped + 1
607 pskipped = pskipped + 1
611 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
617 IF( ( i.LE.swband ) .AND.
618 $ ( pskipped.GT.rowskip ) )
THEN
632 IF( aapp.EQ.zero )notrot = notrot +
633 $ min( jgl+kbl-1, n ) - jgl + 1
634 IF( aapp.LT.zero )notrot = 0
644 DO 2012 p = igl, min( igl+kbl-1, n )
645 sva( p ) = abs( sva( p ) )
652 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
654 sva( n ) = scnrm2( m, a( 1, n ), 1 )
658 CALL classq( m, a( 1, n ), 1, t, aapp )
659 sva( n ) = t*sqrt( aapp )
664 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
665 $ ( iswrot.LE.n ) ) )swband = i
667 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( real( n ) )*
668 $ tol ) .AND. ( real( n )*mxaapq*mxsinj.LT.tol ) )
THEN
672 IF( notrot.GE.emptsw )
GO TO 1994
691 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
699 CALL cswap( m, a( 1, p ), 1, a( 1, q ), 1 )
700 IF( rsvec )
CALL cswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )