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


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