375 SUBROUTINE dtgsja( JOBU, JOBV, JOBQ, M, P, N, K, L, A, LDA, B,
376 $ LDB, TOLA, TOLB, ALPHA, BETA, U, LDU, V, LDV,
377 $ Q, LDQ, WORK, NCYCLE, INFO )
384 CHARACTER JOBQ, JOBU, JOBV
385 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N,
387 DOUBLE PRECISION TOLA, TOLB
390 DOUBLE PRECISION A( LDA, * ), ALPHA( * ), B( LDB, * ),
391 $ BETA( * ), Q( LDQ, * ), U( LDU, * ),
392 $ v( ldv, * ), work( * )
399 PARAMETER ( MAXIT = 40 )
400 DOUBLE PRECISION ZERO, ONE, HUGENUM
401 parameter( zero = 0.0d+0, one = 1.0d+0 )
405 LOGICAL INITQ, INITU, INITV, UPPER, WANTQ, WANTU, WANTV
407 DOUBLE PRECISION A1, A2, A3, B1, B2, B3, CSQ, CSU, CSV, ERROR,
408 $ gamma, rwk, snq, snu, snv, ssmin
419 INTRINSIC abs, max, min, huge
420 parameter( hugenum = huge(zero) )
426 initu = lsame( jobu,
'I' )
427 wantu = initu .OR. lsame( jobu,
'U' )
429 initv = lsame( jobv,
'I' )
430 wantv = initv .OR. lsame( jobv,
'V' )
432 initq = lsame( jobq,
'I' )
433 wantq = initq .OR. lsame( jobq,
'Q' )
436 IF( .NOT.( initu .OR. wantu .OR. lsame( jobu,
'N' ) ) )
THEN
438 ELSE IF( .NOT.( initv .OR. wantv .OR. lsame( jobv,
'N' ) ) )
THEN
440 ELSE IF( .NOT.( initq .OR. wantq .OR. lsame( jobq,
'N' ) ) )
THEN
442 ELSE IF( m.LT.0 )
THEN
444 ELSE IF( p.LT.0 )
THEN
446 ELSE IF( n.LT.0 )
THEN
448 ELSE IF( lda.LT.max( 1, m ) )
THEN
450 ELSE IF( ldb.LT.max( 1, p ) )
THEN
452 ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) )
THEN
454 ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) )
THEN
456 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) )
THEN
460 CALL xerbla(
'DTGSJA', -info )
467 $
CALL dlaset(
'Full', m, m, zero, one, u, ldu )
469 $
CALL dlaset(
'Full', p, p, zero, one, v, ldv )
471 $
CALL dlaset(
'Full', n, n, zero, one, q, ldq )
476 DO 40 kcycle = 1, maxit
487 $ a1 = a( k+i, n-l+i )
489 $ a3 = a( k+j, n-l+j )
496 $ a2 = a( k+i, n-l+j )
500 $ a2 = a( k+j, n-l+i )
504 CALL dlags2( upper, a1, a2, a3, b1, b2, b3, csu, snu,
505 $ csv, snv, csq, snq )
510 $
CALL drot( l, a( k+j, n-l+1 ), lda, a( k+i, n-l+1 ),
515 CALL drot( l, b( j, n-l+1 ), ldb, b( i, n-l+1 ), ldb,
521 CALL drot( min( k+l, m ), a( 1, n-l+j ), 1,
522 $ a( 1, n-l+i ), 1, csq, snq )
524 CALL drot( l, b( 1, n-l+j ), 1, b( 1, n-l+i ), 1, csq,
529 $ a( k+i, n-l+j ) = zero
533 $ a( k+j, n-l+i ) = zero
539 IF( wantu .AND. k+j.LE.m )
540 $
CALL drot( m, u( 1, k+j ), 1, u( 1, k+i ), 1, csu,
544 $
CALL drot( p, v( 1, j ), 1, v( 1, i ), 1, csv, snv )
547 $
CALL drot( n, q( 1, n-l+j ), 1, q( 1, n-l+i ), 1, csq,
553 IF( .NOT.upper )
THEN
562 DO 30 i = 1, min( l, m-k )
563 CALL dcopy( l-i+1, a( k+i, n-l+i ), lda, work, 1 )
564 CALL dcopy( l-i+1, b( i, n-l+i ), ldb, work( l+1 ), 1 )
565 CALL dlapll( l-i+1, work, 1, work( l+1 ), 1, ssmin )
566 error = max( error, ssmin )
569 IF( abs( error ).LE.min( tola, tolb ) )
593 DO 70 i = 1, min( l, m-k )
599 IF( (gamma.LE.hugenum).AND.(gamma.GE.-hugenum) )
THEN
603 IF( gamma.LT.zero )
THEN
604 CALL dscal( l-i+1, -one, b( i, n-l+i ), ldb )
606 $
CALL dscal( p, -one, v( 1, i ), 1 )
609 CALL dlartg( abs( gamma ), one, beta( k+i ), alpha( k+i ),
612 IF( alpha( k+i ).GE.beta( k+i ) )
THEN
613 CALL dscal( l-i+1, one / alpha( k+i ), a( k+i, n-l+i ),
616 CALL dscal( l-i+1, one / beta( k+i ), b( i, n-l+i ),
618 CALL dcopy( l-i+1, b( i, n-l+i ), ldb, a( k+i, n-l+i ),
626 CALL dcopy( l-i+1, b( i, n-l+i ), ldb, a( k+i, n-l+i ),
635 DO 80 i = m + 1, k + l
641 DO 90 i = k + l + 1, n
subroutine xerbla(srname, info)
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dlags2(upper, a1, a2, a3, b1, b2, b3, csu, snu, csv, snv, csq, snq)
DLAGS2 computes 2-by-2 orthogonal matrices U, V, and Q, and applies them to matrices A and B such tha...
subroutine dlapll(n, x, incx, y, incy, ssmin)
DLAPLL 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 dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine drot(n, dx, incx, dy, incy, c, s)
DROT
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dtgsja(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)
DTGSJA