dorgr2.c
Go to the documentation of this file.
00001 /* dorgr2.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 /* Subroutine */ int dorgr2_(integer *m, integer *n, integer *k, doublereal *
00017         a, integer *lda, doublereal *tau, doublereal *work, integer *info)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2, i__3;
00021     doublereal d__1;
00022 
00023     /* Local variables */
00024     integer i__, j, l, ii;
00025     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00026             integer *), dlarf_(char *, integer *, integer *, doublereal *, 
00027             integer *, doublereal *, doublereal *, integer *, doublereal *), xerbla_(char *, integer *);
00028 
00029 
00030 /*  -- LAPACK routine (version 3.2) -- */
00031 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00032 /*     November 2006 */
00033 
00034 /*     .. Scalar Arguments .. */
00035 /*     .. */
00036 /*     .. Array Arguments .. */
00037 /*     .. */
00038 
00039 /*  Purpose */
00040 /*  ======= */
00041 
00042 /*  DORGR2 generates an m by n real matrix Q with orthonormal rows, */
00043 /*  which is defined as the last m rows of a product of k elementary */
00044 /*  reflectors of order n */
00045 
00046 /*        Q  =  H(1) H(2) . . . H(k) */
00047 
00048 /*  as returned by DGERQF. */
00049 
00050 /*  Arguments */
00051 /*  ========= */
00052 
00053 /*  M       (input) INTEGER */
00054 /*          The number of rows of the matrix Q. M >= 0. */
00055 
00056 /*  N       (input) INTEGER */
00057 /*          The number of columns of the matrix Q. N >= M. */
00058 
00059 /*  K       (input) INTEGER */
00060 /*          The number of elementary reflectors whose product defines the */
00061 /*          matrix Q. M >= K >= 0. */
00062 
00063 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00064 /*          On entry, the (m-k+i)-th row must contain the vector which */
00065 /*          defines the elementary reflector H(i), for i = 1,2,...,k, as */
00066 /*          returned by DGERQF in the last k rows of its array argument */
00067 /*          A. */
00068 /*          On exit, the m by n matrix Q. */
00069 
00070 /*  LDA     (input) INTEGER */
00071 /*          The first dimension of the array A. LDA >= max(1,M). */
00072 
00073 /*  TAU     (input) DOUBLE PRECISION array, dimension (K) */
00074 /*          TAU(i) must contain the scalar factor of the elementary */
00075 /*          reflector H(i), as returned by DGERQF. */
00076 
00077 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (M) */
00078 
00079 /*  INFO    (output) INTEGER */
00080 /*          = 0: successful exit */
00081 /*          < 0: if INFO = -i, the i-th argument has an illegal value */
00082 
00083 /*  ===================================================================== */
00084 
00085 /*     .. Parameters .. */
00086 /*     .. */
00087 /*     .. Local Scalars .. */
00088 /*     .. */
00089 /*     .. External Subroutines .. */
00090 /*     .. */
00091 /*     .. Intrinsic Functions .. */
00092 /*     .. */
00093 /*     .. Executable Statements .. */
00094 
00095 /*     Test the input arguments */
00096 
00097     /* Parameter adjustments */
00098     a_dim1 = *lda;
00099     a_offset = 1 + a_dim1;
00100     a -= a_offset;
00101     --tau;
00102     --work;
00103 
00104     /* Function Body */
00105     *info = 0;
00106     if (*m < 0) {
00107         *info = -1;
00108     } else if (*n < *m) {
00109         *info = -2;
00110     } else if (*k < 0 || *k > *m) {
00111         *info = -3;
00112     } else if (*lda < max(1,*m)) {
00113         *info = -5;
00114     }
00115     if (*info != 0) {
00116         i__1 = -(*info);
00117         xerbla_("DORGR2", &i__1);
00118         return 0;
00119     }
00120 
00121 /*     Quick return if possible */
00122 
00123     if (*m <= 0) {
00124         return 0;
00125     }
00126 
00127     if (*k < *m) {
00128 
00129 /*        Initialise rows 1:m-k to rows of the unit matrix */
00130 
00131         i__1 = *n;
00132         for (j = 1; j <= i__1; ++j) {
00133             i__2 = *m - *k;
00134             for (l = 1; l <= i__2; ++l) {
00135                 a[l + j * a_dim1] = 0.;
00136 /* L10: */
00137             }
00138             if (j > *n - *m && j <= *n - *k) {
00139                 a[*m - *n + j + j * a_dim1] = 1.;
00140             }
00141 /* L20: */
00142         }
00143     }
00144 
00145     i__1 = *k;
00146     for (i__ = 1; i__ <= i__1; ++i__) {
00147         ii = *m - *k + i__;
00148 
00149 /*        Apply H(i) to A(1:m-k+i,1:n-k+i) from the right */
00150 
00151         a[ii + (*n - *m + ii) * a_dim1] = 1.;
00152         i__2 = ii - 1;
00153         i__3 = *n - *m + ii;
00154         dlarf_("Right", &i__2, &i__3, &a[ii + a_dim1], lda, &tau[i__], &a[
00155                 a_offset], lda, &work[1]);
00156         i__2 = *n - *m + ii - 1;
00157         d__1 = -tau[i__];
00158         dscal_(&i__2, &d__1, &a[ii + a_dim1], lda);
00159         a[ii + (*n - *m + ii) * a_dim1] = 1. - tau[i__];
00160 
00161 /*        Set A(m-k+i,n-k+i+1:n) to zero */
00162 
00163         i__2 = *n;
00164         for (l = *n - *m + ii + 1; l <= i__2; ++l) {
00165             a[ii + l * a_dim1] = 0.;
00166 /* L30: */
00167         }
00168 /* L40: */
00169     }
00170     return 0;
00171 
00172 /*     End of DORGR2 */
00173 
00174 } /* dorgr2_ */


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