Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-10-12 06:01:38


Author: johnmaddock
Date: 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
New Revision: 39958
URL: http://svn.boost.org/trac/boost/changeset/39958

Log:
Lots of Borland specific patches: quite a few of the special-function tests do now do actually pass.
Added:
   trunk/libs/math/test/functor.hpp (contents, props changed)
Text files modified:
   trunk/boost/math/special_functions/bessel.hpp | 10 ++++++++++
   trunk/boost/math/special_functions/detail/bessel_ik.hpp | 6 +++---
   trunk/boost/math/special_functions/detail/bessel_jy.hpp | 8 ++++----
   trunk/boost/math/special_functions/detail/bessel_jy_asym.hpp | 6 +++---
   trunk/boost/math/special_functions/ellint_rj.hpp | 8 ++++----
   trunk/boost/math/tools/config.hpp | 8 ++++++++
   trunk/boost/math/tools/test.hpp | 4 ++--
   trunk/libs/math/test/hypot_test.cpp | 1 +
   trunk/libs/math/test/log1p_expm1_test.cpp | 24 +++++++++---------------
   trunk/libs/math/test/powm1_sqrtp1m1_test.cpp | 15 +++++++--------
   trunk/libs/math/test/test_bernoulli.cpp | 1 +
   trunk/libs/math/test/test_bessel_i.cpp | 16 ++++++----------
   trunk/libs/math/test/test_bessel_j.cpp | 32 ++++++++++----------------------
   trunk/libs/math/test/test_bessel_k.cpp | 22 ++++++++--------------
   trunk/libs/math/test/test_bessel_y.cpp | 32 ++++++++++----------------------
   trunk/libs/math/test/test_beta.cpp | 20 ++++++--------------
   trunk/libs/math/test/test_beta_dist.cpp | 1 +
   trunk/libs/math/test/test_binomial.cpp | 1 +
   trunk/libs/math/test/test_binomial_coeff.cpp | 19 +++++++------------
   trunk/libs/math/test/test_carlson.cpp | 37 ++++++++++++++-----------------------
   trunk/libs/math/test/test_cauchy.cpp | 1 +
   trunk/libs/math/test/test_cbrt.cpp | 23 +++++++++++++++--------
   22 files changed, 131 insertions(+), 164 deletions(-)

Modified: trunk/boost/math/special_functions/bessel.hpp
==============================================================================
--- trunk/boost/math/special_functions/bessel.hpp (original)
+++ trunk/boost/math/special_functions/bessel.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -86,7 +86,12 @@
 {
    bessel_j_small_z_series_term<T, Policy> s(v, x);
    boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
+ T zero = 0;
+ T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter, zero);
+#else
    T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter);
+#endif
    policies::check_series_iterations("boost::math::bessel_j_small_z_series<%1%>(%1%,%1%)", max_iter, pol);
    return result;
 }
@@ -97,7 +102,12 @@
    BOOST_MATH_STD_USING // ADL of std names
    sph_bessel_j_small_z_series_term<T, Policy> s(v, x);
    boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
+#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
+ T zero = 0;
+ T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter, zero);
+#else
    T result = boost::math::tools::sum_series(s, boost::math::policies::digits<T, Policy>(), max_iter);
+#endif
    policies::check_series_iterations("boost::math::sph_bessel_j_small_z_series<%1%>(%1%,%1%)", max_iter, pol);
    return result * sqrt(constants::pi<T>() / 4);
 }

Modified: trunk/boost/math/special_functions/detail/bessel_ik.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_ik.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_ik.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -44,7 +44,7 @@
     b = exp(v * a);
     sigma = -a * v;
     c = abs(v) < tools::epsilon<T>() ?
- 1 : sin_pi(v) / (v * pi<T>());
+ 1 : boost::math::sin_pi(v) / (v * pi<T>());
     d = abs(sigma) < tools::epsilon<T>() ?
         1 : sinh(sigma) / sigma;
     gamma1 = abs(v) < tools::epsilon<T>() ?
@@ -256,7 +256,7 @@
        if(reflect && (kind & need_i))
        {
            T z = (u + n % 2);
- Iv = sin_pi(z, pol) == 0 ?
+ Iv = boost::math::sin_pi(z, pol) == 0 ?
                Iv :
                policies::raise_overflow_error<T>(function, 0, pol); // reflection formula
        }
@@ -313,7 +313,7 @@
     if (reflect)
     {
         T z = (u + n % 2);
- *I = Iv + (2 / pi<T>()) * sin_pi(z) * Kv; // reflection formula
+ *I = Iv + (2 / pi<T>()) * boost::math::sin_pi(z) * Kv; // reflection formula
         *K = Kv;
     }
     else

Modified: trunk/boost/math/special_functions/detail/bessel_jy.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_jy.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_jy.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -43,8 +43,8 @@
 
     T gp = boost::math::tgamma1pm1(v, pol);
     T gm = boost::math::tgamma1pm1(-v, pol);
- T spv = sin_pi(v, pol);
- T spv2 = sin_pi(v/2, pol);
+ T spv = boost::math::sin_pi(v, pol);
+ T spv2 = boost::math::sin_pi(v/2, pol);
     T xp = pow(x/2, v);
 
     a = log(x / 2);
@@ -342,8 +342,8 @@
     if (reflect)
     {
         T z = (u + n % 2);
- *J = cos_pi(z, pol) * Jv - sin_pi(z, pol) * Yv; // reflection formula
- *Y = sin_pi(z, pol) * Jv + cos_pi(z, pol) * Yv;
+ *J = boost::math::cos_pi(z, pol) * Jv - boost::math::sin_pi(z, pol) * Yv; // reflection formula
+ *Y = boost::math::sin_pi(z, pol) * Jv + boost::math::cos_pi(z, pol) * Yv;
     }
     else
     {

Modified: trunk/boost/math/special_functions/detail/bessel_jy_asym.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_jy_asym.hpp (original)
+++ trunk/boost/math/special_functions/detail/bessel_jy_asym.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -233,10 +233,10 @@
 void temme_asyptotic_y_small_x(T v, T x, T* Y, T* Y1, const Policy& pol)
 {
    T c = 1;
- T p = (v / sin_pi(v, pol)) * pow(x / 2, -v) / tgamma(1 - v, pol);
- T q = (v / sin_pi(v, pol)) * pow(x / 2, v) / tgamma(1 + v, pol);
+ T p = (v / boost::math::sin_pi(v, pol)) * pow(x / 2, -v) / boost::math::tgamma(1 - v, pol);
+ T q = (v / boost::math::sin_pi(v, pol)) * pow(x / 2, v) / boost::math::tgamma(1 + v, pol);
    T f = (p - q) / v;
- T g_prefix = sin_pi(v / 2, pol);
+ T g_prefix = boost::math::sin_pi(v / 2, pol);
    g_prefix *= g_prefix * 2 / v;
    T g = f + g_prefix * q;
    T h = p;

Modified: trunk/boost/math/special_functions/ellint_rj.hpp
==============================================================================
--- trunk/boost/math/special_functions/ellint_rj.hpp (original)
+++ trunk/boost/math/special_functions/ellint_rj.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -87,10 +87,10 @@
        BOOST_ASSERT(pmy >= 0);
 
        T p = pmy + y;
- value = ellint_rj(x, y, z, p, pol);
+ value = boost::math::ellint_rj(x, y, z, p, pol);
        value *= pmy;
- value -= 3 * ellint_rf(x, y, z, pol);
- value += 3 * sqrt((x * y * z) / (x * z + p * q)) * ellint_rc(x * z + p * q, p * q, pol);
+ value -= 3 * boost::math::ellint_rf(x, y, z, pol);
+ value += 3 * sqrt((x * y * z) / (x * z + p * q)) * boost::math::ellint_rc(x * z + p * q, p * q, pol);
        value /= (y + q);
        return value;
     }
@@ -118,7 +118,7 @@
         alpha = p * (sx + sy + sz) + sx * sy * sz;
         alpha *= alpha;
         beta = p * (p + lambda) * (p + lambda);
- sigma += factor * ellint_rc(alpha, beta, pol);
+ sigma += factor * boost::math::ellint_rc(alpha, beta, pol);
         factor /= 4;
         x = (x + lambda) / 4;
         y = (y + lambda) / 4;

Modified: trunk/boost/math/tools/config.hpp
==============================================================================
--- trunk/boost/math/tools/config.hpp (original)
+++ trunk/boost/math/tools/config.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -29,6 +29,8 @@
 //
 # define BOOST_MATH_NO_REAL_CONCEPT_TESTS
 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+# define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
+# include <float.h>
 #endif
 #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106))
 //
@@ -83,6 +85,12 @@
 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
 #endif
 //
+// Helper macro for controlling the FP behaviour:
+//
+#ifndef BOOST_MATH_CONTROL_FP
+# define BOOST_MATH_CONTROL_FP
+#endif
+//
 // Helper macro for using statements:
 //
 #define BOOST_MATH_STD_USING \

Modified: trunk/boost/math/tools/test.hpp
==============================================================================
--- trunk/boost/math/tools/test.hpp (original)
+++ trunk/boost/math/tools/test.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -75,9 +75,9 @@
    if((a != 0) && (b != 0))
    {
       // TODO: use isfinite:
- if(b > max_val)
+ if(fabs(b) >= max_val)
       {
- if(a > max_val)
+ if(fabs(a) >= max_val)
             return 0; // one infinity is as good as another!
       }
       // If the result is denormalised, treat all denorms as equivalent:

Added: trunk/libs/math/test/functor.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/math/test/functor.hpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -0,0 +1,153 @@
+
+#ifndef BOOST_MATH_TEST_FUNCTOR_HPP
+#define BOOST_MATH_TEST_FUNCTOR_HPP
+
+struct extract_result_type
+{
+ extract_result_type(unsigned i) : m_location(i){}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return row[m_location];
+ }
+private:
+ unsigned m_location;
+};
+
+inline extract_result_type extract_result(unsigned i)
+{
+ return extract_result_type(i);
+}
+
+template <class F>
+struct row_binder1
+{
+ row_binder1(F _f, unsigned i) : f(_f), m_i(i) {}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return f(row[m_i]);
+ }
+
+private:
+ F f;
+ unsigned m_i;
+};
+
+template<class F>
+inline row_binder1<F> bind_func(F f, unsigned i)
+{
+ return row_binder1<F>(f, i);
+}
+
+template <class F>
+struct row_binder2
+{
+ row_binder2(F _f, unsigned i, unsigned j) : f(_f), m_i(i), m_j(j) {}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return f(row[m_i], row[m_j]);
+ }
+
+private:
+ F f;
+ unsigned m_i, m_j;
+};
+
+template<class F>
+inline row_binder2<F> bind_func(F f, unsigned i, unsigned j)
+{
+ return row_binder2<F>(f, i, j);
+}
+
+template <class F>
+struct row_binder3
+{
+ row_binder3(F _f, unsigned i, unsigned j, unsigned k) : f(_f), m_i(i), m_j(j), m_k(k) {}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return f(row[m_i], row[m_j], row[m_k]);
+ }
+
+private:
+ F f;
+ unsigned m_i, m_j, m_k;
+};
+
+template<class F>
+inline row_binder3<F> bind_func(F f, unsigned i, unsigned j, unsigned k)
+{
+ return row_binder3<F>(f, i, j, k);
+}
+
+template <class F>
+struct row_binder4
+{
+ row_binder4(F _f, unsigned i, unsigned j, unsigned k, unsigned l) : f(_f), m_i(i), m_j(j), m_k(k), m_l(l) {}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return f(row[m_i], row[m_j], row[m_k], row[m_l]);
+ }
+
+private:
+ F f;
+ unsigned m_i, m_j, m_k, m_l;
+};
+
+template<class F>
+inline row_binder4<F> bind_func(F f, unsigned i, unsigned j, unsigned k, unsigned l)
+{
+ return row_binder4<F>(f, i, j, k, l);
+}
+
+template <class F>
+struct row_binder2_i1
+{
+ row_binder2_i1(F _f, unsigned i, unsigned j) : f(_f), m_i(i), m_j(j) {}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return f(boost::math::tools::real_cast<int>(row[m_i]), row[m_j]);
+ }
+
+private:
+ F f;
+ unsigned m_i, m_j;
+};
+
+template<class F>
+inline row_binder2_i1<F> bind_func_int1(F f, unsigned i, unsigned j)
+{
+ return row_binder2_i1<F>(f, i, j);
+}
+
+template <class F>
+struct negate_type
+{
+ negate_type(F f) : m_f(f){}
+
+ template <class S>
+ typename S::value_type operator()(const S& row)
+ {
+ return -m_f(row);
+ }
+private:
+ F m_f;
+};
+
+template <class F>
+inline negate_type<F> negate(F f)
+{
+ return negate_type<F>(f);
+}
+
+#endif

