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