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


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