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


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