David VanHorn schrieb:
Speed is primary, I need to get the conversion absolutely as fast as
possible.
Accuracy is secondary.
Once I have the logs, the rest of the calculation would be fixed point.
My output will be a 16 bit binary value, the sum of N log values.
My question comes down to wether it is possible to get the preprocessor to
define the values in some form like I described previously.
If not, I'll generate them externally.
No, cpp can't do that and you cannot make a function call in an
initializer. So you either have to write a little code generator,
language is a matter of your taste, type the values by hand, or compute
them at runtime.
FYI, computing log at runtime for low precision and limited ranges can
easily be done by means of an almost trivial method as described in
http://de.wikipedia.org/wiki/Logarithmus#Berechnung_einzelner_Bin.C3.A4rziffern
Sorry for the german article, there is no english analogon. What is
going on should be clear from the source example. The case log(0) that
you want must be handeled explicitely.
With help of that algorithm you can compute logarithmus dualis on the
fly (will cost time comparable to a 16/16 integer division, and minimal
flash costs). You can also initialize a lookup-table in RAM from within
a constructor (__attribute__((constructor)), which is gcc specific).
So there are plenty of approaches to solve this.
Georg-Johann
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list