avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Re: Tables


From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Re: Tables
Date: Wed, 04 Mar 2009 22:24:22 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]