
Calculate exp() and log() without multiplication - soundsop
http://www.quinapalus.com/efunc.html
======
DarkShikari
While this method is interesting, a LUT is often better, especially in cases
where you have a limited range or only need limited precision.

See
[http://git.videolan.org/?p=x264.git;a=commitdiff;h=549cc55b5...](http://git.videolan.org/?p=x264.git;a=commitdiff;h=549cc55b50df76d5167c0ace75c62595feb753ca)
.

------
dxjones
all those if's, no else's, ... looks like there is still room for
optimization.

... and, pipelined CPU's dislike branching code. Are there tricks to do the
same computation with fewer branches?

~~~
jws
In the ARM there will not be branches. The sequences are short enough that
conditional execution can be used. The deeply pipelined (x86 and such)
processors have fast multiplies.

This looks especially handy for embedded processors. I was planning to use a
lookup table and linear interpolation in an upcoming project to approximate
log on an AVR, but I think I'll go with this instead.

The use of the comma operator is interesting.

~~~
pmjordan
_The use of the comma operator is interesting._

Interesting? Meh. It's the difference between

    
    
      if (foo) { a = x; b = y; }
    

and

    
    
      if (foo) a = x, b = y;
    

So it's purely used as a notational quirk.

For loops and similar situations are when the comma operator really comes in
handy - although you _really_ need to watch out for the rule of not assigning
to the same variable more than once before a sequence point, especially as
many compilers will only warn you about it at highest warning level - or not
at all.

