in reply to Re: Processing data with lot of math...
in thread Processing data with lot of math...

Why use sqrt? There is no added value in it; instead, transform the cutoff value.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Re: Re: Processing data with lot of math...
by ysth (Canon) on May 12, 2004 at 23:14 UTC
    Because there's no point in optimizing until you have triaged your algorithm (irremedially slow, a little too slow, or fast enough). If I were certain what form the original questioner's points stored in, I would have even used a distance() sub. Code should be written for minimum conceptual complexity and then optimized only if needed, and having a separate $cutoff_squared checking against a square distance is beyond my minimum. YMMV.

    Update: the above is obviously hypocritical; I get sucked into premature optimization and complexity fascination all the time.

      Oops, my reply lies above. Please forgive me this time. Was not aware what I was doing..., presumed that the reply will come at the bottom. :)