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


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