LAPACK  3.5.0
LAPACK: Linear Algebra PACKage
dggsvp.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine dggsvp (JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB, TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ, IWORK, TAU, WORK, INFO)
 DGGSVP More...
 

Function/Subroutine Documentation

subroutine dggsvp ( character  JOBU,
character  JOBV,
character  JOBQ,
integer  M,
integer  P,
integer  N,
double precision, dimension( lda, * )  A,
integer  LDA,
double precision, dimension( ldb, * )  B,
integer  LDB,
double precision  TOLA,
double precision  TOLB,
integer  K,
integer  L,
double precision, dimension( ldu, * )  U,
integer  LDU,
double precision, dimension( ldv, * )  V,
integer  LDV,
double precision, dimension( ldq, * )  Q,
integer  LDQ,
integer, dimension( * )  IWORK,
double precision, dimension( * )  TAU,
double precision, dimension( * )  WORK,
integer  INFO 
)

DGGSVP

Download DGGSVP + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 DGGSVP computes orthogonal matrices U, V and Q such that

                    N-K-L  K    L
  U**T*A*Q =     K ( 0    A12  A13 )  if M-K-L >= 0;
                 L ( 0     0   A23 )
             M-K-L ( 0     0    0  )

                  N-K-L  K    L
         =     K ( 0    A12  A13 )  if M-K-L < 0;
             M-K ( 0     0   A23 )

                  N-K-L  K    L
  V**T*B*Q =   L ( 0     0   B13 )
             P-L ( 0     0    0  )

 where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
 upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
 otherwise A23 is (M-K)-by-L upper trapezoidal.  K+L = the effective
 numerical rank of the (M+P)-by-N matrix (A**T,B**T)**T. 

 This decomposition is the preprocessing step for computing the
 Generalized Singular Value Decomposition (GSVD), see subroutine
 DGGSVD.
Parameters
[in]JOBU
          JOBU is CHARACTER*1
          = 'U':  Orthogonal matrix U is computed;
          = 'N':  U is not computed.
[in]JOBV
          JOBV is CHARACTER*1
          = 'V':  Orthogonal matrix V is computed;
          = 'N':  V is not computed.
[in]JOBQ
          JOBQ is CHARACTER*1
          = 'Q':  Orthogonal matrix Q is computed;
          = 'N':  Q is not computed.
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]P
          P is INTEGER
          The number of rows of the matrix B.  P >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrices A and B.  N >= 0.
[in,out]A
          A is DOUBLE PRECISION array, dimension (LDA,N)
          On entry, the M-by-N matrix A.
          On exit, A contains the triangular (or trapezoidal) matrix
          described in the Purpose section.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A. LDA >= max(1,M).
[in,out]B
          B is DOUBLE PRECISION array, dimension (LDB,N)
          On entry, the P-by-N matrix B.
          On exit, B contains the triangular matrix described in
          the Purpose section.
[in]LDB
          LDB is INTEGER
          The leading dimension of the array B. LDB >= max(1,P).
[in]TOLA
          TOLA is DOUBLE PRECISION
[in]TOLB
          TOLB is DOUBLE PRECISION

          TOLA and TOLB are the thresholds to determine the effective
          numerical rank of matrix B and a subblock of A. Generally,
          they are set to
             TOLA = MAX(M,N)*norm(A)*MACHEPS,
             TOLB = MAX(P,N)*norm(B)*MACHEPS.
          The size of TOLA and TOLB may affect the size of backward
          errors of the decomposition.
[out]K
          K is INTEGER
[out]L
          L is INTEGER

          On exit, K and L specify the dimension of the subblocks
          described in Purpose section.
          K + L = effective numerical rank of (A**T,B**T)**T.
[out]U
          U is DOUBLE PRECISION array, dimension (LDU,M)
          If JOBU = 'U', U contains the orthogonal matrix U.
          If JOBU = 'N', U is not referenced.
[in]LDU
          LDU is INTEGER
          The leading dimension of the array U. LDU >= max(1,M) if
          JOBU = 'U'; LDU >= 1 otherwise.
