Re:Fast Approximate Logarithms, Part I: The Basics
by dalke on Saturday May 09, 2015 @11:42PM
(#9518703)
Indeed, you're right. I forgot about step-function solutions, and thought interpolation/corrections were needed.
512 elements for 7 bits of accuracy sounds reasonable. The article mentioned a 2x improvement for 11 bits, but didn't get to that point.
The table size required to beat the accuracy of fastlog2 is 512 elements.
edit: The speed ratio is actually about 0.6 in favor of look-up versus fastlog2. Enabling -O3 changes the ratio to 0,9. This is of course not measured in a real-world program where the cache is shared by other stuff.
edit2: I have removed the if statement from fastlog2 and compiled with -O3. The ratio was 1,2.