Re: How to calculate a square root of an integer fast?
<xgl99@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1117899613.758035.37020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> hi all,
> I am now using an algorithm here
>
http://astronomy.swin.edu.au/~pbourke/analysis/sqrt/
> But I find it is slower than float version of sqrt() in the
> standard C library.
> Can anyone point to me a integer version of square root algorithm which
> is fast and utilize hardware optimization. I am working on Intel P4
> CPU.
> Thanks in advance
Assuming you're not too worried about problems due to slight inaccuracy of
floating-point, the quickest way is probably to do it with floats and then
convert. SSE2 includes a SIMD floating point square root instruction -
you'll find it hard to beat that.
Alun Harford
--
Include the word 'lemongrass' in any email you send to me, or you'll hit my
spam filter. If you're reading archives, I may have changed this word -
check
http://www.alunharford.co.uk/
.
Relevant Pages
- Re: Standard Deviation
... Depending on the input data, this might be int64, extended, or perhaps even a large integer or large float class. ... If you look at the formula, you will see that the value for the SS is computed as a relatively small difference between two numbers that can become very large if the number of values thrown at the algorithm is very large. ... After the loop the average needs no further adjustment, while Std contains the sum of squares and needs to be adjusted if you want the standard deviation. ... (borland.public.delphi.non-technical) - Re: Square root algorithms and complexity
... > I developed an algorithm which includes multiplications,addistions, ... > and the computation of a square root. ... > number of multiplications that the algorithm performs, ... >> computing the square root using a specified algorithm? ... (sci.math) - Re: How do I rotate a bitmap fast with high quality?
... and change float to int using fixed point algorithm. ... I want to know a new algorithm, with high quality and faster speed. ... using a BitBlt to copy *a single pixel* from one image to ... (comp.graphics.algorithms) - Checking square root algorithm for portability/correctness
... I posted a thread on comp.programming awhile back asking about an algorithm ... I implemented on square root. ... prime number as a convenient way to get a pseudorandom number generator. ... iterations could be arbitrary. ... (comp.lang.c) - Re: Fast Cube Root Using C33
... that only works with IEEE floating point and not with TI floating point. ... The obvious solution is to convert the TI float to the IEEE ... float, apply the hack, and then convert back to TI float but there must ... For those of you under 80, it's basically a method for churning out decimals of the square root of a number in a method very akin to long division, except that at each step instead of subtracting (cumulative ... (comp.dsp) |
|