Should we use boost::math::log1p/expm1 instead of rtl_math_log1p/expm1 ?
Andrew Douglas Pitonyak
andrew at pitonyak.org
Mon Sep 15 16:49:21 PDT 2014
On 09/15/2014 03:38 PM, julien2412 wrote:
> Hello,
>
> Following
> http://cgit.freedesktop.org/libreoffice/core/commit/?id=a3ad01dc1e07da21182077bd899094fd73f57714,
> should it worth it to replace rtl_math_log1p/rtl_math_expm1 and related by
> boost::math::log1p/expm1 ?
> Or should we let the code as it is right now?
>
> Since we already use Boost, I thought it could be interesting to use it even
> more, waiting by a even more C++11 compatibility (since this standard
> includes these 2 functions).
>
> Julien
>
>
>
> --
> View this message in context: http://nabble.documentfoundation.org/Should-we-use-boost-math-log1p-expm1-instead-of-rtl-math-log1p-expm1-tp4122334.html
> Sent from the Dev mailing list archive at Nabble.com.
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
Julien, I am curious if you have done any testing. On a whim, I ran the
following on my 64-bit Fedora machine using g++.
#include <boost/math/special_functions/log1p.hpp>
#include <boost/math/special_functions/expm1.hpp>
#include <iostream>
#include <math.h>
int main()
{
double min_x = -0.2;
double max_x = 0.2;
long max_its = 10000000;
double delta_x = (max_x - min_x) / (max_its - 1);
double x;
double d;
long i;
for (i=0; i<max_its; ++i) {
x = min_x + i * delta_x;
d = fabs(log1p(x) - boost::math::log1p(x));
if (d > 0.0) {
std::cout << "1. diff(" << x << ") = " << d << std::endl;
}
}
for (i=0; i<max_its; ++i) {
x = min_x + i * delta_x;
d = fabs(expm1(x) - boost::math::expm1(x));
if (d > 0.0) {
std::cout << "2. diff(" << x << ") = " << d << std::endl;
}
}
std::cout << "Finished!" << std::endl;
return 0;
}
No differences were found in this little test. Then again, on Fedora,
Boost may be configured to use the built-in implementation, I don't
really know. I did not check our source code, but, it might reduce the
LO code complexity a little bit, that might be a gain.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
More information about the LibreOffice
mailing list