Modified: trunk/libs/math/test/hypot_test.cpp
==============================================================================
--- trunk/libs/math/test/hypot_test.cpp (original)
+++ trunk/libs/math/test/hypot_test.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -116,6 +116,7 @@
 
 int test_main(int, char* [])
 {
+ BOOST_MATH_CONTROL_FP;
    test_boundaries();
    test_spots();
    return 0;

Modified: trunk/libs/math/test/log1p_expm1_test.cpp
==============================================================================
--- trunk/libs/math/test/log1p_expm1_test.cpp (original)
+++ trunk/libs/math/test/log1p_expm1_test.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -11,10 +11,7 @@
 #include <boost/math/special_functions/log1p.hpp>
 #include <boost/math/special_functions/expm1.hpp>
 #include <boost/array.hpp>
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#endif
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 
@@ -69,12 +66,11 @@
 template <class T>
 void do_test(const T& data, const char* type_name, const char* test_name)
 {
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
    typedef typename T::value_type row_type;
    typedef typename row_type::value_type value_type;
 
    typedef value_type (*pg)(value_type);
- pg funcp = boost::math::log1p;
+ pg funcp = &boost::math::log1p;
 
    boost::math::tools::test_result<value_type> result;
    std::cout << "Testing " << test_name << " with type " << type_name
@@ -82,12 +78,11 @@
    //
    // test log1p against data:
    //
- funcp = boost::math::log1p;
+ funcp = &boost::math::log1p;
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0])),
- boost::lambda::ret<value_type>(boost::lambda::_1[1]));
+ bind_func(funcp, 0),
+ extract_result(1));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::log1p", "log1p and expm1");
    std::cout << std::endl;
    //
