Le mercredi 2 janvier 2008, Bruno Haible a écrit : > Hello, > > Bastien Roucaries wrote: > > I need for my program to use asinh acosh and atanh. For now I used to > > define > > > > it if missing using > > #define asinh(x) log(x+sqrt(x*x+1)) > > #define acosh(x) log(x+sqrt(x-1.0)*sqrt(x+1.0)) > > #define atanh(x) (0.5*log(x+1)-0.5*log(1-x)) > > > > How can I create a gnulib module in order to do that? > > First, look in the gnulib documentation which portability problems are > already known and which of them are already handled by gnulib. In this > case, you see that the problem is that mingw does not provide the > functions, and that gnulib provides no workaround so far.
I have done that. > Second, decide which include file should declare the functions. POSIX says > <math.h> in this case; in gnulib the source code of this file is in > lib/math.in.h. Try to write the declarations here. Add the proper autoconf > tests; see e.g. how it was done for the 'trunc' function or some other > functions. I have added the proper autoconf test > Third, write an implementation of these functions that is portable enough; > each function it its own file. I need isfinite how can I do that? It is a dependancy I suppose but I do not know how to declare it... Could you explain how can I do? > The formula you gave for asinh(x) is ok for x >= 0; for x < 0 it is > unusable since it will lead to numerical instability (i.e. rounding errors > that are far too big). > > The formula you gave for acosh(x) may be ok, but is it necessary to call > sqrt twice? > > The formula you gave for atanh(x): similarly, it is necessary to call log > twice? Furthermore, for x near 0, say abs(x) < 2^-53, your formula will > return 0, which has a relative error of 100%; it's possible to do better. I will use glibc function. > Fourth, write a test suite for each function. The test suite should cover > particular values as well as special cases like +/- infinity and NaN. Ok will do > Then you can submit the patch here. Ok will > Bruno -- "ROUCARIES Bastien" [EMAIL PROTECTED] ------------------------------------------------------------------------------- DO NOT WRITE TO [EMAIL PROTECTED] OR BE BLACKLISTED