00001 /* sorm2r.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 sorm2r_(char *side, char *trans, integer *m, integer *n, 00021 integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, 00022 real *work, integer *info) 00023 { 00024 /* System generated locals */ 00025 integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2; 00026 00027 /* Local variables */ 00028 integer i__, i1, i2, i3, ic, jc, mi, ni, nq; 00029 real aii; 00030 logical left; 00031 extern logical lsame_(char *, char *); 00032 extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, 00033 integer *, real *, real *, integer *, real *), xerbla_( 00034 char *, integer *); 00035 logical notran; 00036 00037 00038 /* -- LAPACK routine (version 3.2) -- */ 00039 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00040 /* November 2006 */ 00041 00042 /* .. Scalar Arguments .. */ 00043 /* .. */ 00044 /* .. Array Arguments .. */ 00045 /* .. */ 00046 00047 /* Purpose */ 00048 /* ======= */ 00049 00050 /* SORM2R overwrites the general real m by n matrix C with */ 00051 00052 /* Q * C if SIDE = 'L' and TRANS = 'N', or */ 00053 00054 /* Q'* C if SIDE = 'L' and TRANS = 'T', or */ 00055 00056 /* C * Q if SIDE = 'R' and TRANS = 'N', or */ 00057 00058 /* C * Q' if SIDE = 'R' and TRANS = 'T', */ 00059 00060 /* where Q is a real orthogonal matrix defined as the product of k */ 00061 /* elementary reflectors */ 00062 00063 /* Q = H(1) H(2) . . . H(k) */ 00064 00065 /* as returned by SGEQRF. Q is of order m if SIDE = 'L' and of order n */ 00066 /* if SIDE = 'R'. */ 00067 00068 /* Arguments */ 00069 /* ========= */ 00070 00071 /* SIDE (input) CHARACTER*1 */ 00072 /* = 'L': apply Q or Q' from the Left */ 00073 /* = 'R': apply Q or Q' from the Right */ 00074 00075 /* TRANS (input) CHARACTER*1 */ 00076 /* = 'N': apply Q (No transpose) */ 00077 /* = 'T': apply Q' (Transpose) */ 00078 00079 /* M (input) INTEGER */ 00080 /* The number of rows of the matrix C. M >= 0. */ 00081 00082 /* N (input) INTEGER */ 00083 /* The number of columns of the matrix C. N >= 0. */ 00084 00085 /* K (input) INTEGER */ 00086 /* The number of elementary reflectors whose product defines */ 00087 /* the matrix Q. */ 00088 /* If SIDE = 'L', M >= K >= 0; */ 00089 /* if SIDE = 'R', N >= K >= 0. */ 00090 00091 /* A (input) REAL array, dimension (LDA,K) */ 00092 /* The i-th column must contain the vector which defines the */ 00093 /* elementary reflector H(i), for i = 1,2,...,k, as returned by */ 00094 /* SGEQRF in the first k columns of its array argument A. */ 00095 /* A is modified by the routine but restored on exit. */ 00096 00097 /* LDA (input) INTEGER */ 00098 /* The leading dimension of the array A. */ 00099 /* If SIDE = 'L', LDA >= max(1,M); */ 00100 /* if SIDE = 'R', LDA >= max(1,N). */ 00101 00102 /* TAU (input) REAL array, dimension (K) */ 00103 /* TAU(i) must contain the scalar factor of the elementary */ 00104 /* reflector H(i), as returned by SGEQRF. */ 00105 00106 /* C (input/output) REAL array, dimension (LDC,N) */ 00107 /* On entry, the m by n matrix C. */ 00108 /* On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */ 00109 00110 /* LDC (input) INTEGER */ 00111 /* The leading dimension of the array C. LDC >= max(1,M). */ 00112 00113 /* WORK (workspace) REAL array, dimension */ 00114 /* (N) if SIDE = 'L', */ 00115 /* (M) if SIDE = 'R' */ 00116 00117 /* INFO (output) INTEGER */ 00118 /* = 0: successful exit */ 00119 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00120 00121 /* ===================================================================== */ 00122 00123 /* .. Parameters .. */ 00124 /* .. */ 00125 /* .. Local Scalars .. */ 00126 /* .. */ 00127 /* .. External Functions .. */ 00128 /* .. */ 00129 /* .. External Subroutines .. */ 00130 /* .. */ 00131 /* .. Intrinsic Functions .. */ 00132 /* .. */ 00133 /* .. Executable Statements .. */ 00134 00135 /* Test the input arguments */ 00136 00137 /* Parameter adjustments */ 00138 a_dim1 = *lda; 00139 a_offset = 1 + a_dim1; 00140 a -= a_offset; 00141 --tau; 00142 c_dim1 = *ldc; 00143 c_offset = 1 + c_dim1; 00144 c__ -= c_offset; 00145 --work; 00146 00147 /* Function Body */ 00148 *info = 0; 00149 left = lsame_(side, "L"); 00150 notran = lsame_(trans, "N"); 00151 00152 /* NQ is the order of Q */ 00153 00154 if (left) { 00155 nq = *m; 00156 } else { 00157 nq = *n; 00158 } 00159 if (! left && ! lsame_(side, "R")) { 00160 *info = -1; 00161 } else if (! notran && ! lsame_(trans, "T")) { 00162 *info = -2; 00163 } else if (*m < 0) { 00164 *info = -3; 00165 } else if (*n < 0) { 00166 *info = -4; 00167 } else if (*k < 0 || *k > nq) { 00168 *info = -5; 00169 } else if (*lda < max(1,nq)) { 00170 *info = -7; 00171 } else if (*ldc < max(1,*m)) { 00172 *info = -10; 00173 } 00174 if (*info != 0) { 00175 i__1 = -(*info); 00176 xerbla_("SORM2R", &i__1); 00177 return 0; 00178 } 00179 00180 /* Quick return if possible */ 00181 00182 if (*m == 0 || *n == 0 || *k == 0) { 00183 return 0; 00184 } 00185 00186 if (left && ! notran || ! left && notran) { 00187 i1 = 1; 00188 i2 = *k; 00189 i3 = 1; 00190 } else { 00191 i1 = *k; 00192 i2 = 1; 00193 i3 = -1; 00194 } 00195 00196 if (left) { 00197 ni = *n; 00198 jc = 1; 00199 } else { 00200 mi = *m; 00201 ic = 1; 00202 } 00203 00204 i__1 = i2; 00205 i__2 = i3; 00206 for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) { 00207 if (left) { 00208 00209 /* H(i) is applied to C(i:m,1:n) */ 00210 00211 mi = *m - i__ + 1; 00212 ic = i__; 00213 } else { 00214 00215 /* H(i) is applied to C(1:m,i:n) */ 00216 00217 ni = *n - i__ + 1; 00218 jc = i__; 00219 } 00220 00221 /* Apply H(i) */ 00222 00223 aii = a[i__ + i__ * a_dim1]; 00224 a[i__ + i__ * a_dim1] = 1.f; 00225 slarf_(side, &mi, &ni, &a[i__ + i__ * a_dim1], &c__1, &tau[i__], &c__[ 00226 ic + jc * c_dim1], ldc, &work[1]); 00227 a[i__ + i__ * a_dim1] = aii; 00228 /* L10: */ 00229 } 00230 return 0; 00231 00232 /* End of SORM2R */ 00233 00234 } /* sorm2r_ */