On 12/10/08, Jon Harrop <[EMAIL PROTECTED]> wrote: > Xah Lee wrote: >> Kaz Kylheku wrote: >>> Really? ``50 or hundreds'' of lines in C? >>> >>> #include <math.h> /* for sqrt */ >>> >>> void normalize(double *out, double *in) >>> { >>> double denom = sqrt(in[0] * in[0] + in[1] * in[1] + in[2] * >>> in[2]); >>> >>> out[0] = in[0]/denom; >>> out[1] = in[1]/denom; >>> out[2] = in[2]/denom; >>> } >>> >>> Doh? >> >> Kaz, pay attention: >> >> Xah wrote: «Note, that the "norm" as defined above works for vectors >> of any dimention, i.e. list of any length.» > > That is still only 6 lines of C code and not 50 as you claimed: > > double il = 0.0; > for (int i=0; i<n; ++i) > il += in[i] * in[i]; > il = 1.0 / sqrt(il); > for (int i=0; i<n; ++i) > out[i] = il * in[i]; > > Try computing the Fourier transform of: > > 0.007 + 0.01 I, -0.002 - 0.0024 I
Funniest thread ever! Actual real money changing hands, did this happen ever in a newsgroup? Xah Lee rulez! Xah Lee for president! (No kidding, I like the guy.) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list