#include "blaswrap.h" /* cgeqls.f -- translated by f2c (version 20061008). 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 */ #include "f2c.h" /* Table of constant values */ static complex c_b1 = {1.f,0.f}; /* Subroutine */ int cgeqls_(integer *m, integer *n, integer *nrhs, complex * a, integer *lda, complex *tau, complex *b, integer *ldb, complex * work, integer *lwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, i__1; /* Local variables */ extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, integer *, integer *, complex *, complex *, integer *, complex *, integer *), xerbla_(char *, integer *), cunmql_(char *, char *, integer *, integer *, integer *, complex *, integer *, complex *, complex *, integer *, complex *, integer *, integer *); /* -- LAPACK routine (version 3.1) -- Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. November 2006 Purpose ======= Solve the least squares problem min || A*X - B || using the QL factorization A = Q*L computed by CGEQLF. Arguments ========= M (input) INTEGER The number of rows of the matrix A. M >= 0. N (input) INTEGER The number of columns of the matrix A. M >= N >= 0. NRHS (input) INTEGER The number of columns of B. NRHS >= 0. A (input) COMPLEX array, dimension (LDA,N) Details of the QL factorization of the original matrix A as returned by CGEQLF. LDA (input) INTEGER The leading dimension of the array A. LDA >= M. TAU (input) COMPLEX array, dimension (N) Details of the orthogonal matrix Q. B (input/output) COMPLEX array, dimension (LDB,NRHS) On entry, the m-by-nrhs right hand side matrix B. On exit, the n-by-nrhs solution matrix X, stored in rows m-n+1:m. LDB (input) INTEGER The leading dimension of the array B. LDB >= M. WORK (workspace) COMPLEX array, dimension (LWORK) LWORK (input) INTEGER The length of the array WORK. LWORK must be at least NRHS, and should be at least NRHS*NB, where NB is the block size for this environment. INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value ===================================================================== Test the input arguments. Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --tau; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; --work; /* Function Body */ *info = 0; if (*m < 0) { *info = -1; } else if (*n < 0 || *n > *m) { *info = -2; } else if (*nrhs < 0) { *info = -3; } else if (*lda < max(1,*m)) { *info = -5; } else if (*ldb < max(1,*m)) { *info = -8; } else if (*lwork < 1 || *lwork < *nrhs && *m > 0 && *n > 0) { *info = -10; } if (*info != 0) { i__1 = -(*info); xerbla_("CGEQLS", &i__1); return 0; } /* Quick return if possible */ if (*n == 0 || *nrhs == 0 || *m == 0) { return 0; } /* B := Q' * B */ cunmql_("Left", "Conjugate transpose", m, nrhs, n, &a[a_offset], lda, & tau[1], &b[b_offset], ldb, &work[1], lwork, info); /* Solve L*X = B(m-n+1:m,:) */ ctrsm_("Left", "Lower", "No transpose", "Non-unit", n, nrhs, &c_b1, &a[*m - *n + 1 + a_dim1], lda, &b[*m - *n + 1 + b_dim1], ldb); return 0; /* End of CGEQLS */ } /* cgeqls_ */