[out]V
          V is DOUBLE PRECISION array, dimension (LDV,P)
          If JOBV = 'V', V contains the orthogonal matrix V.
          If JOBV = 'N', V is not referenced.
[in]LDV
          LDV is INTEGER
          The leading dimension of the array V. LDV >= max(1,P) if
          JOBV = 'V'; LDV >= 1 otherwise.
[out]Q
          Q is DOUBLE PRECISION array, dimension (LDQ,N)
          If JOBQ = 'Q', Q contains the orthogonal matrix Q.
          If JOBQ = 'N', Q is not referenced.
[in]LDQ
          LDQ is INTEGER
          The leading dimension of the array Q. LDQ >= max(1,N) if
          JOBQ = 'Q'; LDQ >= 1 otherwise.
[out]IWORK
          IWORK is INTEGER array, dimension (N)
[out]TAU
          TAU is DOUBLE PRECISION array, dimension (N)
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (max(3*N,M,P))
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011
Further Details:
The subroutine uses LAPACK subroutine DGEQPF for the QR factorization with column pivoting to detect the effective numerical rank of the a matrix. It may be replaced by a better rank determination strategy.

Definition at line 256 of file dggsvp.f.

256 *
257 * -- LAPACK computational routine (version 3.4.0) --
258 * -- LAPACK is a software package provided by Univ. of Tennessee, --
259 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
260 * November 2011
261 *
262 * .. Scalar Arguments ..
263  CHARACTER jobq, jobu, jobv
264  INTEGER info, k, l, lda, ldb, ldq, ldu, ldv, m, n, p
265  DOUBLE PRECISION tola, tolb
266 * ..
267 * .. Array Arguments ..
268  INTEGER iwork( * )
269  DOUBLE PRECISION a( lda, * ), b( ldb, * ), q( ldq, * ),
270  $ tau( * ), u( ldu, * ), v( ldv, * ), work( * )
271 * ..
272 *
273 * =====================================================================
274 *
275 * .. Parameters ..
276  DOUBLE PRECISION zero, one
277  parameter( zero = 0.0d+0, one = 1.0d+0 )
278 * ..
279 * .. Local Scalars ..
280  LOGICAL forwrd, wantq, wantu, wantv
281  INTEGER i, j
282 * ..
283 * .. External Functions ..
284  LOGICAL lsame
285  EXTERNAL lsame
286 * ..
287 * .. External Subroutines ..
288  EXTERNAL dgeqpf, dgeqr2, dgerq2, dlacpy, dlapmt, dlaset,
290 * ..
291 * .. Intrinsic Functions ..
292  INTRINSIC abs, max, min
293 * ..
294 * .. Executable Statements ..
295 *
296 * Test the input parameters
297 *
298  wantu = lsame( jobu, 'U' )
299  wantv = lsame( jobv, 'V' )
300  wantq = lsame( jobq, 'Q' )
301  forwrd = .true.
302 *
303  info = 0
304  IF( .NOT.( wantu .OR. lsame( jobu, 'N' ) ) ) THEN
305  info = -1
306  ELSE IF( .NOT.( wantv .OR. lsame( jobv, 'N' ) ) ) THEN
307  info = -2
308  ELSE IF( .NOT.( wantq .OR. lsame( jobq, 'N' ) ) ) THEN
309  info = -3
310  ELSE IF( m.LT.0 ) THEN
311  info = -4
312  ELSE IF( p.LT.0 ) THEN
313  info = -5
314  ELSE IF( n.LT.0 ) THEN
315  info = -6
316  ELSE IF( lda.LT.max( 1, m ) ) THEN
317  info = -8
318  ELSE IF( ldb.LT.max( 1, p ) ) THEN
319  info = -10
320  ELSE IF( ldu.LT.1 .OR. ( wantu .AND. ldu.LT.m ) ) THEN
321  info = -16
322  ELSE IF( ldv.LT.1 .OR. ( wantv .AND. ldv.LT.p ) ) THEN
323  info = -18
324  ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) ) THEN
325  info = -20
326  END IF
327  IF( info.NE.0 ) THEN
328  CALL xerbla( 'DGGSVP', -info )
329  RETURN
330  END IF
331 *
332 * QR with column pivoting of B: B*P = V*( S11 S12 )
333 * ( 0 0 )
334 *
335  DO 10 i = 1, n
336  iwork( i ) = 0
337  10 CONTINUE
338  CALL dgeqpf( p, n, b, ldb, iwork, tau, work, info )
339 *
340 * Update A := A*P
341 *
342  CALL dlapmt( forwrd, m, n, a, lda, iwork )
343 *
344 * Determine the effective rank of matrix B.
345 *
346  l = 0
347  DO 20 i = 1, min( p, n )
348  IF( abs( b( i, i ) ).GT.tolb )
349  $ l = l + 1
350  20 CONTINUE
351 *
352  IF( wantv ) THEN
353 *
354 * Copy the details of V, and form V.
355 *
356  CALL dlaset( 'Full', p, p, zero, zero, v, ldv )
357  IF( p.GT.1 )
358  $ CALL dlacpy( 'Lower', p-1, n, b( 2, 1 ), ldb, v( 2, 1 ),
359  $ ldv )
360  CALL dorg2r( p, p, min( p, n ), v, ldv, tau, work, info )
361  END IF
362 *
363 * Clean up B
364 *
365  DO 40 j = 1, l - 1
366  DO 30 i = j + 1, l
367  b( i, j ) = zero
368  30 CONTINUE
369  40 CONTINUE
370  IF( p.GT.l )
371  $ CALL dlaset( 'Full', p-l, n, zero, zero, b( l+1, 1 ), ldb )
372 *
373  IF( wantq ) THEN
374 *
375 * Set Q = I and Update Q := Q*P
376 *
377  CALL dlaset( 'Full', n, n, zero, one, q, ldq )
378  CALL dlapmt( forwrd, n, n, q, ldq, iwork )
379  END IF
380 *
381  IF( p.GE.l .AND. n.NE.l ) THEN
382 *
383 * RQ factorization of (S11 S12): ( S11 S12 ) = ( 0 S12 )*Z
384 *
385  CALL dgerq2( l, n, b, ldb, tau, work, info )
386 *
387 * Update A := A*Z**T
388 *
389  CALL dormr2( 'Right', 'Transpose', m, n, l, b, ldb, tau, a,
390  $ lda, work, info )
391 *
392  IF( wantq ) THEN
393 *
394 * Update Q := Q*Z**T
395 *
396  CALL dormr2( 'Right', 'Transpose', n, n, l, b, ldb, tau, q,
397  $ ldq, work, info )
398  END IF
399 *
400 * Clean up B
401 *
402  CALL dlaset( 'Full', l, n-l, zero, zero, b, ldb )
403  DO 60 j = n - l + 1, n
404  DO 50 i = j - n + l + 1, l
405  b( i, j ) = zero
406  50 CONTINUE
407  60 CONTINUE
408 *
409  END IF
410 *
411 * Let N-L L
412 * A = ( A11 A12 ) M,
413 *
414 * then the following does the complete QR decomposition of A11:
415 *
416 * A11 = U*( 0 T12 )*P1**T
417 * ( 0 0 )
418 *
419  DO 70 i = 1, n - l
420  iwork( i ) = 0
421  70 CONTINUE
422  CALL dgeqpf( m, n-l, a, lda, iwork, tau, work, info )
423 *
424 * Determine the effective rank of A11
425 *
426  k = 0
427  DO 80 i = 1, min( m, n-l )
428  IF( abs( a( i, i ) ).GT.tola )
429  $ k = k + 1
430  80 CONTINUE
431 *
432 * Update A12 := U**T*A12, where A12 = A( 1:M, N-L+1:N )
433 *
434  CALL dorm2r( 'Left', 'Transpose', m, l, min( m, n-l ), a, lda,
435  $ tau, a( 1, n-l+1 ), lda, work, info )
436 *
437  IF( wantu ) THEN
438 *
439 * Copy the details of U, and form U
440 *
441  CALL dlaset( 'Full', m, m, zero, zero, u, ldu )
442  IF( m.GT.1 )
443  $ CALL dlacpy( 'Lower', m-1, n-l, a( 2, 1 ), lda, u( 2, 1 ),
444  $ ldu )
445  CALL dorg2r( m, m, min( m, n-l ), u, ldu, tau, work, info )
446  END IF
447 *
448  IF( wantq ) THEN
449 *
450 * Update Q( 1:N, 1:N-L ) = Q( 1:N, 1:N-L )*P1
451 *
452  CALL dlapmt( forwrd, n, n-l, q, ldq, iwork )
453  END IF
454 *
455 * Clean up A: set the strictly lower triangular part of
456 * A(1:K, 1:K) = 0, and A( K+1:M, 1:N-L ) = 0.
457 *
458  DO 100 j = 1, k - 1
459  DO 90 i = j + 1, k
460  a( i, j ) = zero
461  90 CONTINUE
462  100 CONTINUE
463  IF( m.GT.k )
464  $ CALL dlaset( 'Full', m-k, n-l, zero, zero, a( k+1, 1 ), lda )
465 *
466  IF( n-l.GT.k ) THEN
467 *
468 * RQ factorization of ( T11 T12 ) = ( 0 T12 )*Z1
469 *
470  CALL dgerq2( k, n-l, a, lda, tau, work, info )
471 *
472  IF( wantq ) THEN
473 *
474 * Update Q( 1:N,1:N-L ) = Q( 1:N,1:N-L )*Z1**T
475 *
476  CALL dormr2( 'Right', 'Transpose', n, n-l, k, a, lda, tau,
477  $ q, ldq, work, info )
478  END IF
479 *
480 * Clean up A
481 *
482  CALL dlaset( 'Full', k, n-l-k, zero, zero, a, lda )
483  DO 120 j = n - l - k + 1, n - l
484  DO 110 i = j - n + l + k + 1, k
485  a( i, j ) = zero
486  110 CONTINUE
487  120 CONTINUE
488 *
489  END IF
490 *
491  IF( m.GT.k ) THEN
492 *
493 * QR factorization of A( K+1:M,N-L+1:N )
494 *
495  CALL dgeqr2( m-k, l, a( k+1, n-l+1 ), lda, tau, work, info )
496 *
497  IF( wantu ) THEN
498 *
499 * Update U(:,K+1:M) := U(:,K+1:M)*U1
500 *
501  CALL dorm2r( 'Right', 'No transpose', m, m-k, min( m-k, l ),
502  $ a( k+1, n-l+1 ), lda, tau, u( 1, k+1 ), ldu,
503  $ work, info )
504  END IF
505 *
506 * Clean up
507 *
508  DO 140 j = n - l + 1, n
509  DO 130 i = j - n + k + l + 1, m
510  a( i, j ) = zero
511  130 CONTINUE
512  140 CONTINUE
513 *
514  END IF
515 *
516  RETURN
517 *
518 * End of DGGSVP
519 *
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine dorg2r(M, N, K, A, LDA, TAU, WORK, INFO)
DORG2R generates all or part of the orthogonal matrix Q from a QR factorization determined by sgeqrf ...
Definition: dorg2r.f:116
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dgeqpf(M, N, A, LDA, JPVT, TAU, WORK, INFO)
DGEQPF
Definition: dgeqpf.f:144
subroutine dgeqr2(M, N, A, LDA, TAU, WORK, INFO)
DGEQR2 computes the QR factorization of a general rectangular matrix using an unblocked algorithm...
Definition: dgeqr2.f:123
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105
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...
Definition: dlaset.f:112
subroutine dorm2r(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, INFO)
DORM2R multiplies a general matrix by the orthogonal matrix from a QR factorization determined by sge...
Definition: dorm2r.f:161
subroutine dlapmt(FORWRD, M, N, X, LDX, K)
DLAPMT performs a forward or backward permutation of the columns of a matrix.
Definition: dlapmt.f:106
subroutine dormr2(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, INFO)
DORMR2 multiplies a general matrix by the orthogonal matrix from a RQ factorization determined by sge...
Definition: dormr2.f:161
subroutine dgerq2(M, N, A, LDA, TAU, WORK, INFO)
DGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm...
Definition: dgerq2.f:125

Here is the call graph for this function:

Here is the caller graph for this function: