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