Oops, a bit of a rookie error. Thanks John.
So to summarise for those that search the archives:
As per "Link Your Program to a Boost program" (
http://www.boost.org/doc/libs/1_45_0/more/getting_started/unix-variants.html...),
and other basic gcc/g++ documentation, the example "Using with MPR / GMP - a
High-Precision Floating-Point Library" (
http://www.boost.org/doc/libs/1_45_0/libs/math/doc/sf_and_dist/html/math_too...
):
boost_mpfr_example.cpp:
#include
#include
int main()
{
mpfr_class::set_dprec(500); // 500 bit precision
//
// Note that the argument to tgamma is an expression template,
// that's just fine here:
//
mpfr_class v = boost::math::tgamma(sqrt(mpfr_class(2)));
std::cout << std::setprecision(50) << v << std::endl;
}
Should be compiled and linked with the following command:
g++ -I/path/to/boost_1_45_0 boost_mpfr_example.cpp -o boost_mpfr_example
-lgmpfrxx -lmpfr -lgmpxx -lgmp
On Ubuntu 10.10 the following packages (or source) are needed:
- MPFR 3.0.0-2 (ubuntu packages: libmpfr-dev, libmpfr4),
- gmp 4.3.2 (libgmp3-dev, libgmp3c2, libgmpxx4ldbl),
- gmpfrxx (http://math.berkeley.edu/~wilken/code/gmpfrxx/).
Running ./boost_mpfr_example should give:
8.8658142871925912508091761239199431116828551763805e-1
cheers,
Novak.