sgelq2.c
Go to the documentation of this file.
00001 /* sgelq2.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 sgelq2_(integer *m, integer *n, real *a, integer *lda, 
00017         real *tau, real *work, integer *info)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2, i__3;
00021 
00022     /* Local variables */
00023     integer i__, k;
00024     real aii;
00025     extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, 
00026             integer *, real *, real *, integer *, real *), xerbla_(
00027             char *, integer *), slarfp_(integer *, real *, real *, 
00028             integer *, real *);
00029 
00030 
00031 /*  -- LAPACK routine (version 3.2) -- */
00032 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00033 /*     November 2006 */
00034 
00035 /*     .. Scalar Arguments .. */
00036 /*     .. */
00037 /*     .. Array Arguments .. */
00038 /*     .. */
00039 
00040 /*  Purpose */
00041 /*  ======= */
00042 
00043 /*  SGELQ2 computes an LQ factorization of a real m by n matrix A: */
00044 /*  A = L * Q. */
00045 
00046 /*  Arguments */
00047 /*  ========= */
00048 
00049 /*  M       (input) INTEGER */
00050 /*          The number of rows of the matrix A.  M >= 0. */
00051 
00052 /*  N       (input) INTEGER */
00053 /*          The number of columns of the matrix A.  N >= 0. */
00054 
00055 /*  A       (input/output) REAL array, dimension (LDA,N) */
00056 /*          On entry, the m by n matrix A. */
00057 /*          On exit, the elements on and below the diagonal of the array */
00058 /*          contain the m by min(m,n) lower trapezoidal matrix L (L is */
00059 /*          lower triangular if m <= n); the elements above the diagonal, */
00060 /*          with the array TAU, represent the orthogonal matrix Q as a */
00061 /*          product of elementary reflectors (see Further Details). */
00062 
00063 /*  LDA     (input) INTEGER */
00064 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00065 
00066 /*  TAU     (output) REAL array, dimension (min(M,N)) */
00067 /*          The scalar factors of the elementary reflectors (see Further */
00068 /*          Details). */
00069 
00070 /*  WORK    (workspace) REAL array, dimension (M) */
00071 
00072 /*  INFO    (output) INTEGER */
00073 /*          = 0: successful exit */
00074 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00075 
00076 /*  Further Details */
00077 /*  =============== */
00078 
00079 /*  The matrix Q is represented as a product of elementary reflectors */
00080 
00081 /*     Q = H(k) . . . H(2) H(1), where k = min(m,n). */
00082 
00083 /*  Each H(i) has the form */
00084 
00085 /*     H(i) = I - tau * v * v' */
00086 
00087 /*  where tau is a real scalar, and v is a real vector with */
00088 /*  v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n), */
00089 /*  and tau in TAU(i). */
00090 
00091 /*  ===================================================================== */
00092 
00093 /*     .. Parameters .. */
00094 /*     .. */
00095 /*     .. Local Scalars .. */
00096 /*     .. */
00097 /*     .. External Subroutines .. */
00098 /*     .. */
00099 /*     .. Intrinsic Functions .. */
00100 /*     .. */
00101 /*     .. Executable Statements .. */
00102 
00103 /*     Test the input arguments */
00104 
00105     /* Parameter adjustments */
00106     a_dim1 = *lda;
00107     a_offset = 1 + a_dim1;
00108     a -= a_offset;
00109     --tau;
00110     --work;
00111 
00112     /* Function Body */
00113     *info = 0;
00114     if (*m < 0) {
00115         *info = -1;
00116     } else if (*n < 0) {
00117         *info = -2;
00118     } else if (*lda < max(1,*m)) {
00119         *info = -4;
00120     }
00121     if (*info != 0) {
00122         i__1 = -(*info);
00123         xerbla_("SGELQ2", &i__1);
00124         return 0;
00125     }
00126 
00127     k = min(*m,*n);
00128 
00129     i__1 = k;
00130     for (i__ = 1; i__ <= i__1; ++i__) {
00131 
00132 /*        Generate elementary reflector H(i) to annihilate A(i,i+1:n) */
00133 
00134         i__2 = *n - i__ + 1;
00135 /* Computing MIN */
00136         i__3 = i__ + 1;
00137         slarfp_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)* a_dim1]
00138 , lda, &tau[i__]);
00139         if (i__ < *m) {
00140 
00141 /*           Apply H(i) to A(i+1:m,i:n) from the right */
00142 
00143             aii = a[i__ + i__ * a_dim1];
00144             a[i__ + i__ * a_dim1] = 1.f;
00145             i__2 = *m - i__;
00146             i__3 = *n - i__ + 1;
00147             slarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &tau[
00148                     i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
00149             a[i__ + i__ * a_dim1] = aii;
00150         }
00151 /* L10: */
00152     }
00153     return 0;
00154 
00155 /*     End of SGELQ2 */
00156 
00157 } /* sgelq2_ */


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