Mathematica 7 compares to other languages

Daniel Fetchinson fetchinson at googlemail.com
Wed Dec 10 18:11:35 EST 2008


On 12/10/08, Jon Harrop <jon at ffconsultancy.com> 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



More information about the Python-list mailing list