avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] tanh in libm


From: E. Weddington
Subject: Re: [avr-libc-dev] tanh in libm
Date: Wed, 15 Sep 2004 10:18:01 -0600
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

René Liebscher wrote:

Hi,

I have question about the tanh function in libm.

As I can see in
http://savannah.nongnu.org/cgi-bin/viewcvs/avr-libc/avr-libc/libm/fplib/tanh.S?rev=1.2&content-type=text/vnd.viewcvs-markup
there are two ways to calculate the result.

The questions is why was sinh/cosh choosen. (The other way is commented out.) Comparing which functions are called to calculate tanh I find sinh/cosh needs one call to exp, two calls to inverse and one call to ldexp more than the other way. So I think the current solution is slower than the other.
(And it takes more memory if you don't use sinh or cosh in your program.)


AFAIK, the whole math library in avr-libc was a port of Michael Stumpf's FPLib library to the AVR. See the readme.fplib file in CVS:
<http://savannah.nongnu.org/cgi-bin/viewcvs/avr-libc/avr-libc/libm/fplib/readme.fplib?rev=1.1&content-type=text/vnd.viewcvs-markup>
So a lot of the decisions on how to do things were very likely his.


If the other solution brings also correct results and is faster, is there a simple way to integrate it in my program without to recompile the math library.


Probably only if you're making your own tanh function then you wouldn't have to recompile the library. Obviously if you wanted it to be a part of the library then it would have to be rebuilt.

HTH
Eric




reply via email to

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