sorgl2.c
Go to the documentation of this file.
00001 /* sorgl2.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 sorgl2_(integer *m, integer *n, integer *k, real *a, 
00017         integer *lda, real *tau, real *work, integer *info)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, i__1, i__2;
00021     real r__1;
00022 
00023     /* Local variables */
00024     integer i__, j, l;
00025     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00026             slarf_(char *, integer *, integer *, real *, integer *, real *, 
00027             real *, integer *, real *), 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 /*  SORGL2 generates an m by n real matrix Q with orthonormal rows, */
00043 /*  which is defined as the first m rows of a product of k elementary */
00044 /*  reflectors of order n */
00045 
00046 /*        Q  =  H(k) . . . H(2) H(1) */
00047 
00048 /*  as returned by SGELQF. */
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) REAL array, dimension (LDA,N) */
00064 /*          On entry, the i-th row must contain the vector which defines */
00065 /*          the elementary reflector H(i), for i = 1,2,...,k, as returned */
00066 /*          by SGELQF in the first k rows of its array argument A. */
00067 /*          On exit, the m-by-n matrix Q. */
00068 
00069 /*  LDA     (input) INTEGER */
00070 /*          The first dimension of the array A. LDA >= max(1,M). */
00071 
00072 /*  TAU     (input) REAL array, dimension (K) */
00073 /*          TAU(i) must contain the scalar factor of the elementary */
00074 /*          reflector H(i), as returned by SGELQF. */
00075 
00076 /*  WORK    (workspace) REAL array, dimension (M) */
00077 
00078 /*  INFO    (output) INTEGER */
00079 /*          = 0: successful exit */
00080 /*          < 0: if INFO = -i, the i-th argument has an illegal value */
00081 
00082 /*  ===================================================================== */
00083 
00084 /*     .. Parameters .. */
00085 /*     .. */
00086 /*     .. Local Scalars .. */
00087 /*     .. */
00088 /*     .. External Subroutines .. */
00089 /*     .. */
00090 /*     .. Intrinsic Functions .. */
00091 /*     .. */
00092 /*     .. Executable Statements .. */
00093 
00094 /*     Test the input arguments */
00095 
00096     /* Parameter adjustments */
00097     a_dim1 = *lda;
00098     a_offset = 1 + a_dim1;
00099     a -= a_offset;
00100     --tau;
00101     --work;
00102 
00103     /* Function Body */
00104     *info = 0;
00105     if (*m < 0) {
00106         *info = -1;
00107     } else if (*n < *m) {
00108         *info = -2;
00109     } else if (*k < 0 || *k > *m) {
00110         *info = -3;
00111     } else if (*lda < max(1,*m)) {
00112         *info = -5;
00113     }
00114     if (*info != 0) {
00115         i__1 = -(*info);
00116         xerbla_("SORGL2", &i__1);
00117         return 0;
00118     }
00119 
00120 /*     Quick return if possible */
00121 
00122     if (*m <= 0) {
00123         return 0;
00124     }
00125 
00126     if (*k < *m) {
00127 
00128 /*        Initialise rows k+1:m to rows of the unit matrix */
00129 
00130         i__1 = *n;
00131         for (j = 1; j <= i__1; ++j) {
00132             i__2 = *m;
00133             for (l = *k + 1; l <= i__2; ++l) {
00134                 a[l + j * a_dim1] = 0.f;
00135 /* L10: */
00136             }
00137             if (j > *k && j <= *m) {
00138                 a[j + j * a_dim1] = 1.f;
00139             }
00140 /* L20: */
00141         }
00142     }
00143 
00144     for (i__ = *k; i__ >= 1; --i__) {
00145 
00146 /*        Apply H(i) to A(i:m,i:n) from the right */
00147 
00148         if (i__ < *n) {
00149             if (i__ < *m) {
00150                 a[i__ + i__ * a_dim1] = 1.f;
00151                 i__1 = *m - i__;
00152                 i__2 = *n - i__ + 1;
00153                 slarf_("Right", &i__1, &i__2, &a[i__ + i__ * a_dim1], lda, &
00154                         tau[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
00155             }
00156             i__1 = *n - i__;
00157             r__1 = -tau[i__];
00158             sscal_(&i__1, &r__1, &a[i__ + (i__ + 1) * a_dim1], lda);
00159         }
00160         a[i__ + i__ * a_dim1] = 1.f - tau[i__];
00161 
00162 /*        Set A(i,1:i-1) to zero */
00163 
00164         i__1 = i__ - 1;
00165         for (l = 1; l <= i__1; ++l) {
00166             a[i__ + l * a_dim1] = 0.f;
00167 /* L30: */
00168         }
00169 /* L40: */
00170     }
00171     return 0;
00172 
00173 /*     End of SORGL2 */
00174 
00175 } /* sorgl2_ */


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