260 SUBROUTINE zggsvp( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
261 $ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
262 $ IWORK, RWORK, TAU, WORK, INFO )
269 CHARACTER JOBQ, JOBU, JOBV
270 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
271 DOUBLE PRECISION TOLA, TOLB
275 DOUBLE PRECISION RWORK( * )
276 COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
277 $ tau( * ), u( ldu, * ), v( ldv, * ), work( * )
283 COMPLEX*16 CZERO, CONE
284 PARAMETER ( CZERO = ( 0.0d+0, 0.0d+0 ),
285 $ cone = ( 1.0d+0, 0.0d+0 ) )
288 LOGICAL FORWRD, WANTQ, WANTU, WANTV
301 INTRINSIC abs, dble, dimag, max, min
304 DOUBLE PRECISION CABS1
307 cabs1( t ) = abs( dble( t ) ) + abs( dimag( t ) )
313 wantu = lsame( jobu,
'U' )
314 wantv = lsame( jobv,
'V' )
315 wantq = lsame( jobq,
'Q' )
319 IF( .NOT.( wantu .OR. lsame( jobu,
'N' ) ) )
THEN
321 ELSE IF( .NOT.( wantv .OR. lsame( jobv,
'N' ) ) )
THEN
323 ELSE IF( .NOT.( wantq .OR. lsame( jobq,
'N' ) ) )
THEN
325 ELSE IF( m.LT.0 )
THEN
327 ELSE IF( p.LT.0 )
THEN
329 ELSE IF( n.LT.0 )
THEN
331 ELSE IF( lda.LT.max( 1, m ) )
THEN
333 ELSE IF( ldb.LT.max( 1, p ) )
THEN
335 ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) )
THEN
337 ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) )
THEN
339 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) )
THEN
343 CALL xerbla(
'ZGGSVP', -info )
353 CALL zgeqpf( p, n, b, ldb, iwork, tau, work, rwork, info )
357 CALL zlapmt( forwrd, m, n, a, lda, iwork )
362 DO 20 i = 1, min( p, n )
363 IF( cabs1( b( i, i ) ).GT.tolb )
371 CALL zlaset(
'Full', p, p, czero, czero, v, ldv )
373 $
CALL zlacpy(
'Lower', p-1, n, b( 2, 1 ), ldb, v( 2, 1 ),
375 CALL zung2r( p, p, min( p, n ), v, ldv, tau, work, info )
386 $
CALL zlaset(
'Full', p-l, n, czero, czero, b( l+1, 1 ),
393 CALL zlaset(
'Full', n, n, czero, cone, q, ldq )
394 CALL zlapmt( forwrd, n, n, q, ldq, iwork )
397 IF( p.GE.l .AND. n.NE.l )
THEN
401 CALL zgerq2( l, n, b, ldb, tau, work, info )
405 CALL zunmr2(
'Right',
'Conjugate transpose', m, n, l, b,
406 $ ldb, tau, a, lda, work, info )
411 CALL zunmr2(
'Right',
'Conjugate transpose', n, n, l, b,
412 $ ldb, tau, q, ldq, work, info )
417 CALL zlaset(
'Full', l, n-l, czero, czero, b, ldb )
418 DO 60 j = n - l + 1, n
419 DO 50 i = j - n + l + 1, l
437 CALL zgeqpf( m, n-l, a, lda, iwork, tau, work, rwork, info )
442 DO 80 i = 1, min( m, n-l )
443 IF( cabs1( a( i, i ) ).GT.tola )
449 CALL zunm2r(
'Left',
'Conjugate transpose', m, l,
450 $ min( m, n-l ), a, lda, tau, a( 1, n-l+1 ), lda,
457 CALL zlaset(
'Full', m, m, czero, czero, u, ldu )
459 $
CALL zlacpy(
'Lower', m-1, n-l, a( 2, 1 ), lda,
461 CALL zung2r( m, m, min( m, n-l ), u, ldu, tau, work,
469 CALL zlapmt( forwrd, n, n-l, q, ldq, iwork )
481 $
CALL zlaset(
'Full', m-k, n-l, czero, czero, a( k+1, 1 ),
488 CALL zgerq2( k, n-l, a, lda, tau, work, info )
494 CALL zunmr2(
'Right',
'Conjugate transpose', n, n-l, k,
495 $ a, lda, tau, q, ldq, work, info )
500 CALL zlaset(
'Full', k, n-l-k, czero, czero, a, lda )
501 DO 120 j = n - l - k + 1, n - l
502 DO 110 i = j - n + l + k + 1, k
513 CALL zgeqr2( m-k, l, a( k+1, n-l+1 ), lda, tau, work, info )
519 CALL zunm2r(
'Right',
'No transpose', m, m-k,
520 $ min( m-k, l ), a( k+1, n-l+1 ), lda, tau,
521 $ u( 1, k+1 ), ldu, work, info )
526 DO 140 j = n - l + 1, n
527 DO 130 i = j - n + k + l + 1, m