376 SUBROUTINE ztgsja( JOBU, JOBV, JOBQ, M, P, N, K, L, A, LDA, B,
377 $ LDB, TOLA, TOLB, ALPHA, BETA, U, LDU, V, LDV,
378 $ Q, LDQ, WORK, NCYCLE, INFO )
385 CHARACTER JOBQ, JOBU, JOBV
386 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N,
388 DOUBLE PRECISION TOLA, TOLB
391 DOUBLE PRECISION ALPHA( * ), BETA( * )
392 COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
393 $ u( ldu, * ), v( ldv, * ), work( * )
400 PARAMETER ( MAXIT = 40 )
401 DOUBLE PRECISION ZERO, ONE, HUGENUM
402 parameter( zero = 0.0d+0, one = 1.0d+0 )
403 COMPLEX*16 CZERO, CONE
404 parameter( czero = ( 0.0d+0, 0.0d+0 ),
405 $ cone = ( 1.0d+0, 0.0d+0 ) )
409 LOGICAL INITQ, INITU, INITV, UPPER, WANTQ, WANTU, WANTV
411 DOUBLE PRECISION A1, A3, B1, B3, CSQ, CSU, CSV, ERROR, GAMMA,
413 COMPLEX*16 A2, B2, SNQ, SNU, SNV
424 INTRINSIC abs, dble, dconjg, max, min, huge
425 parameter( hugenum = huge(zero) )
431 initu = lsame( jobu,
'I' )
432 wantu = initu .OR. lsame( jobu,
'U' )
434 initv = lsame( jobv,
'I' )
435 wantv = initv .OR. lsame( jobv,
'V' )
437 initq = lsame( jobq,
'I' )
438 wantq = initq .OR. lsame( jobq,
'Q' )
441 IF( .NOT.( initu .OR. wantu .OR. lsame( jobu,
'N' ) ) )
THEN
443 ELSE IF( .NOT.( initv .OR. wantv .OR. lsame( jobv,
'N' ) ) )
THEN
445 ELSE IF( .NOT.( initq .OR. wantq .OR. lsame( jobq,
'N' ) ) )
THEN
447 ELSE IF( m.LT.0 )
THEN
449 ELSE IF( p.LT.0 )
THEN
451 ELSE IF( n.LT.0 )
THEN
453 ELSE IF( lda.LT.max( 1, m ) )
THEN
455 ELSE IF( ldb.LT.max( 1, p ) )
THEN
457 ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) )
THEN
459 ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) )
THEN
461 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) )
THEN
465 CALL xerbla(
'ZTGSJA', -info )
472 $
CALL zlaset(
'Full', m, m, czero, cone, u, ldu )
474 $
CALL zlaset(
'Full', p, p, czero, cone, v, ldv )
476 $
CALL zlaset(
'Full', n, n, czero, cone, q, ldq )
481 DO 40 kcycle = 1, maxit
492 $ a1 = dble( a( k+i, n-l+i ) )
494 $ a3 = dble( a( k+j, n-l+j ) )
496 b1 = dble( b( i, n-l+i ) )
497 b3 = dble( b( j, n-l+j ) )
501 $ a2 = a( k+i, n-l+j )
505 $ a2 = a( k+j, n-l+i )
509 CALL zlags2( upper, a1, a2, a3, b1, b2, b3, csu, snu,
510 $ csv, snv, csq, snq )
515 $
CALL zrot( l, a( k+j, n-l+1 ), lda, a( k+i, n-l+1 ),
516 $ lda, csu, dconjg( snu ) )
520 CALL zrot( l, b( j, n-l+1 ), ldb, b( i, n-l+1 ), ldb,
521 $ csv, dconjg( snv ) )
526 CALL zrot( min( k+l, m ), a( 1, n-l+j ), 1,
527 $ a( 1, n-l+i ), 1, csq, snq )
529 CALL zrot( l, b( 1, n-l+j ), 1, b( 1, n-l+i ), 1, csq,
534 $ a( k+i, n-l+j ) = czero
535 b( i, n-l+j ) = czero
538 $ a( k+j, n-l+i ) = czero
539 b( j, n-l+i ) = czero
545 $ a( k+i, n-l+i ) = dble( a( k+i, n-l+i ) )
547 $ a( k+j, n-l+j ) = dble( a( k+j, n-l+j ) )
548 b( i, n-l+i ) = dble( b( i, n-l+i ) )
549 b( j, n-l+j ) = dble( b( j, n-l+j ) )
553 IF( wantu .AND. k+j.LE.m )
554 $
CALL zrot( m, u( 1, k+j ), 1, u( 1, k+i ), 1, csu,
558 $
CALL zrot( p, v( 1, j ), 1, v( 1, i ), 1, csv, snv )
561 $
CALL zrot( n, q( 1, n-l+j ), 1, q( 1, n-l+i ), 1, csq,
567 IF( .NOT.upper )
THEN
576 DO 30 i = 1, min( l, m-k )
577 CALL zcopy( l-i+1, a( k+i, n-l+i ), lda, work, 1 )
578 CALL zcopy( l-i+1, b( i, n-l+i ), ldb, work( l+1 ), 1 )
579 CALL zlapll( l-i+1, work, 1, work( l+1 ), 1, ssmin )
580 error = max( error, ssmin )
583 IF( abs( error ).LE.min( tola, tolb ) )
607 DO 70 i = 1, min( l, m-k )
609 a1 = dble( a( k+i, n-l+i ) )
610 b1 = dble( b( i, n-l+i ) )
613 IF( (gamma.LE.hugenum).AND.(gamma.GE.-hugenum) )
THEN
615 IF( gamma.LT.zero )
THEN
616 CALL zdscal( l-i+1, -one, b( i, n-l+i ), ldb )
618 $
CALL zdscal( p, -one, v( 1, i ), 1 )
621 CALL dlartg( abs( gamma ), one, beta( k+i ), alpha( k+i ),
624 IF( alpha( k+i ).GE.beta( k+i ) )
THEN
625 CALL zdscal( l-i+1, one / alpha( k+i ), a( k+i, n-l+i ),
628 CALL zdscal( l-i+1, one / beta( k+i ), b( i, n-l+i ),
630 CALL zcopy( l-i+1, b( i, n-l+i ), ldb, a( k+i, n-l+i ),
638 CALL zcopy( l-i+1, b( i, n-l+i ), ldb, a( k+i, n-l+i ),
645 DO 80 i = m + 1, k + l
651 DO 90 i = k + l + 1, n
subroutine xerbla(srname, info)
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine zlags2(upper, a1, a2, a3, b1, b2, b3, csu, snu, csv, snv, csq, snq)
ZLAGS2
subroutine zlapll(n, x, incx, y, incy, ssmin)
ZLAPLL measures the linear dependence of two vectors.
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
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 zdscal(n, da, zx, incx)
ZDSCAL
subroutine ztgsja(jobu, jobv, jobq, m, p, n, k, l, a, lda, b, ldb, tola, tolb, alpha, beta, u, ldu, v, ldv, q, ldq, work, ncycle, info)
ZTGSJA