Hi Eike,

Eike Rathke schrieb:
Hi Regina,

I was on sick leave, hence the silence.

I hope you are fit again.

On Tuesday, 2008-07-01 14:16:08 +0200, Regina Henschel wrote:

I'm searching for the functions log1p and expm1 in OOo. The function log1p(x) returns log(1+x) for x near 0, and expm1(x) returns exp(x)-1 for x near 0.

C99 compliant compilers should provide them with their math libraries.
GCC and Sun Studio have it, your question sounds as if MSVC does not.

Right, at least the MSVC 9.0 Express version doesn't provide it.

AFAIK Boost provides those functions as well, don't know if the template
works out of the box or would need some Boost library compiled and
linked.

I've got an ersatz, but I'd be surprised if it was not implemented yet.

If it is really not implemented, I need to know whether my ersatz will work on other compilers than MS Visual Express 9. Can anyone help with that?

It might be that no other supported platform than MSVC would need it..

#ifdef __MSC_VER
double log1p( double x ) { ... }
#endif

may be sufficient.

But then I think, it should get a more common place than in the interpr*-files.

 However, I'd try the Boost implementation first, that
might save worries.

I use now the ersatz

double lcl_log1p(double fX)
{
double fU = 1.0+fX;
if (fU == 1.0)
    return fX;
else
    return log(fU)*fX/(fU-1);
}

found in the article "What Every Computer Scientist Should Know About Floating-Point Arithmetic" which you mentioned in the other thread.

and

double lcl_expm1(double fX)
{
    return tanh(fX/2)*(exp(fX)+1);
}

which I found as tip on http://www.plunk.org/~hatch/rightway.php. He gives also a version from which he says, it is from Kahan, but I have not tested the other.

kind regards
Regina

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to