234 SUBROUTINE cgsvj1( 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 COMPLEX A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK )
255 parameter( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
259 REAL AAPP, AAPP0, AAPQ1, AAQQ, APOAQ, AQOAP, BIG,
260 $ bigtheta, cs, mxaapq, mxsinj, rootbig,
261 $ rooteps, rootsfmin, roottol, small, sn, t,
262 $ temp1, theta, thsign
263 INTEGER BLSKIP, EMPTSW, i, ibr, igl, IERR, IJBLSK,
264 $ iswrot, jbc, jgl, kbl, mvl, notrot, nblc, nblr,
265 $ p, pskipped, q, rowskip, swband
266 LOGICAL APPLV, ROTOK, RSVEC
270 INTRINSIC abs, max, conjg, real, min, sign, sqrt
277 EXTERNAL isamax, lsame, cdotc, scnrm2
289 applv = lsame( jobv,
'A' )
290 rsvec = lsame( jobv,
'V' )
291 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
293 ELSE IF( m.LT.0 )
THEN
295 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
297 ELSE IF( n1.LT.0 )
THEN
299 ELSE IF( lda.LT.m )
THEN
301 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
303 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
304 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
306 ELSE IF( tol.LE.eps )
THEN
308 ELSE IF( nsweep.LT.0 )
THEN
310 ELSE IF( lwork.LT.m )
THEN
318 CALL xerbla(
'CGSVJ1', -info )
324 ELSE IF( applv )
THEN
327 rsvec = rsvec .OR. applv
329 rooteps = sqrt( eps )
330 rootsfmin = sqrt( sfmin )
333 rootbig = one / rootsfmin
335 bigtheta = one / rooteps
336 roottol = sqrt( tol )
349 IF( ( nblr*kbl ).NE.n1 )nblr = nblr + 1
353 nblc = ( n-n1 ) / kbl
354 IF( ( nblc*kbl ).NE.( n-n1 ) )nblc = nblc + 1
355 blskip = ( kbl**2 ) + 1
358 rowskip = min( 5, kbl )
374 DO 1993 i = 1, nsweep
390 DO 2000 ibr = 1, nblr
392 igl = ( ibr-1 )*kbl + 1
398 igl = ( ibr-1 )*kbl + 1
401 DO 2010 jbc = 1, nblc
403 jgl = ( jbc-1 )*kbl + n1 + 1
408 DO 2100 p = igl, min( igl+kbl-1, n1 )
411 IF( aapp.GT.zero )
THEN
415 DO 2200 q = jgl, min( jgl+kbl-1, n )
418 IF( aaqq.GT.zero )
THEN
425 IF( aaqq.GE.one )
THEN
426 IF( aapp.GE.aaqq )
THEN
427 rotok = ( small*aapp ).LE.aaqq
429 rotok = ( small*aaqq ).LE.aapp
431 IF( aapp.LT.( big / aaqq ) )
THEN
432 aapq = ( cdotc( m, a( 1, p ), 1,
433 $ a( 1, q ), 1 ) / aaqq ) / aapp
435 CALL ccopy( m, a( 1, p ), 1,
437 CALL clascl(
'G', 0, 0, aapp,
440 aapq = cdotc( m, work, 1,
441 $ a( 1, q ), 1 ) / aaqq
444 IF( aapp.GE.aaqq )
THEN
445 rotok = aapp.LE.( aaqq / small )
447 rotok = aaqq.LE.( aapp / small )
449 IF( aapp.GT.( small / aaqq ) )
THEN
450 aapq = ( cdotc( m, a( 1, p ), 1,
451 $ a( 1, q ), 1 ) / max(aaqq,aapp) )
454 CALL ccopy( m, a( 1, q ), 1,
456 CALL clascl(
'G', 0, 0, aaqq,
459 aapq = cdotc( m, a( 1, p ), 1,
466 mxaapq = max( mxaapq, -aapq1 )
470 IF( abs( aapq1 ).GT.tol )
THEN
471 ompq = aapq / abs(aapq)
481 theta = -half*abs( aqoap-apoaq )/ aapq1
482 IF( aaqq.GT.aapp0 )theta = -theta
484 IF( abs( theta ).GT.bigtheta )
THEN
487 CALL crot( m, a(1,p), 1, a(1,q), 1,
488 $ cs, conjg(ompq)*t )
490 CALL crot( 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 crot( m, a(1,p), 1, a(1,q), 1,
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, one,
531 CALL clascl(
'G', 0, 0, aaqq, one,
532 $ m, 1, a( 1, q ), lda,
534 CALL caxpy( m, -aapq, work,
536 CALL clascl(
'G', 0, 0, one, aaqq,
537 $ m, 1, a( 1, q ), lda,
539 sva( q ) = aaqq*sqrt( max( zero,
540 $ one-aapq1*aapq1 ) )
541 mxsinj = max( mxsinj, sfmin )
543 CALL ccopy( m, a( 1, q ), 1,
545 CALL clascl(
'G', 0, 0, aaqq, one,
548 CALL clascl(
'G', 0, 0, aapp, one,
549 $ m, 1, a( 1, p ), lda,
551 CALL caxpy( m, -conjg(aapq),
552 $ work, 1, a( 1, p ), 1 )
553 CALL clascl(
'G', 0, 0, one, aapp,
554 $ m, 1, a( 1, p ), lda,
556 sva( p ) = aapp*sqrt( max( zero,
557 $ one-aapq1*aapq1 ) )
558 mxsinj = max( 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 )**2.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 )
595 pskipped = pskipped + 1
600 pskipped = pskipped + 1
604 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
610 IF( ( i.LE.swband ) .AND.
611 $ ( pskipped.GT.rowskip ) )
THEN
625 IF( aapp.EQ.zero )notrot = notrot +
626 $ min( jgl+kbl-1, n ) - jgl + 1
627 IF( aapp.LT.zero )notrot = 0
637 DO 2012 p = igl, min( igl+kbl-1, n )
638 sva( p ) = abs( sva( p ) )
645 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
647 sva( n ) = scnrm2( m, a( 1, n ), 1 )
651 CALL classq( m, a( 1, n ), 1, t, aapp )
652 sva( n ) = t*sqrt( aapp )
657 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
658 $ ( iswrot.LE.n ) ) )swband = i
660 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( real( n ) )*
661 $ tol ) .AND. ( real( n )*mxaapq*mxsinj.LT.tol ) )
THEN
665 IF( notrot.GE.emptsw )
GO TO 1994
684 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
692 CALL cswap( m, a( 1, p ), 1, a( 1, q ), 1 )
693 IF( rsvec )
CALL cswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
subroutine xerbla(srname, info)
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine cgsvj1(jobv, m, n, n1, a, lda, d, sva, mv, v, ldv, eps, sfmin, tol, nsweep, work, lwork, info)
CGSVJ1 pre-processor for the routine cgesvj, applies Jacobi rotations targeting only particular pivot...
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 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.
subroutine cswap(n, cx, incx, cy, incy)
CSWAP