@@ -96,12 +91,10 @@
    funcp = boost::math::expm1;
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::expm1", "log1p and expm1");
    std::cout << std::endl;
-#endif
 }
 
 template <class T>
@@ -130,6 +123,7 @@
 int test_main(int, char* [])
 {
    expected_results();
+ BOOST_MATH_CONTROL_FP;
    test(float(0), "float");
    test(double(0), "double");
    //
@@ -137,7 +131,7 @@
    // due to poor std lib support (not enough digits returned from
    // std::log and std::exp):
    //
-#if !defined(__CYGWIN__) && !defined(__FreeBSD__) && !(defined(__GNUC__) && defined(__sun))
+#if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
    test((long double)(0), "long double");
 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
    test((boost::math::concepts::real_concept)(0), "real_concept");

Modified: trunk/libs/math/test/powm1_sqrtp1m1_test.cpp
==============================================================================
--- trunk/libs/math/test/powm1_sqrtp1m1_test.cpp (original)
+++ trunk/libs/math/test/powm1_sqrtp1m1_test.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -9,9 +9,8 @@
 #include <boost/math/special_functions/sqrt1pm1.hpp>
 #include <boost/math/special_functions/powm1.hpp>
 #include <boost/math/tools/test.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
 #include <boost/array.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 
@@ -1613,7 +1612,6 @@
 #undef SC_
 
 
- using namespace boost::lambda;
    using namespace std;
 
    typedef T (*func_t)(const T&);
@@ -1621,25 +1619,26 @@
 
    boost::math::tools::test_result<T> result = boost::math::tools::test(
       sqrtp1m1_data,
- bind(f, ret<T>(_1[0])),
- ret<T>(_1[1]));
+ bind_func(f, 0),
+ extract_result(1));
 
    std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
       "Test results for type " << type_name << std::endl << std::endl;
    handle_test_result(result, sqrtp1m1_data[result.worst()], result.worst(), type_name, "boost::math::sqrt1pm1", "sqrt1pm1");
 
    typedef T (*func2_t)(T const, T const);
- func2_t f2 = &boost::math::powm1<T>;
+ func2_t f2 = &boost::math::powm1<T,T>;
    result = boost::math::tools::test(
       powm1_data,
- bind(f2, ret<T>(_1[0]), ret<T>(_1[1])),
- ret<T>(_1[2]));
+ bind_func(f2, 0, 1),
+ extract_result(2));
    handle_test_result(result, powm1_data[result.worst()], result.worst(), type_name, "boost::math::powm1", "powm1");
 }
 
 int test_main(int, char* [])
 {
    expected_results();
+ BOOST_MATH_CONTROL_FP;
    test_powm1_sqrtp1m1(1.0F, "float");
    test_powm1_sqrtp1m1(1.0, "double");
 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS

Modified: trunk/libs/math/test/test_bernoulli.cpp
==============================================================================
--- trunk/libs/math/test/test_bernoulli.cpp (original)
+++ trunk/libs/math/test/test_bernoulli.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -209,6 +209,7 @@
 
 int test_main(int, char* [])
 {
+ BOOST_MATH_CONTROL_FP;
         // Check that can generate bernoulli distribution using both convenience methods:
         bernoulli_distribution<double> bn1(0.5); // Using default RealType double.
         boost::math::bernoulli bn2(0.5); // Using typedef.

Modified: trunk/libs/math/test/test_bessel_i.cpp
==============================================================================
--- trunk/libs/math/test/test_bessel_i.cpp (original)
+++ trunk/libs/math/test/test_bessel_i.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -10,8 +10,7 @@
 #include <boost/math/special_functions/bessel.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 #include "test_bessel_hooks.hpp"
@@ -126,10 +125,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_i", test_name);
    std::cout << std::endl;
 
@@ -172,10 +169,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_i", test_name);
    std::cout << std::endl;
 }
@@ -257,6 +252,7 @@
    gsl_set_error_handler_off();
 #endif
    expected_results();
+ BOOST_MATH_CONTROL_FP;
 
 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
    test_bessel(0.1F, "float");

Modified: trunk/libs/math/test/test_bessel_j.cpp
==============================================================================
--- trunk/libs/math/test/test_bessel_j.cpp (original)
+++ trunk/libs/math/test/test_bessel_j.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -9,8 +9,7 @@
 #include <boost/math/special_functions/bessel.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 #include "test_bessel_hooks.hpp"
@@ -255,10 +254,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_j", test_name);
    std::cout << std::endl;
 
@@ -272,10 +269,8 @@
       //
       result = boost::math::tools::test(
          data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
       handle_test_result(result, data[result.worst()], result.worst(), type_name, "other::cyl_bessel_j", test_name);
       std::cout << std::endl;
    }
@@ -308,10 +303,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_j", test_name);
    std::cout << std::endl;
 }
@@ -326,7 +319,6 @@
    pg funcp = boost::math::sph_bessel;
 
    typedef int (*cast_t)(value_type);
- cast_t rc = &boost::math::tools::real_cast<int, value_type>;
 
    boost::math::tools::test_result<value_type> result;
 
@@ -338,13 +330,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<int>(
- boost::lambda::bind(
- rc,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]))),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func_int1(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::sph_bessel", test_name);
    std::cout << std::endl;
 }
@@ -472,6 +459,7 @@
    gsl_set_error_handler_off();
 #endif
    expected_results();
+ BOOST_MATH_CONTROL_FP;
 
    test_bessel(0.1F, "float");
    test_bessel(0.1, "double");

