mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Added mpfr docs, and updated the NTL usage docs.
Updated bindings tests to run automatically when the appropriate libraries are present. [SVN r49110]
This commit is contained in:
@@ -52,6 +52,8 @@ sph_neumann
|
||||
;
|
||||
|
||||
compile has_long_double_support.cpp ;
|
||||
compile has_mpfr_class.cpp ;
|
||||
compile has_ntl_rr.cpp ;
|
||||
|
||||
lib boost_math_tr1 : ../src/tr1/$(TR1_SOURCES).cpp
|
||||
:
|
||||
|
||||
7
build/has_mpfr_class.cpp
Normal file
7
build/has_mpfr_class.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright John Maddock 2008.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <gmpfrxx.h>
|
||||
|
||||
7
build/has_ntl_rr.cpp
Normal file
7
build/has_ntl_rr.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright John Maddock 2008.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <NTL/RR.h>
|
||||
|
||||
@@ -14,17 +14,58 @@ replacement for the "real" NTL::RR that adds some syntactic sugar to keep
|
||||
this library happy, plus some of the standard library functions not implemented
|
||||
in NTL.
|
||||
|
||||
Finally there is a high precision __lanczos suitable for use with `boost::math::ntl::RR`,
|
||||
used at 1000-bit precision in
|
||||
[@../../../tools/ntl_rr_lanczos.hpp libs/math/tools/ntl_rr_lanczos.hpp].
|
||||
The approximation has a theoretical precision of > 90 decimal digits,
|
||||
and an experimental precision of > 100 decimal digits. To use that
|
||||
approximation, just include that header before any of the special
|
||||
function headers (if you don't use it, you'll get a slower, but
|
||||
fully generic implementation for all of the gamma-like functions).
|
||||
For those functions that are based upon the __lanczos, the bindings
|
||||
defines a series of approximations with up to 61 terms and accuracy
|
||||
up to approximately 3e-113. This therefore sets the upper limit for accuracy
|
||||
to the majority of functions defined this library when used with `NTL::RR`.
|
||||
|
||||
There is a concept checking test program for NTL support
|
||||
[@../../../../../libs/math/test/ntl_concept_check.cpp here].
|
||||
|
||||
[endsect][/section:use_ntl Using With NTL - a High Precision Floating-Point Library]
|
||||
|
||||
[section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library]
|
||||
|
||||
The special functions and tools in this library can be used with
|
||||
[@http://www.mpfr.org MPFR (an arbitrary precision number type based on the GMP library)],
|
||||
via the bindings in [@../../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp].
|
||||
|
||||
In order to use these binings you will need to have installed [@http://www.mpfr.org MPFR]
|
||||
plus it's dependency the [@http://gmplib.org GMP library] and the C++ wrapper for MPFR known as
|
||||
[@http://math.berkeley.edu/~wilken/code/gmpfrxx/ gmpfrxx (or mpfr_class)].
|
||||
|
||||
Unfortunately `mpfr_class` doesn't quite satisfy our conceptual requirements,
|
||||
so there is a very thin set of additional interfaces and some helper traits defined in
|
||||
[@../../../../../boost/math/bindings/mpfr.hpp boost/math/bindings/mpfr.hpp] that you
|
||||
should use in place of including 'gmpfrxx.h' directly. The existing mpfr_class is
|
||||
then usable unchanged once this header is included, so it's performance-enhancing
|
||||
expression templates are preserved and fully supported by this library:
|
||||
|
||||
#include <boost/math/bindings/mpfr.hpp>
|
||||
#include <boost/math/special_functions/gamma.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
For those functions that are based upon the __lanczos, the bindings
|
||||
defines a series of approximations with up to 61 terms and accuracy
|
||||
up to approximately 3e-113. This therefore sets the upper limit for accuracy
|
||||
to the majority of functions defined this library when used with `mpfr_class`.
|
||||
|
||||
There is a concept checking test program for mpfr support
|
||||
[@../../../../../libs/math/test/mpfr_concept_check.cpp here].
|
||||
|
||||
[endsect][/section:use_mpfr Using With MPFR / GMP - a High-Precision Floating-Point Library]
|
||||
|
||||
[section:concepts Conceptual Requirements for Real Number Types]
|
||||
|
||||
The functions, and statistical distributions in this library can be used with
|
||||
|
||||
@@ -646,7 +646,7 @@ struct lanczos61UDT
|
||||
boost::lexical_cast<T>("-0.163907874717737848669759890242660846846105433791283903651924563157080252845636658802930428e-44"),
|
||||
};
|
||||
T result = d[0];
|
||||
for(int k = 1; k < sizeof(d)/sizeof(d[0]); ++k)
|
||||
for(unsigned k = 1; k < sizeof(d)/sizeof(d[0]); ++k)
|
||||
{
|
||||
result += d[k]/(z+(k-1));
|
||||
}
|
||||
@@ -721,7 +721,7 @@ struct lanczos61UDT
|
||||
boost::lexical_cast<T>("-0.589653534231618730406843260601322236697428143603814281282790370329151249078338470962782338e-72"),
|
||||
};
|
||||
T result = d[0];
|
||||
for(int k = 1; k < sizeof(d)/sizeof(d[0]); ++k)
|
||||
for(unsigned k = 1; k < sizeof(d)/sizeof(d[0]); ++k)
|
||||
{
|
||||
result += d[k]/(z+(k-1));
|
||||
}
|
||||
@@ -795,7 +795,7 @@ struct lanczos61UDT
|
||||
boost::lexical_cast<T>("-0.285425405297633795767452984791738825078111150078605004958179057245980222485147999495352632e-71"),
|
||||
};
|
||||
T result = 0;
|
||||
for(int k = 1; k <= sizeof(d)/sizeof(d[0]); ++k)
|
||||
for(unsigned k = 1; k <= sizeof(d)/sizeof(d[0]); ++k)
|
||||
{
|
||||
result += (-d[k-1]*dz)/(k*dz + k*k);
|
||||
}
|
||||
@@ -870,7 +870,7 @@ struct lanczos61UDT
|
||||
};
|
||||
T result = 0;
|
||||
T z = dz + 2;
|
||||
for(int k = 1; k <= sizeof(d)/sizeof(d[0]); ++k)
|
||||
for(unsigned k = 1; k <= sizeof(d)/sizeof(d[0]); ++k)
|
||||
{
|
||||
result += (-d[k-1]*dz)/(z + k*z + k*k - 1);
|
||||
}
|
||||
|
||||
@@ -399,6 +399,7 @@ run test_tr1.cpp
|
||||
../build//boost_math_c99l
|
||||
: : :
|
||||
<define>TEST_LD=1
|
||||
<dependency>../build//has_long_double_support
|
||||
:
|
||||
test_tr1_long_double
|
||||
;
|
||||
@@ -491,5 +492,6 @@ compile compile_test/tools_test_data_inc_test.cpp ;
|
||||
compile compile_test/tools_test_inc_test.cpp ;
|
||||
compile compile_test/tools_toms748_inc_test.cpp ;
|
||||
|
||||
|
||||
compile ntl_concept_check.cpp : <dependency>../build//has_ntl_rr ;
|
||||
compile mpfr_concept_check.cpp : <dependency>../build//has_mpfr_class ;
|
||||
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
#define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
|
||||
#define TEST_MPFR
|
||||
|
||||
#pragma warning(disable:4800)
|
||||
#pragma warning(disable:4512)
|
||||
#pragma warning(disable:4127)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable:4800)
|
||||
# pragma warning(disable:4512)
|
||||
# pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#include <boost/math/bindings/mpfr.hpp>
|
||||
#include <boost/math/concepts/real_type_concept.hpp>
|
||||
|
||||
Reference in New Issue
Block a user