Say I have a floating point value x taht is in the range [TINY…BIG].Now I want to take the square root of x and map it to an integer using a log scale.Of course I coudl do this:

f=sqrt(x);

i=(int)floor((float)MAX_VAL*((log(f)-log(TINY))/(log(BIG)-log(TINY))));

That will take the sqrt of x and map it to an integer from 0 to MAX_VAL.That’s what I’m doing now but it’s slow.What I want to do is use the lookup table to do the sqrts and logs.Problem is how do I do that for the range {TINY…BIG].Does anybody know of any on-line docs about lookup tables?Thanks in advance for any help.

There’s a LUT based sqrt function in nvidias collection of fast math routines on their dev-rel site. If the numbers you plug into the sqrt aren’t very regular though, you probably won’t get much of a speedup, at least on newer CPUs.

I’ve seen a LUT based sqrt calculator(propably the same as the one you mention) but I think that the work quite differently,and for any floating point nimber.I need a way of making a table that will give me the outcome of the above function(which is an int between 0 and MAX_VAL) for a range of [1e-6…1e4].The floats in this range would have to somehow be converted to ints though to be useable as table indices.These are my main two problems.It’s strange that I can’t find any usefull info on it on the web.Looks like a major optimization to me.

Since you want to take the log of a value that you previously took the square root of, you can eliminate the square root all together since the log(sqrt(x))=.5*log(x)

Also consider using a base two log, followed by a multiplication to get the values to the right base.