Modified: trunk/libs/math/test/test_bessel_k.cpp
==============================================================================
--- trunk/libs/math/test/test_bessel_k.cpp (original)
+++ trunk/libs/math/test/test_bessel_k.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -17,8 +17,7 @@
 #include <boost/math/special_functions/bessel.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 #include "test_bessel_hooks.hpp"
@@ -114,10 +113,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_k", test_name);
    std::cout << std::endl;
 
@@ -131,10 +128,8 @@
       //
       result = boost::math::tools::test(
          data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
       print_test_result(result, data[result.worst()], result.worst(), type_name, "other::cyl_bessel_k");
       std::cout << std::endl;
    }
@@ -160,10 +155,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_bessel_k", test_name);
    std::cout << std::endl;
 }
@@ -243,6 +236,7 @@
    gsl_set_error_handler_off();
 #endif
    expected_results();
+ BOOST_MATH_CONTROL_FP;
 
 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
    test_bessel(0.1F, "float");

Modified: trunk/libs/math/test/test_bessel_y.cpp
==============================================================================
--- trunk/libs/math/test/test_bessel_y.cpp (original)
+++ trunk/libs/math/test/test_bessel_y.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -10,8 +10,7 @@
 #include <boost/math/special_functions/bessel.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 #include "test_bessel_hooks.hpp"
@@ -241,10 +240,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_neumann", test_name);
    std::cout << std::endl;
 
@@ -258,10 +255,8 @@
       //
       result = boost::math::tools::test(
          data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
       handle_test_result(result, data[result.worst()], result.worst(), type_name, "other::cyl_neumann", test_name);
       std::cout << std::endl;
    }
@@ -293,10 +288,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_neumann", test_name);
    std::cout << std::endl;
 }
@@ -311,7 +304,6 @@
    pg funcp = boost::math::sph_neumann;
 
    typedef int (*cast_t)(value_type);
- cast_t rc = &boost::math::tools::real_cast<int, value_type>;
 
    boost::math::tools::test_result<value_type> result;
 
@@ -323,13 +315,8 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<int>(
- boost::lambda::bind(
- rc,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]))),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func_int1(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cyl_neumann", test_name);
    std::cout << std::endl;
 }
@@ -416,6 +403,7 @@
    gsl_set_error_handler_off();
 #endif
    expected_results();
+ BOOST_MATH_CONTROL_FP;
 
 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
    test_bessel(0.1F, "float");

Modified: trunk/libs/math/test/test_beta.cpp
==============================================================================
--- trunk/libs/math/test/test_beta.cpp (original)
+++ trunk/libs/math/test/test_beta.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -14,10 +14,7 @@
 #include <boost/math/constants/constants.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#endif
+#include "functor.hpp"
 
 #include "test_beta_hooks.hpp"
 #include "handle_test_result.hpp"
@@ -116,7 +113,6 @@
 template <class T>
 void do_test_beta(const T& data, const char* type_name, const char* test_name)
 {
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
    typedef typename T::value_type row_type;
    typedef typename row_type::value_type value_type;
 
@@ -133,25 +129,20 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::beta", test_name);
 #ifdef TEST_OTHER
    if(::boost::is_floating_point<value_type>::value){
       funcp = other::beta;
       result = boost::math::tools::test(
          data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(funcp, 0, 1),
+ extract_result(2));
       print_test_result(result, data[result.worst()], result.worst(), type_name, "other::beta");
    }
 #endif
    std::cout << std::endl;
-#endif
 }
 template <class T>
 void test_beta(T, const char* name)
