236 SUBROUTINE cgsvj1( JOBV, M, N, N1, A, LDA, D, SVA, MV, V, LDV,
237 $ eps, sfmin, tol, nsweep, work, lwork, info )
246 INTEGER INFO, LDA, LDV, LWORK, M, MV, N, N1, NSWEEP
250 COMPLEX A( lda, * ), D( n ), V( ldv, * ), WORK( lwork )
258 parameter ( zero = 0.0e0, half = 0.5e0, one = 1.0e0)
262 REAL AAPP, AAPP0, AAPQ1, AAQQ, APOAQ, AQOAP, BIG,
263 $ bigtheta, cs, large, mxaapq, mxsinj, rootbig,
264 $ rooteps, rootsfmin, roottol, small, sn, t,
265 $ temp1, theta, thsign
266 INTEGER BLSKIP, EMPTSW, i, ibr, igl, IERR, IJBLSK,
267 $ iswrot, jbc, jgl, kbl, mvl, notrot, nblc, nblr,
268 $ p, pskipped, q, rowskip, swband
269 LOGICAL APPLV, ROTOK, RSVEC
273 INTRINSIC abs, amax1, conjg, float, min0, sign, sqrt
280 EXTERNAL isamax, lsame, cdotc, scnrm2
292 applv = lsame( jobv,
'A' )
293 rsvec = lsame( jobv,
'V' )
294 IF( .NOT.( rsvec .OR. applv .OR. lsame( jobv,
'N' ) ) )
THEN
296 ELSE IF( m.LT.0 )
THEN
298 ELSE IF( ( n.LT.0 ) .OR. ( n.GT.m ) )
THEN
300 ELSE IF( n1.LT.0 )
THEN
302 ELSE IF( lda.LT.m )
THEN
304 ELSE IF( ( rsvec.OR.applv ) .AND. ( mv.LT.0 ) )
THEN
306 ELSE IF( ( rsvec.AND.( ldv.LT.n ) ).OR.
307 $ ( applv.AND.( ldv.LT.mv ) ) )
THEN
309 ELSE IF( tol.LE.eps )
THEN
311 ELSE IF( nsweep.LT.0 )
THEN
313 ELSE IF( lwork.LT.m )
THEN
321 CALL xerbla(
'CGSVJ1', -info )
327 ELSE IF( applv )
THEN
330 rsvec = rsvec .OR. applv
332 rooteps = sqrt( eps )
333 rootsfmin = sqrt( sfmin )
336 rootbig = one / rootsfmin
337 large = big / sqrt( float( m*n ) )
338 bigtheta = one / rooteps
339 roottol = sqrt( tol )
352 IF( ( nblr*kbl ).NE.n1 )nblr = nblr + 1
356 nblc = ( n-n1 ) / kbl
357 IF( ( nblc*kbl ).NE.( n-n1 ) )nblc = nblc + 1
358 blskip = ( kbl**2 ) + 1
361 rowskip = min0( 5, kbl )
377 DO 1993 i = 1, nsweep
393 DO 2000 ibr = 1, nblr
395 igl = ( ibr-1 )*kbl + 1
401 igl = ( ibr-1 )*kbl + 1
404 DO 2010 jbc = 1, nblc
406 jgl = ( jbc-1 )*kbl + n1 + 1
411 DO 2100 p = igl, min0( igl+kbl-1, n1 )
414 IF( aapp.GT.zero )
THEN
418 DO 2200 q = jgl, min0( jgl+kbl-1, n )
421 IF( aaqq.GT.zero )
THEN
428 IF( aaqq.GE.one )
THEN
429 IF( aapp.GE.aaqq )
THEN
430 rotok = ( small*aapp ).LE.aaqq
432 rotok = ( small*aaqq ).LE.aapp
434 IF( aapp.LT.( big / aaqq ) )
THEN
435 aapq = ( cdotc( m, a( 1, p ), 1,
436 $ a( 1, q ), 1 ) / aaqq ) / aapp
438 CALL ccopy( m, a( 1, p ), 1,
440 CALL clascl(
'G', 0, 0, aapp,
443 aapq = cdotc( m, work, 1,
444 $ a( 1, q ), 1 ) / aaqq
447 IF( aapp.GE.aaqq )
THEN
448 rotok = aapp.LE.( aaqq / small )
450 rotok = aaqq.LE.( aapp / small )
452 IF( aapp.GT.( small / aaqq ) )
THEN
453 aapq = ( cdotc( m, a( 1, p ), 1,
454 $ a( 1, q ), 1 ) / aaqq ) / aapp
456 CALL ccopy( m, a( 1, q ), 1,
458 CALL clascl(
'G', 0, 0, aaqq,
461 aapq = cdotc( m, a( 1, p ), 1,
466 ompq = aapq / abs(aapq)
469 mxaapq = amax1( mxaapq, -aapq1 )
473 IF( abs( aapq1 ).GT.tol )
THEN
483 theta = -half*abs( aqoap-apoaq )/ aapq1
484 IF( aaqq.GT.aapp0 )theta = -theta
486 IF( abs( theta ).GT.bigtheta )
THEN
489 CALL crot( m, a(1,p), 1, a(1,q), 1,
490 $ cs, conjg(ompq)*t )
492 CALL crot( mvl, v(1,p), 1,
493 $ v(1,q), 1, cs, conjg(ompq)*t )
495 sva( q ) = aaqq*sqrt( amax1( zero,
496 $ one+t*apoaq*aapq1 ) )
497 aapp = aapp*sqrt( amax1( zero,
498 $ one-t*aqoap*aapq1 ) )
499 mxsinj = amax1( mxsinj, abs( t ) )
504 thsign = -sign( one, aapq1 )
505 IF( aaqq.GT.aapp0 )thsign = -thsign
506 t = one / ( theta+thsign*
507 $ sqrt( one+theta*theta ) )
508 cs = sqrt( one / ( one+t*t ) )
510 mxsinj = amax1( mxsinj, abs( sn ) )
511 sva( q ) = aaqq*sqrt( amax1( zero,
512 $ one+t*apoaq*aapq1 ) )
513 aapp = aapp*sqrt( amax1( zero,
514 $ one-t*aqoap*aapq1 ) )
516 CALL crot( m, a(1,p), 1, a(1,q), 1,
517 $ cs, conjg(ompq)*sn )
519 CALL crot( mvl, v(1,p), 1,
520 $ v(1,q), 1, cs, conjg(ompq)*sn )
527 IF( aapp.GT.aaqq )
THEN
528 CALL ccopy( m, a( 1, p ), 1,
530 CALL clascl(
'G', 0, 0, aapp, one,
533 CALL clascl(
'G', 0, 0, aaqq, one,
534 $ m, 1, a( 1, q ), lda,
536 CALL caxpy( m, -aapq, work,
538 CALL clascl(
'G', 0, 0, one, aaqq,
539 $ m, 1, a( 1, q ), lda,
541 sva( q ) = aaqq*sqrt( amax1( zero,
542 $ one-aapq1*aapq1 ) )
543 mxsinj = amax1( mxsinj, sfmin )
545 CALL ccopy( m, a( 1, q ), 1,
547 CALL clascl(
'G', 0, 0, aaqq, one,
550 CALL clascl(
'G', 0, 0, aapp, one,
551 $ m, 1, a( 1, p ), lda,
553 CALL caxpy( m, -conjg(aapq),
554 $ work, 1, a( 1, p ), 1 )
555 CALL clascl(
'G', 0, 0, one, aapp,
556 $ m, 1, a( 1, p ), lda,
558 sva( p ) = aapp*sqrt( amax1( zero,
559 $ one-aapq1*aapq1 ) )
560 mxsinj = amax1( mxsinj, sfmin )
567 IF( ( sva( q ) / aaqq )**2.LE.rooteps )
569 IF( ( aaqq.LT.rootbig ) .AND.
570 $ ( aaqq.GT.rootsfmin ) )
THEN
571 sva( q ) = scnrm2( m, a( 1, q ), 1)
575 CALL classq( m, a( 1, q ), 1, t,
577 sva( q ) = t*sqrt( aaqq )
580 IF( ( aapp / aapp0 )**2.LE.rooteps )
THEN
581 IF( ( aapp.LT.rootbig ) .AND.
582 $ ( aapp.GT.rootsfmin ) )
THEN
583 aapp = scnrm2( m, a( 1, p ), 1 )
587 CALL classq( m, a( 1, p ), 1, t,
589 aapp = t*sqrt( aapp )
597 pskipped = pskipped + 1
602 pskipped = pskipped + 1
606 IF( ( i.LE.swband ) .AND. ( ijblsk.GE.blskip ) )
612 IF( ( i.LE.swband ) .AND.
613 $ ( pskipped.GT.rowskip ) )
THEN
627 IF( aapp.EQ.zero )notrot = notrot +
628 $ min0( jgl+kbl-1, n ) - jgl + 1
629 IF( aapp.LT.zero )notrot = 0
639 DO 2012 p = igl, min0( igl+kbl-1, n )
640 sva( p ) = abs( sva( p ) )
647 IF( ( sva( n ).LT.rootbig ) .AND. ( sva( n ).GT.rootsfmin ) )
649 sva( n ) = scnrm2( m, a( 1, n ), 1 )
653 CALL classq( m, a( 1, n ), 1, t, aapp )
654 sva( n ) = t*sqrt( aapp )
659 IF( ( i.LT.swband ) .AND. ( ( mxaapq.LE.roottol ) .OR.
660 $ ( iswrot.LE.n ) ) )swband = i
662 IF( ( i.GT.swband+1 ) .AND. ( mxaapq.LT.sqrt( float( n ) )*
663 $ tol ) .AND. ( float( n )*mxaapq*mxsinj.LT.tol ) )
THEN
667 IF( notrot.GE.emptsw )
GO TO 1994
686 q = isamax( n-p+1, sva( p ), 1 ) + p - 1
694 CALL cswap( m, a( 1, p ), 1, a( 1, q ), 1 )
695 IF( rsvec )
CALL cswap( mvl, v( 1, p ), 1, v( 1, q ), 1 )
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
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine cswap(N, CX, INCX, CY, INCY)
CSWAP
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 caxpy(N, CA, CX, INCX, CY, INCY)
CAXPY
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...