Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49110 - in sandbox/math_toolkit: boost/math/bindings/detail libs/math/build libs/math/doc/sf_and_dist libs/math/test
From: john_at_[hidden]
Date: 2008-10-02 05:37:30


Author: johnmaddock
Date: 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
New Revision: 49110
URL: http://svn.boost.org/trac/boost/changeset/49110

Log:
Added mpfr docs, and updated the NTL usage docs.
Updated bindings tests to run automatically when the appropriate libraries are present.
Added:
   sandbox/math_toolkit/libs/math/build/has_mpfr_class.cpp (contents, props changed)
   sandbox/math_toolkit/libs/math/build/has_ntl_rr.cpp (contents, props changed)
Text files modified:
   sandbox/math_toolkit/boost/math/bindings/detail/big_lanczos.hpp | 8 ++--
   sandbox/math_toolkit/libs/math/build/Jamfile.v2 | 2 +
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/concepts.qbk | 57 ++++++++++++++++++++++++++++++++++-----
   sandbox/math_toolkit/libs/math/test/Jamfile.v2 | 4 ++
   sandbox/math_toolkit/libs/math/test/mpfr_concept_check.cpp | 8 +++--
   5 files changed, 63 insertions(+), 16 deletions(-)

Modified: sandbox/math_toolkit/boost/math/bindings/detail/big_lanczos.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/bindings/detail/big_lanczos.hpp (original)
+++ sandbox/math_toolkit/boost/math/bindings/detail/big_lanczos.hpp 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -646,7 +646,7 @@
          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 @@
          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 @@
          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 @@
       };
       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);
       }

Modified: sandbox/math_toolkit/libs/math/build/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/build/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/build/Jamfile.v2 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -52,6 +52,8 @@
 ;
 
 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
     :

Added: sandbox/math_toolkit/libs/math/build/has_mpfr_class.cpp
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/build/has_mpfr_class.cpp 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -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>
+

Added: sandbox/math_toolkit/libs/math/build/has_ntl_rr.cpp
==============================================================================
--- (empty file)
+++ sandbox/math_toolkit/libs/math/build/has_ntl_rr.cpp 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -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>
+

Modified: sandbox/math_toolkit/libs/math/doc/sf_and_dist/concepts.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/sf_and_dist/concepts.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/concepts.qbk 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -14,17 +14,58 @@
 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

Modified: sandbox/math_toolkit/libs/math/test/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/test/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/test/Jamfile.v2 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -399,6 +399,7 @@
    ../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_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 ;
 

Modified: sandbox/math_toolkit/libs/math/test/mpfr_concept_check.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/mpfr_concept_check.cpp (original)
+++ sandbox/math_toolkit/libs/math/test/mpfr_concept_check.cpp 2008-10-02 05:37:29 EDT (Thu, 02 Oct 2008)
@@ -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>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk