[Shootout-list] LOC
Jon Harrop
jon@ffconsultancy.com
Sun, 1 May 2005 14:01:57 +0100
On Sunday 01 May 2005 04:23, Ben Hinkle wrote:
> Looking at the C++ version of the same benchmark there's the function:
>
> void eval_AtA_times_u(const vector<double> &u, vector<double> &AtAu)
> { vector<double> v(u.size()); eval_A_times_u(u, v); eval_At_times_u(v,
> AtAu); }
Yes, the OCaml version of the same benchmark has some similar peculiarities.
let u = Array.make n 1.0
and v = Array.make n 0.0 in
should be:
let u = Array.make n 1.0 and v = Array.make n 0.0 in
and:
for j = 0 to n do v.(i) <- v.(i) +. eval_A i j *. u.(j) done
should probably be:
for j = 0 to n do
v.(i) <- v.(i) +. eval_A i j *. u.(j)
done
I've reformatted the OCaml harmonic benchmark, making it a few lines shorter.
Surprisingly, this also made it twice as fast on my computer.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists