dgeqrs.c
Go to the documentation of this file.
00001 /* dgeqrs.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 doublereal c_b9 = 1.;
00019 
00020 /* Subroutine */ int dgeqrs_(integer *m, integer *n, integer *nrhs, 
00021         doublereal *a, integer *lda, doublereal *tau, doublereal *b, integer *
00022         ldb, doublereal *work, integer *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 dtrsm_(char *, char *, char *, char *, 
00029             integer *, integer *, doublereal *, doublereal *, integer *, 
00030             doublereal *, integer *), xerbla_(
00031             char *, integer *), dormqr_(char *, char *, integer *, 
00032             integer *, integer *, doublereal *, integer *, doublereal *, 
00033             doublereal *, integer *, doublereal *, integer *, integer *);
00034 
00035 
00036 /*  -- LAPACK routine (version 3.1) -- */
00037 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00038 /*     November 2006 */
00039 
00040 /*     .. Scalar Arguments .. */
00041 /*     .. */
00042 /*     .. Array Arguments .. */
00043 /*     .. */
00044 
00045 /*  Purpose */
00046 /*  ======= */
00047 
00048 /*  Solve the least squares problem */
00049 /*      min || A*X - B || */
00050 /*  using the QR factorization */
00051 /*      A = Q*R */
00052 /*  computed by DGEQRF. */
00053 
00054 /*  Arguments */
00055 /*  ========= */
00056 
00057 /*  M       (input) INTEGER */
00058 /*          The number of rows of the matrix A.  M >= 0. */
00059 
00060 /*  N       (input) INTEGER */
00061 /*          The number of columns of the matrix A.  M >= N >= 0. */
00062 
00063 /*  NRHS    (input) INTEGER */
00064 /*          The number of columns of B.  NRHS >= 0. */
00065 
00066 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00067 /*          Details of the QR factorization of the original matrix A as */
00068 /*          returned by DGEQRF. */
00069 
00070 /*  LDA     (input) INTEGER */
00071 /*          The leading dimension of the array A.  LDA >= M. */
00072 
00073 /*  TAU     (input) DOUBLE PRECISION array, dimension (N) */
00074 /*          Details of the orthogonal matrix Q. */
00075 
00076 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00077 /*          On entry, the m-by-nrhs right hand side matrix B. */
00078 /*          On exit, the n-by-nrhs solution matrix X. */
00079 
00080 /*  LDB     (input) INTEGER */
00081 /*          The leading dimension of the array B. LDB >= M. */
00082 
00083 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00084 
00085 /*  LWORK   (input) INTEGER */
00086 /*          The length of the array WORK.  LWORK must be at least NRHS, */
00087 /*          and should be at least NRHS*NB, where NB is the block size */
00088 /*          for this environment. */
00089 
00090 /*  INFO    (output) INTEGER */
00091 /*          = 0: successful exit */
00092 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00093 
00094 /*  ===================================================================== */
00095 
00096 /*     .. Parameters .. */
00097 /*     .. */
00098 /*     .. External Subroutines .. */
00099 /*     .. */
00100 /*     .. Intrinsic Functions .. */
00101 /*     .. */
00102 /*     .. Executable Statements .. */
00103 
00104 /*     Test the input arguments. */
00105 
00106     /* Parameter adjustments */
00107     a_dim1 = *lda;
00108     a_offset = 1 + a_dim1;
00109     a -= a_offset;
00110     --tau;
00111     b_dim1 = *ldb;
00112     b_offset = 1 + b_dim1;
00113     b -= b_offset;
00114     --work;
00115 
00116     /* Function Body */
00117     *info = 0;
00118     if (*m < 0) {
00119         *info = -1;
00120     } else if (*n < 0 || *n > *m) {
00121         *info = -2;
00122     } else if (*nrhs < 0) {
00123         *info = -3;
00124     } else if (*lda < max(1,*m)) {
00125         *info = -5;
00126     } else if (*ldb < max(1,*m)) {
00127         *info = -8;
00128     } else if (*lwork < 1 || *lwork < *nrhs && *m > 0 && *n > 0) {
00129         *info = -10;
00130     }
00131     if (*info != 0) {
00132         i__1 = -(*info);
00133         xerbla_("DGEQRS", &i__1);
00134         return 0;
00135     }
00136 
00137 /*     Quick return if possible */
00138 
00139     if (*n == 0 || *nrhs == 0 || *m == 0) {
00140         return 0;
00141     }
00142 
00143 /*     B := Q' * B */
00144 
00145     dormqr_("Left", "Transpose", m, nrhs, n, &a[a_offset], lda, &tau[1], &b[
00146             b_offset], ldb, &work[1], lwork, info);
00147 
00148 /*     Solve R*X = B(1:n,:) */
00149 
00150     dtrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b9, &a[
00151             a_offset], lda, &b[b_offset], ldb);
00152 
00153     return 0;
00154 
00155 /*     End of DGEQRS */
00156 
00157 } /* dgeqrs_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:44