dlarf.c
Go to the documentation of this file.
00001 /* dlarf.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 doublereal c_b4 = 1.;
00019 static doublereal c_b5 = 0.;
00020 static integer c__1 = 1;
00021 
00022 /* Subroutine */ int dlarf_(char *side, integer *m, integer *n, doublereal *v, 
00023          integer *incv, doublereal *tau, doublereal *c__, integer *ldc, 
00024         doublereal *work)
00025 {
00026     /* System generated locals */
00027     integer c_dim1, c_offset;
00028     doublereal d__1;
00029 
00030     /* Local variables */
00031     integer i__;
00032     logical applyleft;
00033     extern /* Subroutine */ int dger_(integer *, integer *, doublereal *, 
00034             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00035             integer *);
00036     extern logical lsame_(char *, char *);
00037     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00038             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00039             doublereal *, doublereal *, integer *);
00040     integer lastc, lastv;
00041     extern integer iladlc_(integer *, integer *, doublereal *, integer *), 
00042             iladlr_(integer *, integer *, doublereal *, integer *);
00043 
00044 
00045 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  DLARF applies a real elementary reflector H to a real m by n matrix */
00058 /*  C, from either the left or the right. H is represented in the form */
00059 
00060 /*        H = I - tau * v * v' */
00061 
00062 /*  where tau is a real scalar and v is a real vector. */
00063 
00064 /*  If tau = 0, then H is taken to be the unit matrix. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  SIDE    (input) CHARACTER*1 */
00070 /*          = 'L': form  H * C */
00071 /*          = 'R': form  C * H */
00072 
00073 /*  M       (input) INTEGER */
00074 /*          The number of rows of the matrix C. */
00075 
00076 /*  N       (input) INTEGER */
00077 /*          The number of columns of the matrix C. */
00078 
00079 /*  V       (input) DOUBLE PRECISION array, dimension */
00080 /*                     (1 + (M-1)*abs(INCV)) if SIDE = 'L' */
00081 /*                  or (1 + (N-1)*abs(INCV)) if SIDE = 'R' */
00082 /*          The vector v in the representation of H. V is not used if */
00083 /*          TAU = 0. */
00084 
00085 /*  INCV    (input) INTEGER */
00086 /*          The increment between elements of v. INCV <> 0. */
00087 
00088 /*  TAU     (input) DOUBLE PRECISION */
00089 /*          The value tau in the representation of H. */
00090 
00091 /*  C       (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
00092 /*          On entry, the m by n matrix C. */
00093 /*          On exit, C is overwritten by the matrix H * C if SIDE = 'L', */
00094 /*          or C * H if SIDE = 'R'. */
00095 
00096 /*  LDC     (input) INTEGER */
00097 /*          The leading dimension of the array C. LDC >= max(1,M). */
00098 
00099 /*  WORK    (workspace) DOUBLE PRECISION array, dimension */
00100 /*                         (N) if SIDE = 'L' */
00101 /*                      or (M) if SIDE = 'R' */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Subroutines .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. Executable Statements .. */
00114 
00115     /* Parameter adjustments */
00116     --v;
00117     c_dim1 = *ldc;
00118     c_offset = 1 + c_dim1;
00119     c__ -= c_offset;
00120     --work;
00121 
00122     /* Function Body */
00123     applyleft = lsame_(side, "L");
00124     lastv = 0;
00125     lastc = 0;
00126     if (*tau != 0.) {
00127 /*     Set up variables for scanning V.  LASTV begins pointing to the end */
00128 /*     of V. */
00129         if (applyleft) {
00130             lastv = *m;
00131         } else {
00132             lastv = *n;
00133         }
00134         if (*incv > 0) {
00135             i__ = (lastv - 1) * *incv + 1;
00136         } else {
00137             i__ = 1;
00138         }
00139 /*     Look for the last non-zero row in V. */
00140         while(lastv > 0 && v[i__] == 0.) {
00141             --lastv;
00142             i__ -= *incv;
00143         }
00144         if (applyleft) {
00145 /*     Scan for the last non-zero column in C(1:lastv,:). */
00146             lastc = iladlc_(&lastv, n, &c__[c_offset], ldc);
00147         } else {
00148 /*     Scan for the last non-zero row in C(:,1:lastv). */
00149             lastc = iladlr_(m, &lastv, &c__[c_offset], ldc);
00150         }
00151     }
00152 /*     Note that lastc.eq.0 renders the BLAS operations null; no special */
00153 /*     case is needed at this level. */
00154     if (applyleft) {
00155 
00156 /*        Form  H * C */
00157 
00158         if (lastv > 0) {
00159 
00160 /*           w(1:lastc,1) := C(1:lastv,1:lastc)' * v(1:lastv,1) */
00161 
00162             dgemv_("Transpose", &lastv, &lastc, &c_b4, &c__[c_offset], ldc, &
00163                     v[1], incv, &c_b5, &work[1], &c__1);
00164 
00165 /*           C(1:lastv,1:lastc) := C(...) - v(1:lastv,1) * w(1:lastc,1)' */
00166 
00167             d__1 = -(*tau);
00168             dger_(&lastv, &lastc, &d__1, &v[1], incv, &work[1], &c__1, &c__[
00169                     c_offset], ldc);
00170         }
00171     } else {
00172 
00173 /*        Form  C * H */
00174 
00175         if (lastv > 0) {
00176 
00177 /*           w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1) */
00178 
00179             dgemv_("No transpose", &lastc, &lastv, &c_b4, &c__[c_offset], ldc, 
00180                      &v[1], incv, &c_b5, &work[1], &c__1);
00181 
00182 /*           C(1:lastc,1:lastv) := C(...) - w(1:lastc,1) * v(1:lastv,1)' */
00183 
00184             d__1 = -(*tau);
00185             dger_(&lastc, &lastv, &d__1, &work[1], &c__1, &v[1], incv, &c__[
00186                     c_offset], ldc);
00187         }
00188     }
00189     return 0;
00190 
00191 /*     End of DLARF */
00192 
00193 } /* dlarf_ */


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