sgeqrs.c
Go to the documentation of this file.
00001 /* sgeqrs.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static real c_b9 = 1.f;
00019 
00020 /* Subroutine */ int sgeqrs_(integer *m, integer *n, integer *nrhs, real *a, 
00021         integer *lda, real *tau, real *b, integer *ldb, real *work, integer *
00022         lwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
00026 
00027     /* Local variables */
00028     extern /* Subroutine */ int strsm_(char *, char *, char *, char *, 
00029             integer *, integer *, real *, real *, integer *, real *, integer *
00030 ), xerbla_(char *, integer *), sormqr_(char *, char *, integer *, integer *, integer *, 
00031             real *, integer *, real *, real *, integer *, real *, integer *, 
00032             integer *);
00033 
00034 
00035 /*  -- LAPACK routine (version 3.1) -- */
00036 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00037 /*     November 2006 */
00038 
00039 /*     .. Scalar Arguments .. */
00040 /*     .. */
00041 /*     .. Array Arguments .. */
00042 /*     .. */
00043 
00044 /*  Purpose */
00045 /*  ======= */
00046 
00047 /*  Solve the least squares problem */
00048 /*      min || A*X - B || */
00049 /*  using the QR factorization */
00050 /*      A = Q*R */
00051 /*  computed by SGEQRF. */
00052 
00053 /*  Arguments */
00054 /*  ========= */
00055 
00056 /*  M       (input) INTEGER */
00057 /*          The number of rows of the matrix A.  M >= 0. */
00058 
00059 /*  N       (input) INTEGER */
00060 /*          The number of columns of the matrix A.  M >= N >= 0. */
00061 
00062 /*  NRHS    (input) INTEGER */
00063 /*          The number of columns of B.  NRHS >= 0. */
00064 
00065 /*  A       (input) REAL array, dimension (LDA,N) */
00066 /*          Details of the QR factorization of the original matrix A as */
00067 /*          returned by SGEQRF. */
00068 
00069 /*  LDA     (input) INTEGER */
00070 /*          The leading dimension of the array A.  LDA >= M. */
00071 
00072 /*  TAU     (input) REAL array, dimension (N) */
00073 /*          Details of the orthogonal matrix Q. */
00074 
00075 /*  B       (input/output) REAL array, dimension (LDB,NRHS) */
00076 /*          On entry, the m-by-nrhs right hand side matrix B. */
00077 /*          On exit, the n-by-nrhs solution matrix X. */
00078 
00079 /*  LDB     (input) INTEGER */
00080 /*          The leading dimension of the array B. LDB >= M. */
00081 
00082 /*  WORK    (workspace) REAL array, dimension (LWORK) */
00083 
00084 /*  LWORK   (input) INTEGER */
00085 /*          The length of the array WORK.  LWORK must be at least NRHS, */
00086 /*          and should be at least NRHS*NB, where NB is the block size */
00087 /*          for this environment. */
00088 
00089 /*  INFO    (output) INTEGER */
00090 /*          = 0: successful exit */
00091 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00092 
00093 /*  ===================================================================== */
00094 
00095 /*     .. Parameters .. */
00096 /*     .. */
00097 /*     .. External Subroutines .. */
00098 /*     .. */
00099 /*     .. Intrinsic Functions .. */
00100 /*     .. */
00101 /*     .. Executable Statements .. */
00102 
00103 /*     Test the input arguments. */
00104 
00105     /* Parameter adjustments */
00106     a_dim1 = *lda;
00107     a_offset = 1 + a_dim1;
00108     a -= a_offset;
00109     --tau;
00110     b_dim1 = *ldb;
00111     b_offset = 1 + b_dim1;
00112     b -= b_offset;
00113     --work;
00114 
00115     /* Function Body */
00116     *info = 0;
00117     if (*m < 0) {
00118         *info = -1;
00119     } else if (*n < 0 || *n > *m) {
00120         *info = -2;
00121     } else if (*nrhs < 0) {
00122         *info = -3;
00123     } else if (*lda < max(1,*m)) {
00124         *info = -5;
00125     } else if (*ldb < max(1,*m)) {
00126         *info = -8;
00127     } else if (*lwork < 1 || *lwork < *nrhs && *m > 0 && *n > 0) {
00128         *info = -10;
00129     }
00130     if (*info != 0) {
00131         i__1 = -(*info);
00132         xerbla_("SGEQRS", &i__1);
00133         return 0;
00134     }
00135 
00136 /*     Quick return if possible */
00137 
00138     if (*n == 0 || *nrhs == 0 || *m == 0) {
00139         return 0;
00140     }
00141 
00142 /*     B := Q' * B */
00143 
00144     sormqr_("Left", "Transpose", m, nrhs, n, &a[a_offset], lda, &tau[1], &b[
00145             b_offset], ldb, &work[1], lwork, info);
00146 
00147 /*     Solve R*X = B(1:n,:) */
00148 
00149     strsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b9, &a[
00150             a_offset], lda, &b[b_offset], ldb);
00151 
00152     return 0;
00153 
00154 /*     End of SGEQRS */
00155 
00156 } /* sgeqrs_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:06