375 SUBROUTINE stgsja( 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,
390 REAL A( LDA, * ), ALPHA( * ), B( LDB, * ),
391 $ BETA( * ), Q( LDQ, * ), U( LDU, * ),
392 $ v( ldv, * ), work( * )
399 PARAMETER ( MAXIT = 40 )
400 REAL ZERO, ONE, HUGENUM
401 parameter( zero = 0.0e+0, one = 1.0e+0 )
405 LOGICAL INITQ, INITU, INITV, UPPER, WANTQ, WANTU, WANTV
407 REAL 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(
'STGSJA', -info )
467 $
CALL slaset(
'Full', m, m, zero, one, u, ldu )
469 $
CALL slaset(
'Full', p, p, zero, one, v, ldv )
471 $
CALL slaset(
'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 slags2( upper, a1, a2, a3, b1, b2, b3, csu, snu,
505 $ csv, snv, csq, snq )
510 $
CALL srot( l, a( k+j, n-l+1 ), lda, a( k+i, n-l+1 ),
515 CALL srot( l, b( j, n-l+1 ), ldb, b( i, n-l+1 ), ldb,
521 CALL srot( min( k+l, m ), a( 1, n-l+j ), 1,
522 $ a( 1, n-l+i ), 1, csq, snq )
524 CALL srot( 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 srot( m, u( 1, k+j ), 1, u( 1, k+i ), 1, csu,
544 $
CALL srot( p, v( 1, j ), 1, v( 1, i ), 1, csv, snv )
547 $
CALL srot( 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 scopy( l-i+1, a( k+i, n-l+i ), lda, work, 1 )
564 CALL scopy( l-i+1, b( i, n-l+i ), ldb, work( l+1 ), 1 )
565 CALL slapll( 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 sscal( l-i+1, -one, b( i, n-l+i ), ldb )
606 $
CALL sscal( p, -one, v( 1, i ), 1 )
609 CALL slartg( abs( gamma ), one, beta( k+i ), alpha( k+i ),
612 IF( alpha( k+i ).GE.beta( k+i ) )
THEN
613 CALL sscal( l-i+1, one / alpha( k+i ), a( k+i, n-l+i ),
616 CALL sscal( l-i+1, one / beta( k+i ), b( i, n-l+i ),
618 CALL scopy( l-i+1, b( i, n-l+i ), ldb, a( k+i, n-l+i ),
626 CALL scopy( 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 scopy(n, sx, incx, sy, incy)
SCOPY
subroutine slags2(upper, a1, a2, a3, b1, b2, b3, csu, snu, csv, snv, csq, snq)
SLAGS2 computes 2-by-2 orthogonal matrices U, V, and Q, and applies them to matrices A and B such tha...
subroutine slapll(n, x, incx, y, incy, ssmin)
SLAPLL measures the linear dependence of two vectors.
subroutine slartg(f, g, c, s, r)
SLARTG generates a plane rotation with real cosine and real sine.
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine srot(n, sx, incx, sy, incy, c, s)
SROT
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine stgsja(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)
STGSJA