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