@@ -196,6 +187,7 @@
 int test_main(int, char* [])
 {
    expected_results();
+ BOOST_MATH_CONTROL_FP;
    test_spots(0.0F);
    test_spots(0.0);
 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS

Modified: trunk/libs/math/test/test_beta_dist.cpp
==============================================================================
--- trunk/libs/math/test/test_beta_dist.cpp (original)
+++ trunk/libs/math/test/test_beta_dist.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -457,6 +457,7 @@
 
 int test_main(int, char* [])
 {
+ BOOST_MATH_CONTROL_FP;
    // Check that can generate beta distribution using one convenience methods:
    beta_distribution<> mybeta11(1., 1.); // Using default RealType double.
    // but that

Modified: trunk/libs/math/test/test_binomial.cpp
==============================================================================
--- trunk/libs/math/test/test_binomial.cpp (original)
+++ trunk/libs/math/test/test_binomial.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -692,6 +692,7 @@
 
 int test_main(int, char* [])
 {
+ BOOST_MATH_CONTROL_FP;
         // Check that can generate binomial distribution using one convenience methods:
         binomial_distribution<> mybn2(1., 0.5); // Using default RealType double.
   // but that

Modified: trunk/libs/math/test/test_binomial_coeff.cpp
==============================================================================
--- trunk/libs/math/test/test_binomial_coeff.cpp (original)
+++ trunk/libs/math/test/test_binomial_coeff.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -8,10 +8,7 @@
 #include <boost/test/floating_point_comparison.hpp>
 #include <boost/math/special_functions/binomial.hpp>
 #include <boost/math/tools/test.hpp>
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
-#endif
+#include "functor.hpp"
 #include <boost/array.hpp>
 
 #include "handle_test_result.hpp"
@@ -104,19 +101,17 @@
 template <class T>
 void test_binomial(T, const char* type_name)
 {
-#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
- using namespace boost::lambda;
    using namespace std;
 
    typedef T (*func_t)(T, T);
- func_t f = &binomial_wrapper<T>;
+ func_t f = &binomial_wrapper;
 
 #include "binomial_data.ipp"
 
    boost::math::tools::test_result<T> result = boost::math::tools::test(
       binomial_data,
- bind(f, ret<T>(_1[0]), ret<T>(_1[1])),
- ret<T>(_1[2]));
+ bind_func(f, 0, 1),
+ extract_result(2));
 
    std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
       "Test results for small arguments and type " << type_name << std::endl << std::endl;
@@ -128,15 +123,14 @@
 
    result = boost::math::tools::test(
       binomial_large_data,
- bind(f, ret<T>(_1[0]), ret<T>(_1[1])),
- ret<T>(_1[2]));
+ bind_func(f, 0, 1),
+ extract_result(2));
 
    std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
       "Test results for large arguments and type " << type_name << std::endl << std::endl;
    std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
    handle_test_result(result, binomial_large_data[result.worst()], result.worst(), type_name, "binomial_coefficient", "Binomials: large arguments");
    std::cout << std::endl;
-#endif
 }
 
 template <class T>
@@ -170,6 +164,7 @@
 int test_main(int, char* [])
 {
    expected_results();
+ BOOST_MATH_CONTROL_FP;
 
    test_spots(1.0F, "float");
    test_spots(1.0, "double");

Modified: trunk/libs/math/test/test_carlson.cpp
==============================================================================
--- trunk/libs/math/test/test_carlson.cpp (original)
+++ trunk/libs/math/test/test_carlson.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -14,9 +14,8 @@
 #include <boost/math/special_functions/ellint_rd.hpp>
 #include <boost/math/constants/constants.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
 #include <boost/tr1/random.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 //
@@ -135,11 +134,8 @@
  
     result = boost::math::tools::test(
       data,
- boost::lambda::bind(fp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1]),
- boost::lambda::ret<value_type>(boost::lambda::_1[2])),
- boost::lambda::ret<value_type>(boost::lambda::_1[3]));
+ bind_func(fp, 0, 1, 2),
+ extract_result(3));
    handle_test_result(result, data[result.worst()], result.worst(),
       type_name, "boost::math::ellint_rf", test);
 
@@ -160,10 +156,8 @@
  
     result = boost::math::tools::test(
       data,
- boost::lambda::bind(fp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]));
+ bind_func(fp, 0, 1),
+ extract_result(2));
    handle_test_result(result, data[result.worst()], result.worst(),
       type_name, "boost::math::ellint_rc", test);
 
