📄 sggsvp.c
字号:
/* lapack/single/sggsvp.f -- translated by f2c (version 20050501).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "v3p_netlib.h"
/* Table of constant values */
static real c_b12 = (float)0.;
static real c_b22 = (float)1.;
/*< >*/
/* Subroutine */ int sggsvp_(char *jobu, char *jobv, char *jobq, integer *m,
integer *p, integer *n, real *a, integer *lda, real *b, integer *ldb,
real *tola, real *tolb, integer *k, integer *l, real *u, integer *ldu,
real *v, integer *ldv, real *q, integer *ldq, integer *iwork, real *
tau, real *work, integer *info, ftnlen jobu_len, ftnlen jobv_len,
ftnlen jobq_len)
{
/* System generated locals */
integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1,
u_offset, v_dim1, v_offset, i__1, i__2, i__3;
real r__1;
/* Local variables */
integer i__, j;
extern logical lsame_(char *, char *, ftnlen, ftnlen);
logical wantq, wantu, wantv;
extern /* Subroutine */ int sgeqr2_(integer *, integer *, real *, integer
*, real *, real *, integer *), sgerq2_(integer *, integer *, real
*, integer *, real *, real *, integer *), sorg2r_(integer *,
integer *, integer *, real *, integer *, real *, real *, integer *
), sorm2r_(char *, char *, integer *, integer *, integer *, real *
, integer *, real *, real *, integer *, real *, integer *, ftnlen,
ftnlen), sormr2_(char *, char *, integer *, integer *, integer *,
real *, integer *, real *, real *, integer *, real *, integer *,
ftnlen, ftnlen), xerbla_(char *, integer *, ftnlen), sgeqpf_(
integer *, integer *, real *, integer *, integer *, real *, real *
, integer *), slacpy_(char *, integer *, integer *, real *,
integer *, real *, integer *, ftnlen), slaset_(char *, integer *,
integer *, real *, real *, real *, integer *, ftnlen), slapmt_(
logical *, integer *, integer *, real *, integer *, integer *);
logical forwrd;
(void)jobu_len;
(void)jobv_len;
(void)jobq_len;
/* -- LAPACK routine (version 3.0) -- */
/* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
/* Courant Institute, Argonne National Lab, and Rice University */
/* September 30, 1994 */
/* .. Scalar Arguments .. */
/*< CHARACTER JOBQ, JOBU, JOBV >*/
/*< INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P >*/
/*< REAL TOLA, TOLB >*/
/* .. */
/* .. Array Arguments .. */
/*< INTEGER IWORK( * ) >*/
/*< >*/
/* .. */
/* Purpose */
/* ======= */
/* SGGSVP computes orthogonal matrices U, V and Q such that */
/* N-K-L K L */
/* U'*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'*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',B')'. Z' denotes the */
/* transpose of Z. */
/* This decomposition is the preprocessing step for computing the */
/* Generalized Singular Value Decomposition (GSVD), see subroutine */
/* SGGSVD. */
/* Arguments */
/* ========= */
/* JOBU (input) CHARACTER*1 */
/* = 'U': Orthogonal matrix U is computed; */
/* = 'N': U is not computed. */
/* JOBV (input) CHARACTER*1 */
/* = 'V': Orthogonal matrix V is computed; */
/* = 'N': V is not computed. */
/* JOBQ (input) CHARACTER*1 */
/* = 'Q': Orthogonal matrix Q is computed; */
/* = 'N': Q is not computed. */
/* M (input) INTEGER */
/* The number of rows of the matrix A. M >= 0. */
/* P (input) INTEGER */
/* The number of rows of the matrix B. P >= 0. */
/* N (input) INTEGER */
/* The number of columns of the matrices A and B. N >= 0. */
/* A (input/output) REAL 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. */
/* LDA (input) INTEGER */
/* The leading dimension of the array A. LDA >= max(1,M). */
/* B (input/output) REAL array, dimension (LDB,N) */
/* On entry, the P-by-N matrix B. */
/* On exit, B contains the triangular matrix described in */
/* the Purpose section. */
/* LDB (input) INTEGER */
/* The leading dimension of the array B. LDB >= max(1,P). */
/* TOLA (input) REAL */
/* TOLB (input) REAL */
/* 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. */
/* K (output) INTEGER */
/* L (output) INTEGER */
/* On exit, K and L specify the dimension of the subblocks */
/* described in Purpose. */
/* K + L = effective numerical rank of (A',B')'. */
/* U (output) REAL array, dimension (LDU,M) */
/* If JOBU = 'U', U contains the orthogonal matrix U. */
/* If JOBU = 'N', U is not referenced. */
/* LDU (input) INTEGER */
/* The leading dimension of the array U. LDU >= max(1,M) if */
/* JOBU = 'U'; LDU >= 1 otherwise. */
/* V (output) REAL array, dimension (LDV,M) */
/* If JOBV = 'V', V contains the orthogonal matrix V. */
/* If JOBV = 'N', V is not referenced. */
/* LDV (input) INTEGER */
/* The leading dimension of the array V. LDV >= max(1,P) if */
/* JOBV = 'V'; LDV >= 1 otherwise. */
/* Q (output) REAL array, dimension (LDQ,N) */
/* If JOBQ = 'Q', Q contains the orthogonal matrix Q. */
/* If JOBQ = 'N', Q is not referenced. */
/* LDQ (input) INTEGER */
/* The leading dimension of the array Q. LDQ >= max(1,N) if */
/* JOBQ = 'Q'; LDQ >= 1 otherwise. */
/* IWORK (workspace) INTEGER array, dimension (N) */
/* TAU (workspace) REAL array, dimension (N) */
/* WORK (workspace) REAL array, dimension (max(3*N,M,P)) */
/* INFO (output) INTEGER */
/* = 0: successful exit */
/* < 0: if INFO = -i, the i-th argument had an illegal value. */
/* Further Details */
/* =============== */
/* The subroutine uses LAPACK subroutine SGEQPF 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. */
/* ===================================================================== */
/* .. Parameters .. */
/*< REAL ZERO, ONE >*/
/*< PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) >*/
/* .. */
/* .. Local Scalars .. */
/*< LOGICAL FORWRD, WANTQ, WANTU, WANTV >*/
/*< INTEGER I, J >*/
/* .. */
/* .. External Functions .. */
/*< LOGICAL LSAME >*/
/*< EXTERNAL LSAME >*/
/* .. */
/* .. External Subroutines .. */
/*< >*/
/* .. */
/* .. Intrinsic Functions .. */
/*< INTRINSIC ABS, MAX, MIN >*/
/* .. */
/* .. Executable Statements .. */
/* Test the input parameters */
/*< WANTU = LSAME( JOBU, 'U' ) >*/
/* Parameter adjustments */
a_dim1 = *lda;
a_offset = 1 + a_dim1;
a -= a_offset;
b_dim1 = *ldb;
b_offset = 1 + b_dim1;
b -= b_offset;
u_dim1 = *ldu;
u_offset = 1 + u_dim1;
u -= u_offset;
v_dim1 = *ldv;
v_offset = 1 + v_dim1;
v -= v_offset;
q_dim1 = *ldq;
q_offset = 1 + q_dim1;
q -= q_offset;
--iwork;
--tau;
--work;
/* Function Body */
wantu = lsame_(jobu, "U", (ftnlen)1, (ftnlen)1);
/*< WANTV = LSAME( JOBV, 'V' ) >*/
wantv = lsame_(jobv, "V", (ftnlen)1, (ftnlen)1);
/*< WANTQ = LSAME( JOBQ, 'Q' ) >*/
wantq = lsame_(jobq, "Q", (ftnlen)1, (ftnlen)1);
/*< FORWRD = .TRUE. >*/
forwrd = TRUE_;
/*< INFO = 0 >*/
*info = 0;
/*< IF( .NOT.( WANTU .OR. LSAME( JOBU, 'N' ) ) ) THEN >*/
if (! (wantu || lsame_(jobu, "N", (ftnlen)1, (ftnlen)1))) {
/*< INFO = -1 >*/
*info = -1;
/*< ELSE IF( .NOT.( WANTV .OR. LSAME( JOBV, 'N' ) ) ) THEN >*/
} else if (! (wantv || lsame_(jobv, "N", (ftnlen)1, (ftnlen)1))) {
/*< INFO = -2 >*/
*info = -2;
/*< ELSE IF( .NOT.( WANTQ .OR. LSAME( JOBQ, 'N' ) ) ) THEN >*/
} else if (! (wantq || lsame_(jobq, "N", (ftnlen)1, (ftnlen)1))) {
/*< INFO = -3 >*/
*info = -3;
/*< ELSE IF( M.LT.0 ) THEN >*/
} else if (*m < 0) {
/*< INFO = -4 >*/
*info = -4;
/*< ELSE IF( P.LT.0 ) THEN >*/
} else if (*p < 0) {
/*< INFO = -5 >*/
*info = -5;
/*< ELSE IF( N.LT.0 ) THEN >*/
} else if (*n < 0) {
/*< INFO = -6 >*/
*info = -6;
/*< ELSE IF( LDA.LT.MAX( 1, M ) ) THEN >*/
} else if (*lda < max(1,*m)) {
/*< INFO = -8 >*/
*info = -8;
/*< ELSE IF( LDB.LT.MAX( 1, P ) ) THEN >*/
} else if (*ldb < max(1,*p)) {
/*< INFO = -10 >*/
*info = -10;
/*< ELSE IF( LDU.LT.1 .OR. ( WANTU .AND. LDU.LT.M ) ) THEN >*/
} else if (*ldu < 1 || (wantu && *ldu < *m)) {
/*< INFO = -16 >*/
*info = -16;
/*< ELSE IF( LDV.LT.1 .OR. ( WANTV .AND. LDV.LT.P ) ) THEN >*/
} else if (*ldv < 1 || (wantv && *ldv < *p)) {
/*< INFO = -18 >*/
*info = -18;
/*< ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN >*/
} else if (*ldq < 1 || (wantq && *ldq < *n)) {
/*< INFO = -20 >*/
*info = -20;
/*< END IF >*/
}
/*< IF( INFO.NE.0 ) THEN >*/
if (*info != 0) {
/*< CALL XERBLA( 'SGGSVP', -INFO ) >*/
i__1 = -(*info);
xerbla_("SGGSVP", &i__1, (ftnlen)6);
/*< RETURN >*/
return 0;
/*< END IF >*/
}
/* QR with column pivoting of B: B*P = V*( S11 S12 ) */
/* ( 0 0 ) */
/*< DO 10 I = 1, N >*/
i__1 = *n;
for (i__ = 1; i__ <= i__1; ++i__) {
/*< IWORK( I ) = 0 >*/
iwork[i__] = 0;
/*< 10 CONTINUE >*/
/* L10: */
}
/*< CALL SGEQPF( P, N, B, LDB, IWORK, TAU, WORK, INFO ) >*/
sgeqpf_(p, n, &b[b_offset], ldb, &iwork[1], &tau[1], &work[1], info);
/* Update A := A*P */
/*< CALL SLAPMT( FORWRD, M, N, A, LDA, IWORK ) >*/
slapmt_(&forwrd, m, n, &a[a_offset], lda, &iwork[1]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -