251 SUBROUTINE sggsvp( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
252 $ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
253 $ IWORK, TAU, WORK, INFO )
260 CHARACTER JOBQ, JOBU, JOBV
261 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
266 REAL A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
267 $ tau( * ), u( ldu, * ), v( ldv, * ), work( * )
274 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
277 LOGICAL FORWRD, WANTQ, WANTU, WANTV
289 INTRINSIC abs, max, min
295 wantu = lsame( jobu,
'U' )
296 wantv = lsame( jobv,
'V' )
297 wantq = lsame( jobq,
'Q' )
301 IF( .NOT.( wantu .OR. lsame( jobu,
'N' ) ) )
THEN
303 ELSE IF( .NOT.( wantv .OR. lsame( jobv,
'N' ) ) )
THEN
305 ELSE IF( .NOT.( wantq .OR. lsame( jobq,
'N' ) ) )
THEN
307 ELSE IF( m.LT.0 )
THEN
309 ELSE IF( p.LT.0 )
THEN
311 ELSE IF( n.LT.0 )
THEN
313 ELSE IF( lda.LT.max( 1, m ) )
THEN
315 ELSE IF( ldb.LT.max( 1, p ) )
THEN
317 ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) )
THEN
319 ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) )
THEN
321 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) )
THEN
325 CALL xerbla(
'SGGSVP', -info )
335 CALL sgeqpf( p, n, b, ldb, iwork, tau, work, info )
339 CALL slapmt( forwrd, m, n, a, lda, iwork )
344 DO 20 i = 1, min( p, n )
345 IF( abs( b( i, i ) ).GT.tolb )
353 CALL slaset(
'Full', p, p, zero, zero, v, ldv )
355 $
CALL slacpy(
'Lower', p-1, n, b( 2, 1 ), ldb, v( 2, 1 ),
357 CALL sorg2r( p, p, min( p, n ), v, ldv, tau, work, info )
368 $
CALL slaset(
'Full', p-l, n, zero, zero, b( l+1, 1 ), ldb )
374 CALL slaset(
'Full', n, n, zero, one, q, ldq )
375 CALL slapmt( forwrd, n, n, q, ldq, iwork )
378 IF( p.GE.l .AND. n.NE.l )
THEN
382 CALL sgerq2( l, n, b, ldb, tau, work, info )
386 CALL sormr2(
'Right',
'Transpose', m, n, l, b, ldb, tau, a,
393 CALL sormr2(
'Right',
'Transpose', n, n, l, b, ldb, tau,
394 $ q, ldq, work, info )
399 CALL slaset(
'Full', l, n-l, zero, zero, b, ldb )
400 DO 60 j = n - l + 1, n
401 DO 50 i = j - n + l + 1, l
419 CALL sgeqpf( m, n-l, a, lda, iwork, tau, work, info )
424 DO 80 i = 1, min( m, n-l )
425 IF( abs( a( i, i ) ).GT.tola )
431 CALL sorm2r(
'Left',
'Transpose', m, l, min( m, n-l ), a, lda,
432 $ tau, a( 1, n-l+1 ), lda, work, info )
438 CALL slaset(
'Full', m, m, zero, zero, u, ldu )
440 $
CALL slacpy(
'Lower', m-1, n-l, a( 2, 1 ), lda,
442 CALL sorg2r( m, m, min( m, n-l ), u, ldu, tau, work, info )
449 CALL slapmt( forwrd, n, n-l, q, ldq, iwork )
461 $
CALL slaset(
'Full', m-k, n-l, zero, zero, a( k+1, 1 ),
468 CALL sgerq2( k, n-l, a, lda, tau, work, info )
474 CALL sormr2(
'Right',
'Transpose', n, n-l, k, a, lda,
475 $ tau, q, ldq, work, info )
480 CALL slaset(
'Full', k, n-l-k, zero, zero, a, lda )
481 DO 120 j = n - l - k + 1, n - l
482 DO 110 i = j - n + l + k + 1, k
493 CALL sgeqr2( m-k, l, a( k+1, n-l+1 ), lda, tau, work, info )
499 CALL sorm2r(
'Right',
'No transpose', m, m-k,
500 $ min( m-k, l ), a( k+1, n-l+1 ), lda, tau,
501 $ u( 1, k+1 ), ldu, work, info )
506 DO 140 j = n - l + 1, n
507 DO 130 i = j - n + k + l + 1, m