@@ -184,12 +178,8 @@
  
     result = boost::math::tools::test(
       data,
- boost::lambda::bind(fp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1]),
- boost::lambda::ret<value_type>(boost::lambda::_1[2]),
- boost::lambda::ret<value_type>(boost::lambda::_1[3])),
- boost::lambda::ret<value_type>(boost::lambda::_1[4]));
+ bind_func(fp, 0, 1, 2, 3),
+ extract_result(4));
    handle_test_result(result, data[result.worst()], result.worst(),
       type_name, "boost::math::ellint_rf", test);
 
@@ -210,11 +200,8 @@
  
     result = boost::math::tools::test(
       data,
- boost::lambda::bind(fp,
- boost::lambda::ret<value_type>(boost::lambda::_1[0]),
- boost::lambda::ret<value_type>(boost::lambda::_1[1]),
- boost::lambda::ret<value_type>(boost::lambda::_1[2])),
- boost::lambda::ret<value_type>(boost::lambda::_1[3]));
+ bind_func(fp, 0, 1, 2),
+ extract_result(3));
    handle_test_result(result, data[result.worst()], result.worst(),
       type_name, "boost::math::ellint_rd", test);
 
@@ -318,6 +305,10 @@
 int test_main(int, char* [])
 {
     expected_results();
+ BOOST_MATH_CONTROL_FP;
+
+ boost::math::ellint_rj(1.778e-31, 1.407e+18, 10.05, -4.83e-10);
+
     test_spots(0.0F, "float");
     test_spots(0.0, "double");
 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
@@ -401,4 +392,4 @@
     { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
 *** No errors detected
 
-*/
\ No newline at end of file
+*/

Modified: trunk/libs/math/test/test_cauchy.cpp
==============================================================================
--- trunk/libs/math/test/test_cauchy.cpp (original)
+++ trunk/libs/math/test/test_cauchy.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -714,6 +714,7 @@
 
 int test_main(int, char* [])
 {
+ BOOST_MATH_CONTROL_FP;
         // Check that can generate cauchy distribution using the two convenience methods:
         boost::math::cauchy mycd1(1.); // Using typedef
         cauchy_distribution<> mycd2(1.); // Using default RealType double.

Modified: trunk/libs/math/test/test_cbrt.cpp
==============================================================================
--- trunk/libs/math/test/test_cbrt.cpp (original)
+++ trunk/libs/math/test/test_cbrt.cpp 2007-10-12 06:01:36 EDT (Fri, 12 Oct 2007)
@@ -10,9 +10,8 @@
 #include <boost/math/tools/test.hpp>
 #include <boost/type_traits/is_floating_point.hpp>
 #include <boost/array.hpp>
-#include <boost/lambda/lambda.hpp>
-#include <boost/lambda/bind.hpp>
 #include <boost/math/special_functions/cbrt.hpp>
+#include "functor.hpp"
 
 #include "handle_test_result.hpp"
 
@@ -49,6 +48,14 @@
    //
    std::cout << "Tests run with " << BOOST_COMPILER << ", "
       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
+
+ add_expected_result(
+ "Borland.*", // compiler
+ ".*", // stdlib
+ ".*", // platform
+ "long double", // test type(s)
+ ".*", // test data group
+ ".*", 10, 6); // test function
 }
 
 
@@ -71,14 +78,12 @@
    //
    result = boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- boost::lambda::ret<value_type>(boost::lambda::_1[0]));
+ bind_func(funcp, 1),
+ extract_result(0));
    result += boost::math::tools::test(
       data,
- boost::lambda::bind(funcp,
- -boost::lambda::ret<value_type>(boost::lambda::_1[1])),
- -boost::lambda::ret<value_type>(boost::lambda::_1[0]));
+ negate(bind_func(funcp, 1)),
+ negate(extract_result(0)));
    handle_test_result(result, data[result.worst()], result.worst(), type_name, "boost::math::cbrt", test_name);
    std::cout << std::endl;
 }
@@ -99,6 +104,8 @@
 
 int test_main(int, char* [])
 {
+ expected_results();
+ BOOST_MATH_CONTROL_FP;
    test_cbrt(0.1F, "float");
    test_cbrt(0.1, "double");
    test_cbrt(0.1L, "long double");


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