Hello All, Can anyone please help me in implementing exp10(x) in a fixed point C. I need to convert a dB value ( 0 to 50 dB) to linear domain value. This is for a 16-bit DSP application. Thanks and Regards, Patrick
fixed point exp10(x)
Started by ●October 3, 2005
Reply by ●October 5, 20052005-10-05
pth10312002@yahoo.com wrote:> Hello All, > > > Can anyone please help me in implementing exp10(x) in a fixed point C. > I need to convert a dB value ( 0 to 50 dB) to linear domain value. This > is for a 16-bit DSP application. > > > Thanks and Regards, > > PatrickIf it's no time constraint then it's trivial, so I suspect it is student homework. If it is, then you might need somebody with function approximation experience, would you consider paying for the job? Adrian
Reply by ●October 5, 20052005-10-05
<pth10312002@yahoo.com> wrote in message news:1128364805.477691.282990@g49g2000cwa.googlegroups.com...> Hello All, > > Can anyone please help me in implementing exp10(x) in a fixed point C. > I need to convert a dB value ( 0 to 50 dB) to linear domain value. This > is for a 16-bit DSP application. > > Thanks and Regards, > > Patrickeasy. outputVal = exp10Table[ inputVal ]; very fast, too. Of course, exp10Table will consume 128k bytes. Is that a problem? ;-) If you can spare the time for a MAC or two (or three), the lookup tables can be *tiny*. The first step in coding any integer approximation function is usually writing the desired function using floating point. (You'll need to test your integer code against it.) e.g. int16 LibFunc( int16 inVal ) { return (int)( 65535* whateverFunction((float)(inVal) / 256.0)); } Bob
Reply by ●October 5, 20052005-10-05
Adrian, thanks for reply. I was hoping someone in this group had run into this problem before and may be willing to discuss any issues/difficulty on the complexity and precision. It is for a real time application but doesnt have to be super fast (to be written in C). I am looking for advice/pointers to tackle the problem and I will do the simulation my self. Sorry if I sounds like a cheap person trying to look for freebee on the net. Currently I plan to use the 2nd order polynomial approximation but not happy with the max. error. Patrick
Reply by ●October 5, 20052005-10-05
Bob wrote:> <pth10312002@yahoo.com> wrote in message > news:1128364805.477691.282990@g49g2000cwa.googlegroups.com... >> Hello All, >> >> Can anyone please help me in implementing exp10(x) in a fixed point C. >> I need to convert a dB value ( 0 to 50 dB) to linear domain value. This >> is for a 16-bit DSP application. >> >> Thanks and Regards, >> >> Patrick > > easy. > > outputVal = exp10Table[ inputVal ]; > > very fast, too. > > Of course, exp10Table will consume 128k bytes. Is that a problem? ;-) > If you can spare the time for a MAC or two (or three), the lookup tables > can be *tiny*. The first step in coding any integer approximation function > is usually writing the desired function using floating point. (You'll need > to test your integer code against it.) > > e.g. > int16 LibFunc( int16 inVal ) > { return (int)( 65535* whateverFunction((float)(inVal) / 256.0)); } > > BobNot quite integer... Patrick was talking about fixed point. And in the second post he mentioned "precision", 128 values might not be enough. But the table method is not a bad idea, I was actually thinking about table lookup and interpolation. Adrian
Reply by ●October 5, 20052005-10-05
Hi What polynomial are you using for approximation? You are better off using the Chebyshev polynomial which has the minmax property (minimizes the maximum error). But of course the problem is that the Chebyshev polynomial is based on non-uniform sampling points and if your samples are uniformly sampled then you would notice a slightly different error pattern than the theoretical one. You can take a look at some of the approximation results (unfortunately only exp(x) can be found) that I have done for various functions using chebyshev polynomial. the plots show the performance of both fixed point (Q-15 or Q31) and floating-point(double precision). I have used Horner's algoithm in this case to implement the polynomial. http://utdallas.edu/~nithinr/EE6481_project_report.doc I had done this a while back. I have seen that if you use the least squares approximation the error is much 'noisier' (oscillatory pattern) but the max. error is higher. Hope this helps Nithin pth10312002@yahoo.com wrote:> Adrian, thanks for reply. > I was hoping someone in this group had run into this problem before and > may be willing to discuss any issues/difficulty on the complexity and > precision. > It is for a real time application but doesnt have to be super fast (to > be written in C). I am looking for advice/pointers to tackle the > problem and I will do the simulation my self. Sorry if I sounds like a > cheap person trying to look for freebee on the net. > Currently I plan to use the 2nd order polynomial approximation but not > happy with the max. error. > > Patrick
Reply by ●October 5, 20052005-10-05
"Adrian Spilca" <adsp40@spamGuard_yahoo.co.uk> wrote in message news:di13d0$i5m$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...> Bob wrote: > > > <pth10312002@yahoo.com> wrote in message > > news:1128364805.477691.282990@g49g2000cwa.googlegroups.com... > >> Hello All, > >> > >> Can anyone please help me in implementing exp10(x) in a fixed point C. > >> I need to convert a dB value ( 0 to 50 dB) to linear domain value. This > >> is for a 16-bit DSP application. > >> > >> Thanks and Regards, > >> > >> Patrick > > > > easy. > > > > outputVal = exp10Table[ inputVal ]; > > > > very fast, too. > > > > Of course, exp10Table will consume 128k bytes. Is that a problem? ;-) > > If you can spare the time for a MAC or two (or three), the lookup tables > > can be *tiny*. The first step in coding any integer approximationfunction> > is usually writing the desired function using floating point. (You'llneed> > to test your integer code against it.) > > > > e.g. > > int16 LibFunc( int16 inVal ) > > { return (int)( 65535* whateverFunction((float)(inVal) / 256.0)); } > > > > Bob > > Not quite integer... Patrick was talking about fixed point. > And in the second post he mentioned "precision", 128 values might not be > enough. > > But the table method is not a bad idea, I was actually thinking abouttable> lookup and interpolation. > > AdrianHi Adrian, Yes, I made some pretty wild assumptions since Patrick hasn't really defined the problem (how many bits wide and where is the radix of the input and output? How much error is tolerable? How many MACs can he afford?). If you assume 16bit in and 16bit out (doesn't matter what the bits represent - fixed, float, Spanish, etc.) then a 64k*2byte table *will* do it in a single lookup op. You'ld have to be awfully short on time and long on space to do it that way, though ;-) Bob hint to Patrick: convert your dB to bB (binaryBell - not deciBell). The exp2 is easier than exp10 in a binary world.