Boost logo

Boost-Commit :

From: johnmaddock_at_[hidden]
Date: 2007-07-14 05:27:55


Author: johnmaddock
Date: 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
New Revision: 7424
URL: http://svn.boost.org/trac/boost/changeset/7424

Log:
Updated elliptic integrals and more to Policy framework.

Text files modified:
   sandbox/math_toolkit/policy/boost/math/special_functions/binomial.hpp | 29 +++++---
   sandbox/math_toolkit/policy/boost/math/special_functions/cbrt.hpp | 16 +++-
   sandbox/math_toolkit/policy/boost/math/special_functions/digamma.hpp | 44 ++++++++-----
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_1.hpp | 69 +++++++++++++++-------
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_2.hpp | 66 ++++++++++++++------
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_3.hpp | 122 ++++++++++++++++++++++++---------------
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rc.hpp | 36 +++++++----
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rd.hpp | 44 ++++++++-----
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rf.hpp | 38 +++++++----
   sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rj.hpp | 57 ++++++++++-------
   sandbox/math_toolkit/policy/boost/math/tools/toms748_solve.hpp | 2
   sandbox/math_toolkit/policy/libs/math/test/test_poisson.cpp | 2
   12 files changed, 330 insertions(+), 195 deletions(-)

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/binomial.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/binomial.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/binomial.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -8,19 +8,20 @@
 
 #include <boost/math/special_functions/factorials.hpp>
 #include <boost/math/special_functions/beta.hpp>
-#include <boost/math/tools/error_handling.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 namespace boost{ namespace math{
 
-template <class T>
-T binomial_coefficient(unsigned n, unsigned k)
+template <class T, class Policy>
+T binomial_coefficient(unsigned n, unsigned k, const Policy& pol)
 {
    using namespace std;
+ static const char* function = "boost::math::binomial_coefficient<%1%>(unsigned, unsigned)";
    if(k > n)
- return tools::domain_error<T>(
- BOOST_CURRENT_FUNCTION,
+ return policy::raise_domain_error<T>(
+ function,
          "The binomial coefficient is undefined for k > n, but got k = %1%.",
- k);
+ k, pol);
    T result;
    if((k == 0) || (k == n))
       return 1;
@@ -38,11 +39,11 @@
    {
       // Use the beta function:
       if(k < n - k)
- result = k * beta(static_cast<T>(k), static_cast<T>(n-k+1));
+ result = k * beta(static_cast<T>(k), static_cast<T>(n-k+1), pol);
       else
- result = (n - k) * beta(static_cast<T>(k+1), static_cast<T>(n-k));
+ result = (n - k) * beta(static_cast<T>(k+1), static_cast<T>(n-k), pol);
       if(result == 0)
- return tools::overflow_error<T>(BOOST_CURRENT_FUNCTION);
+ return policy::raise_overflow_error<T>(function, 0, pol);
       result = 1 / result;
    }
    // convert to nearest integer:
@@ -54,9 +55,15 @@
 // we'll promote to double:
 //
 template <>
-inline float binomial_coefficient<float>(unsigned n, unsigned k)
+inline float binomial_coefficient<float, policy::policy<> >(unsigned n, unsigned k, const policy::policy<>& pol)
+{
+ return policy::checked_narrowing_cast<float, policy::policy<> >(binomial_coefficient<double>(n, k, pol), "boost::math::binomial_coefficient<%1%>(unsigned,unsigned)");
+}
+
+template <class T>
+inline T binomial_coefficient(unsigned n, unsigned k)
 {
- return tools::checked_narrowing_cast<float>(binomial_coefficient<double>(n, k), BOOST_CURRENT_FUNCTION);
+ return binomial_coefficient<T>(n, k, policy::policy<>());
 }
 
 } // namespace math

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/cbrt.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/cbrt.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/cbrt.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -27,8 +27,8 @@
                  T a;
         };
 
-template <class T>
-T cbrt_imp(T z)
+template <class T, class Policy>
+T cbrt_imp(T z, const Policy&)
 {
    using namespace std;
    int exp, sign(1);
@@ -44,17 +44,23 @@
    T min = static_cast<T>(ldexp(0.5, exp/3));
    T max = static_cast<T>(ldexp(2.0, exp/3));
    T guess = static_cast<T>(ldexp(1.0, exp/3));
- int digits = (tools::digits<T>()) / 2;
+ int digits = (policy::digits<T, Policy>()) / 2;
    return sign * tools::halley_iterate(detail::cbrt_functor<T>(z), guess, min, max, digits);
 }
 
 } // namespace detail
 
+template <class T, class Policy>
+inline typename tools::promote_args<T>::type cbrt(T z, const Policy& pol)
+{
+ typedef typename tools::promote_args<T>::type result_type;
+ return detail::cbrt_imp(result_type(z), pol);
+}
+
 template <class T>
 inline typename tools::promote_args<T>::type cbrt(T z)
 {
- typedef typename tools::promote_args<T>::type result_type;
- return detail::cbrt_imp(result_type(z));
+ return cbrt(z, policy::policy<>());
 }
 
 } // namespace math

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/digamma.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/digamma.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/digamma.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -9,8 +9,9 @@
 #include <boost/math/tools/rational.hpp>
 #include <boost/math/tools/evaluation_type.hpp>
 #include <boost/math/tools/promotion.hpp>
-#include <boost/math/tools/error_handling.hpp>
+#include <boost/math/policy/error_handling.hpp>
 #include <boost/math/constants/constants.hpp>
+#include <boost/mpl/comparison.hpp>
 
 namespace boost{
 namespace math{
@@ -338,8 +339,8 @@
    return result;
 }
 
-template <class T, class Tag>
-T digamma_imp(T x, const Tag* t)
+template <class T, class Tag, class Policy>
+T digamma_imp(T x, const Tag* t, const Policy& pol)
 {
    //
    // This handles reflection of negative arguments, and all our
@@ -367,7 +368,7 @@
       //
       if(remainder == 0)
       {
- return tools::pole_error<T>(BOOST_CURRENT_FUNCTION, 0, (1-x));
+ return policy::raise_pole_error<T>("boost::math::digamma<%1%>(%1%)", 0, (1-x), pol);
       }
       result = constants::pi<T>() / tan(constants::pi<T>() * remainder);
    }
@@ -404,31 +405,40 @@
 
 } // namespace detail
 
-template <class T>
+template <class T, class Policy>
 inline typename tools::promote_args<T>::type
- digamma(T x)
+ digamma(T x, const Policy& pol)
 {
    typedef typename tools::promote_args<T>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- typedef typename mpl::if_c<
- (std::numeric_limits<T>::digits == 0)
- ||
- (std::numeric_limits<T>::digits > 64),
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ typedef typename policy::precision<T, Policy>::type precision_type;
+ typedef typename mpl::if_<
+ mpl::or_<
+ mpl::less_equal<precision_type, mpl::int_<0> >,
+ mpl::greater<precision_type, mpl::int_<64> >
+ >,
       mpl::int_<0>,
- typename mpl::if_c<
- (std::numeric_limits<T>::digits < 25),
+ typename mpl::if_<
+ mpl::less<precision_type, mpl::int_<25> >,
          mpl::int_<24>,
- typename mpl::if_c<
- (std::numeric_limits<T>::digits < 54),
+ typename mpl::if_<
+ mpl::less<precision_type, mpl::int_<54> >,
             mpl::int_<53>,
             mpl::int_<64>
>::type
>::type
>::type tag_type;
 
- return tools::checked_narrowing_cast<result_type>(detail::digamma_imp(
+ return policy::checked_narrowing_cast<result_type, Policy>(detail::digamma_imp(
       static_cast<value_type>(x),
- static_cast<const tag_type*>(0)), BOOST_CURRENT_FUNCTION);
+ static_cast<const tag_type*>(0), pol), "boost::math::digamma<%1%>(%1%)");
+}
+
+template <class T>
+inline typename tools::promote_args<T>::type
+ digamma(T x)
+{
+ return digamma(x, policy::policy<>());
 }
 
 } // namespace math

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_1.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_1.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_1.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -16,28 +16,32 @@
 
 #include <boost/math/special_functions/ellint_rf.hpp>
 #include <boost/math/constants/constants.hpp>
-#include <boost/math/tools/error_handling.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 // Elliptic integrals (complete and incomplete) of the first kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
 
 namespace boost { namespace math {
 
+template <class T1, class T2, class Policy>
+typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi, const Policy& pol);
+
 namespace detail{
 
 // Elliptic integral (Legendre form) of the first kind
-template <typename T>
-T ellint_f_imp(T phi, T k)
+template <typename T, typename Policy>
+T ellint_f_imp(T phi, T k, const Policy& pol)
 {
     using namespace std;
     using namespace boost::math::tools;
     using namespace boost::math::constants;
 
+ static const char* function = "boost::math::ellint_f<%1%>(%1%,%1%)";
+
     if (abs(k) > 1)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got k = %1%, function requires |k| <= 1", k);
+ return policy::raise_domain_error<T>(function,
+ "Got k = %1%, function requires |k| <= 1", k, pol);
     }
 
     bool invert = false;
@@ -53,14 +57,14 @@
     if(phi >= tools::max_value<T>())
     {
        // Need to handle infinity as a special case:
- result = tools::overflow_error<T>(BOOST_CURRENT_FUNCTION);
+ result = policy::raise_overflow_error<T>(function, 0, pol);
        BOOST_MATH_INSTRUMENT_CODE(result);
     }
     else if(phi > 1 / tools::epsilon<T>())
     {
        // Phi is so large that phi%pi is necessarily zero (or garbage),
        // just return the second part of the duplication formula:
- result = 2 * phi * ellint_k_imp(k) / constants::pi<T>();
+ result = 2 * phi * ellint_k_imp(k, pol) / constants::pi<T>();
        BOOST_MATH_INSTRUMENT_CODE(result);
     }
     else
@@ -86,11 +90,11 @@
        }
        T sinp = sin(rphi);
        T cosp = cos(rphi);
- result = s * sinp * ellint_rf_imp(cosp * cosp, 1 - k * k * sinp * sinp, T(1));
+ result = s * sinp * ellint_rf_imp(cosp * cosp, 1 - k * k * sinp * sinp, T(1), pol);
        BOOST_MATH_INSTRUMENT_CODE(result);
        if(m != 0)
        {
- result += m * ellint_k_imp(k);
+ result += m * ellint_k_imp(k, pol);
           BOOST_MATH_INSTRUMENT_CODE(result);
        }
     }
@@ -98,48 +102,69 @@
 }
 
 // Complete elliptic integral (Legendre form) of the first kind
-template <typename T>
-T ellint_k_imp(T k)
+template <typename T, typename Policy>
+T ellint_k_imp(T k, const Policy& pol)
 {
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_k<%1%>(%1%)";
+
     if (abs(k) > 1)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got k = %1%, function requires |k| <= 1", k);
+ return policy::raise_domain_error<T>(function,
+ "Got k = %1%, function requires |k| <= 1", k, pol);
     }
     if (abs(k) == 1)
     {
- return overflow_error<T>(BOOST_CURRENT_FUNCTION);
+ return policy::raise_overflow_error<T>(function, 0, pol);
     }
 
     T x = 0;
     T y = 1 - k * k;
     T z = 1;
- T value = ellint_rf_imp(x, y, z);
+ T value = ellint_rf_imp(x, y, z, pol);
 
     return value;
 }
 
+template <typename T, typename Policy>
+inline typename tools::promote_args<T>::type ellint_1(T k, const Policy& pol, const mpl::true_&)
+{
+ typedef typename tools::promote_args<T>::type result_type;
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(detail::ellint_k_imp(static_cast<value_type>(k), pol), "boost::math::ellint_1<%1%>(%1%)");
+}
+
+template <class T1, class T2>
+inline typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi, const mpl::false_&)
+{
+ return boost::math::ellint_1(k, phi, policy::policy<>());
+}
+
 }
 
 // Complete elliptic integral (Legendre form) of the first kind
 template <typename T>
 inline typename tools::promote_args<T>::type ellint_1(T k)
 {
- typedef typename tools::promote_args<T>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(detail::ellint_k_imp(static_cast<value_type>(k)), BOOST_CURRENT_FUNCTION);
+ return ellint_1(k, policy::policy<>());
 }
 
 // Elliptic integral (Legendre form) of the first kind
+template <class T1, class T2, class Policy>
+inline typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi, const Policy& pol)
+{
+ typedef typename tools::promote_args<T1, T2>::type result_type;
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(detail::ellint_f_imp(static_cast<value_type>(phi), static_cast<value_type>(k), pol), "boost::math::ellint_1<%1%>(%1%,%1%)");
+}
+
 template <class T1, class T2>
 inline typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi)
 {
- typedef typename tools::promote_args<T1, T2>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(detail::ellint_f_imp(static_cast<value_type>(phi), static_cast<value_type>(k)), BOOST_CURRENT_FUNCTION);
+ typedef typename policy::is_policy<T2>::type tag_type;
+ return detail::ellint_1(k, phi, tag_type());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_2.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_2.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_2.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -17,20 +17,24 @@
 #include <boost/math/special_functions/ellint_rf.hpp>
 #include <boost/math/special_functions/ellint_rd.hpp>
 #include <boost/math/constants/constants.hpp>
-#include <boost/math/tools/error_handling.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 // Elliptic integrals (complete and incomplete) of the second kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
 
-namespace boost { namespace math { namespace detail{
+namespace boost { namespace math {
+
+template <class T1, class T2, class Policy>
+typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi, const Policy& pol);
+
+namespace detail{
 
-template <typename T>
-T ellint_e_imp(T k);
+template <typename T, typename Policy>
+T ellint_e_imp(T k, const Policy& pol);
 
 // Elliptic integral (Legendre form) of the second kind
-template <typename T>
-T ellint_e_imp(T phi, T k)
+template <typename T, typename Policy>
+T ellint_e_imp(T phi, T k, const Policy& pol)
 {
     using namespace std;
     using namespace boost::math::tools;
@@ -48,13 +52,13 @@
     if(phi >= tools::max_value<T>())
     {
        // Need to handle infinity as a special case:
- result = tools::overflow_error<T>(BOOST_CURRENT_FUNCTION);
+ result = policy::raise_overflow_error<T>("boost::math::ellint_e<%1%>(%1%,%1%)", 0, pol);
     }
     else if(phi > 1 / tools::epsilon<T>())
     {
        // Phi is so large that phi%pi is necessarily zero (or garbage),
        // just return the second part of the duplication formula:
- result = 2 * phi * ellint_e_imp(k) / constants::pi<T>();
+ result = 2 * phi * ellint_e_imp(k, pol) / constants::pi<T>();
     }
     else
     {
@@ -80,24 +84,24 @@
        T t = k * k * sinp * sinp;
        T y = 1 - t;
        T z = 1;
- result = s * sinp * (ellint_rf_imp(x, y, z) - t * ellint_rd_imp(x, y, z) / 3);
+ result = s * sinp * (ellint_rf_imp(x, y, z, pol) - t * ellint_rd_imp(x, y, z, pol) / 3);
        if(m != 0)
- result += m * ellint_e_imp(k);
+ result += m * ellint_e_imp(k, pol);
     }
     return invert ? -result : result;
 }
 
 // Complete elliptic integral (Legendre form) of the second kind
-template <typename T>
-T ellint_e_imp(T k)
+template <typename T, typename Policy>
+T ellint_e_imp(T k, const Policy& pol)
 {
     using namespace std;
     using namespace boost::math::tools;
 
     if (abs(k) > 1)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got k = %1%, function requires |k| <= 1", k);
+ return policy::raise_domain_error<T>("boost::math::ellint_e<%1%>(%1%)",
+ "Got k = %1%, function requires |k| <= 1", k, pol);
     }
     if (abs(k) == 1)
     {
@@ -108,29 +112,49 @@
     T t = k * k;
     T y = 1 - t;
     T z = 1;
- T value = ellint_rf_imp(x, y, z) - t * ellint_rd_imp(x, y, z) / 3;
+ T value = ellint_rf_imp(x, y, z, pol) - t * ellint_rd_imp(x, y, z, pol) / 3;
 
     return value;
 }
 
+template <typename T, typename Policy>
+inline typename tools::promote_args<T>::type ellint_2(T k, const Policy& pol, const mpl::true_&)
+{
+ typedef typename tools::promote_args<T>::type result_type;
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(detail::ellint_e_imp(static_cast<value_type>(k), pol), "boost::math::ellint_2<%1%>(%1%)");
+}
+
+// Elliptic integral (Legendre form) of the second kind
+template <class T1, class T2>
+inline typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi, const mpl::false_&)
+{
+ return boost::math::ellint_2(k, phi, policy::policy<>());
+}
+
 } // detail
 
 // Complete elliptic integral (Legendre form) of the second kind
 template <typename T>
 inline typename tools::promote_args<T>::type ellint_2(T k)
 {
- typedef typename tools::promote_args<T>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(detail::ellint_e_imp(static_cast<value_type>(k)), BOOST_CURRENT_FUNCTION);
+ return ellint_2(k, policy::policy<>());
 }
 
 // Elliptic integral (Legendre form) of the second kind
 template <class T1, class T2>
 inline typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi)
 {
+ typedef typename policy::is_policy<T2>::type tag_type;
+ return detail::ellint_2(k, phi, tag_type());
+}
+
+template <class T1, class T2, class Policy>
+inline typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi, const Policy& pol)
+{
    typedef typename tools::promote_args<T1, T2>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(detail::ellint_e_imp(static_cast<value_type>(phi), static_cast<value_type>(k)), BOOST_CURRENT_FUNCTION);
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(detail::ellint_e_imp(static_cast<value_type>(phi), static_cast<value_type>(k), pol), "boost::math::ellint_2<%1%>(%1%,%1%)");
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_3.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_3.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_3.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -20,19 +20,24 @@
 #include <boost/math/special_functions/ellint_2.hpp>
 #include <boost/math/special_functions/log1p.hpp>
 #include <boost/math/constants/constants.hpp>
-#include <boost/math/tools/error_handling.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 // Elliptic integrals (complete and incomplete) of the third kind
 // Carlson, Numerische Mathematik, vol 33, 1 (1979)
 
-namespace boost { namespace math { namespace detail{
+namespace boost { namespace math {
+
+template <class T1, class T2, class T3, class Policy>
+typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi, const Policy& pol);
+
+namespace detail{
 
-template <typename T>
-T ellint_pi_imp(T v, T k, T vc);
+template <typename T, typename Policy>
+T ellint_pi_imp(T v, T k, T vc, const Policy& pol);
 
 // Elliptic integral (Legendre form) of the third kind
-template <typename T>
-T ellint_pi_imp(T v, T phi, T k, T vc)
+template <typename T, typename Policy>
+T ellint_pi_imp(T v, T phi, T k, T vc, const Policy& pol)
 {
     // Note vc = 1-v presumably without cancellation error.
     T value, x, y, z, p, t;
@@ -41,10 +46,12 @@
     using namespace boost::math::tools;
     using namespace boost::math::constants;
 
+ static const char* function = "boost::math::ellint_3<%1%>(%1%,%1%,%1%)";
+
     if (abs(k) > 1)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got k = %1%, function requires |k| <= 1", k);
+ return policy::raise_domain_error<T>(function,
+ "Got k = %1%, function requires |k| <= 1", k, pol);
     }
 
     T sphi = sin(fabs(phi));
@@ -52,15 +59,15 @@
     if(v > 1 / (sphi * sphi))
     {
         // Complex result is a domain error:
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got v = %1%, but result is complex for v > 1 / sin^2(phi)", v);
+ return policy::raise_domain_error<T>(function,
+ "Got v = %1%, but result is complex for v > 1 / sin^2(phi)", v, pol);
     }
 
     // Special cases first:
     if(v == 0)
     {
        // A&S 17.7.18 & 19
- return (k == 0) ? phi : ellint_f_imp(phi, k);
+ return (k == 0) ? phi : ellint_f_imp(phi, k, pol);
     }
     if(phi == constants::pi<T>() / 2)
     {
@@ -71,7 +78,7 @@
        // in a T, this is a bit of a guess as to the users true
        // intent...
        //
- return ellint_pi_imp(v, k, vc);
+ return ellint_pi_imp(v, k, vc, pol);
     }
     if(k == 0)
     {
@@ -90,7 +97,7 @@
           // v > 1:
           T vcr = sqrt(-vc);
           T arg = vcr * tan(phi);
- return (boost::math::log1p(arg) - boost::math::log1p(-arg)) / (2 * vcr);
+ return (boost::math::log1p(arg, pol) - boost::math::log1p(-arg, pol)) / (2 * vcr);
        }
     }
 
@@ -106,10 +113,10 @@
        T Nm1 = (1 - k2) / (1 - v);
        T p2 = sqrt(-v * (k2 - v) / (1 - v));
        T delta = sqrt(1 - k2 * sphi * sphi);
- T result = ellint_pi_imp(N, phi, k, Nm1);
+ T result = ellint_pi_imp(N, phi, k, Nm1, pol);
 
        result *= sqrt(Nm1 * (1 - k2 / N));
- result += ellint_f_imp(phi, k) * k2 / p2;
+ result += ellint_f_imp(phi, k, pol) * k2 / p2;
        result += atan((p2/2) * sin(2 * phi) / delta);
        result /= sqrt((1 - v) * (1 - k2 / v));
        return result;
@@ -162,14 +169,14 @@
     if(fabs(phi) > 1 / tools::epsilon<T>())
     {
        if(v > 1)
- return tools::domain_error<T>(
- BOOST_CURRENT_FUNCTION,
- "Got v = %1%, but this is only supported for 0 <= phi <= pi/2", v);
+ return policy::raise_domain_error<T>(
+ function,
+ "Got v = %1%, but this is only supported for 0 <= phi <= pi/2", v, pol);
        //
        // Phi is so large that phi%pi is necessarily zero (or garbage),
        // just return the second part of the duplication formula:
        //
- value = 2 * fabs(phi) * ellint_pi_imp(v, k, vc) / constants::pi<T>();
+ value = 2 * fabs(phi) * ellint_pi_imp(v, k, vc, pol) / constants::pi<T>();
     }
     else
     {
@@ -189,9 +196,9 @@
           // The region with v > 1 and phi outside [0, pi/2] is
           // currently unsupported:
           //
- return tools::domain_error<T>(
- BOOST_CURRENT_FUNCTION,
- "Got v = %1%, but this is only supported for 0 <= phi <= pi/2", v);
+ return policy::raise_domain_error<T>(
+ function,
+ "Got v = %1%, but this is only supported for 0 <= phi <= pi/2", v, pol);
        }
        T sinp = sin(rphi);
        T cosp = cos(rphi);
@@ -203,9 +210,9 @@
            p = 1 - v * t;
        else
            p = x + vc * t;
- value = sign * sinp * (ellint_rf_imp(x, y, z) + v * t * ellint_rj_imp(x, y, z, p) / 3);
+ value = sign * sinp * (ellint_rf_imp(x, y, z, pol) + v * t * ellint_rj_imp(x, y, z, p, pol) / 3);
        if(m > 0)
- value += m * ellint_pi_imp(v, k, vc);
+ value += m * ellint_pi_imp(v, k, vc, pol);
     }
 
     if (phi < 0)
@@ -216,28 +223,30 @@
 }
 
 // Complete elliptic integral (Legendre form) of the third kind
-template <typename T>
-T ellint_pi_imp(T v, T k, T vc)
+template <typename T, typename Policy>
+T ellint_pi_imp(T v, T k, T vc, const Policy& pol)
 {
     // Note arg vc = 1-v, possibly without cancellation errors
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_pi<%1%>(%1%,%1%)";
+
     if (abs(k) >= 1)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got k = %1%, function requires |k| <= 1", k);
+ return policy::raise_domain_error<T>(function,
+ "Got k = %1%, function requires |k| <= 1", k, pol);
     }
     if(vc <= 0)
     {
        // Result is complex:
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Got v = %1%, function requires v < 1", v);
+ return policy::raise_domain_error<T>(function,
+ "Got v = %1%, function requires v < 1", v, pol);
     }
 
     if(v == 0)
     {
- return (k == 0) ? boost::math::constants::pi<T>() / 2 : ellint_k_imp(k);
+ return (k == 0) ? boost::math::constants::pi<T>() / 2 : ellint_k_imp(k, pol);
     }
 
     if(v < 0)
@@ -247,10 +256,10 @@
        T Nm1 = (1 - k2) / (1 - v);
        T p2 = sqrt(-v * (k2 - v) / (1 - v));
 
- T result = boost::math::detail::ellint_pi_imp(N, k, Nm1);
+ T result = boost::math::detail::ellint_pi_imp(N, k, Nm1, pol);
 
        result *= sqrt(Nm1 * (1 - k2 / N));
- result += ellint_k_imp(k) * k2 / p2;
+ result += ellint_k_imp(k, pol) * k2 / p2;
        result /= sqrt((1 - v) * (1 - k2 / v));
        return result;
     }
@@ -259,36 +268,57 @@
     T y = 1 - k * k;
     T z = 1;
     T p = vc;
- T value = ellint_rf_imp(x, y, z) + v * ellint_rj_imp(x, y, z, p) / 3;
+ T value = ellint_rf_imp(x, y, z, pol) + v * ellint_rj_imp(x, y, z, p, pol) / 3;
 
     return value;
 }
 
+template <class T1, class T2, class T3>
+inline typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi, const mpl::false_&)
+{
+ return boost::math::ellint_3(k, v, phi, policy::policy<>());
+}
+
+template <class T1, class T2, class Policy>
+inline typename tools::promote_args<T1, T2>::type ellint_3(T1 k, T2 v, const Policy& pol, const mpl::true_&)
+{
+ typedef typename tools::promote_args<T1, T2>::type result_type;
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
+ detail::ellint_pi_imp(
+ static_cast<value_type>(v),
+ static_cast<value_type>(k),
+ static_cast<value_type>(1-v),
+ pol), "boost::math::ellint_3<%1%>(%1%,%1%)");
+}
+
 } // namespace detail
 
-template <class T1, class T2, class T3>
-inline typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi)
+template <class T1, class T2, class T3, class Policy>
+inline typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi, const Policy& pol)
 {
    typedef typename tools::promote_args<T1, T2, T3>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
       detail::ellint_pi_imp(
          static_cast<value_type>(v),
          static_cast<value_type>(phi),
          static_cast<value_type>(k),
- static_cast<value_type>(1-v)), BOOST_CURRENT_FUNCTION);
+ static_cast<value_type>(1-v),
+ pol), "boost::math::ellint_3<%1%>(%1%,%1%,%1%)");
+}
+
+template <class T1, class T2, class T3>
+inline typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi)
+{
+ typedef typename policy::is_policy<T3>::type tag_type;
+ return detail::ellint_3(k, v, phi, tag_type());
 }
 
 template <class T1, class T2>
 inline typename tools::promote_args<T1, T2>::type ellint_3(T1 k, T2 v)
 {
- typedef typename tools::promote_args<T1, T2>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
- detail::ellint_pi_imp(
- static_cast<value_type>(v),
- static_cast<value_type>(k),
- static_cast<value_type>(1-v)), BOOST_CURRENT_FUNCTION);
+ return ellint_3(k, v, policy::policy<>());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rc.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rc.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rc.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -13,10 +13,9 @@
 #ifndef BOOST_MATH_ELLINT_RC_HPP
 #define BOOST_MATH_ELLINT_RC_HPP
 
-#include <boost/math/tools/error_handling.hpp>
+#include <boost/math/policy/error_handling.hpp>
 #include <boost/math/tools/config.hpp>
 #include <boost/math/special_functions/math_fwd.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
 
 // Carlson's degenerate elliptic integral
 // R_C(x, y) = R_F(x, y, y) = 0.5 * \int_{0}^{\infty} (t+x)^{-1/2} (t+y)^{-1} dt
@@ -24,8 +23,8 @@
 
 namespace boost { namespace math { namespace detail{
 
-template <typename T>
-T ellint_rc_imp(T x, T y)
+template <typename T, typename Policy>
+T ellint_rc_imp(T x, T y, const Policy& pol)
 {
     T value, S, u, lambda, tolerance, prefix;
     int k;
@@ -33,15 +32,17 @@
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_rc<%1%>(%1%,%1%)";
+
     if(x < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument x must be non-negative but got %1%", x);
+ return policy::raise_domain_error<T>(function,
+ "Argument x must be non-negative but got %1%", x, pol);
     }
     if(y == 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument y must not be zero but got %1%", y);
+ return policy::raise_domain_error<T>(function,
+ "Argument y must not be zero but got %1%", y, pol);
     }
 
     // error scales as the 6th power of tolerance
@@ -73,7 +74,7 @@
         y = (y + lambda) / 4;
     }
     // Check to see if we gave up too soon:
- tools::check_series_iterations(BOOST_CURRENT_FUNCTION, k);
+ policy::check_series_iterations(function, k, pol);
 
     // Taylor series expansion to the 5th order
     value = (1 + S * S * (T(3) / 10 + S * (T(1) / 7 + S * (T(3) / 8 + S * T(9) / 22)))) / sqrt(u);
@@ -83,16 +84,23 @@
 
 } // namespace detail
 
-template <class T1, class T2>
+template <class T1, class T2, class Policy>
 inline typename tools::promote_args<T1, T2>::type
- ellint_rc(T1 x, T2 y)
+ ellint_rc(T1 x, T2 y, const Policy& pol)
 {
    typedef typename tools::promote_args<T1, T2>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
       detail::ellint_rc_imp(
          static_cast<value_type>(x),
- static_cast<value_type>(y)), BOOST_CURRENT_FUNCTION);
+ static_cast<value_type>(y), pol), "boost::math::ellint_rc<%1%>(%1%,%1%)");
+}
+
+template <class T1, class T2>
+inline typename tools::promote_args<T1, T2>::type
+ ellint_rc(T1 x, T2 y)
+{
+ return ellint_rc(x, y, policy::policy<>());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rd.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rd.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rd.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -13,8 +13,7 @@
 
 #include <boost/math/special_functions/math_fwd.hpp>
 #include <boost/math/tools/config.hpp>
-#include <boost/math/tools/error_handling.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 // Carlson's elliptic integral of the second kind
 // R_D(x, y, z) = R_J(x, y, z, z) = 1.5 * \int_{0}^{\infty} [(t+x)(t+y)]^{-1/2} (t+z)^{-3/2} dt
@@ -22,8 +21,8 @@
 
 namespace boost { namespace math { namespace detail{
 
-template <typename T>
-T ellint_rd_imp(T x, T y, T z)
+template <typename T, typename Policy>
+T ellint_rd_imp(T x, T y, T z, const Policy& pol)
 {
     T value, u, lambda, sigma, factor, tolerance;
     T X, Y, Z, EA, EB, EC, ED, EE, S1, S2;
@@ -32,25 +31,27 @@
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_rd<%1%>(%1%,%1%,%1%)";
+
     if (x < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument x must be >= 0, but got %1%", x);
+ return policy::raise_domain_error<T>(function,
+ "Argument x must be >= 0, but got %1%", x, pol);
     }
     if (y < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument y must be >= 0, but got %1%", y);
+ return policy::raise_domain_error<T>(function,
+ "Argument y must be >= 0, but got %1%", y, pol);
     }
     if (z <= 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument z must be > 0, but got %1%", z);
+ return policy::raise_domain_error<T>(function,
+ "Argument z must be > 0, but got %1%", z, pol);
     }
     if (x + y == 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "At most one argument can be zero, but got, x + y = %1%", x+y);
+ return policy::raise_domain_error<T>(function,
+ "At most one argument can be zero, but got, x + y = %1%", x+y, pol);
     }
 
     // error scales as the 6th power of tolerance
@@ -78,7 +79,7 @@
         z = (z + lambda) / 4;
     }
     // Check to see if we gave up too soon:
- tools::check_series_iterations(BOOST_CURRENT_FUNCTION, k);
+ policy::check_series_iterations(function, k, pol);
 
     // Taylor series expansion to the 5th order
     EA = X * Y;
@@ -95,17 +96,24 @@
 
 } // namespace detail
 
-template <class T1, class T2, class T3>
+template <class T1, class T2, class T3, class Policy>
 inline typename tools::promote_args<T1, T2, T3>::type
- ellint_rd(T1 x, T2 y, T3 z)
+ ellint_rd(T1 x, T2 y, T3 z, const Policy& pol)
 {
    typedef typename tools::promote_args<T1, T2, T3>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
       detail::ellint_rd_imp(
          static_cast<value_type>(x),
          static_cast<value_type>(y),
- static_cast<value_type>(z)), BOOST_CURRENT_FUNCTION);
+ static_cast<value_type>(z), pol), "boost::math::ellint_rd<%1%>(%1%,%1%,%1%)");
+}
+
+template <class T1, class T2, class T3>
+inline typename tools::promote_args<T1, T2, T3>::type
+ ellint_rd(T1 x, T2 y, T3 z)
+{
+ return ellint_rd(x, y, z, policy::policy<>());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rf.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rf.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rf.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -15,8 +15,7 @@
 #include <boost/math/special_functions/math_fwd.hpp>
 #include <boost/math/tools/config.hpp>
 
-#include <boost/math/tools/error_handling.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
+#include <boost/math/policy/error_handling.hpp>
 
 // Carlson's elliptic integral of the first kind
 // R_F(x, y, z) = 0.5 * \int_{0}^{\infty} [(t+x)(t+y)(t+z)]^{-1/2} dt
@@ -24,8 +23,8 @@
 
 namespace boost { namespace math { namespace detail{
 
-template <typename T>
-T ellint_rf_imp(T x, T y, T z)
+template <typename T, typename Policy>
+T ellint_rf_imp(T x, T y, T z, const Policy& pol)
 {
     T value, X, Y, Z, E2, E3, u, lambda, tolerance;
     int k;
@@ -33,25 +32,27 @@
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_rf<%1%>(%1%,%1%,%1%)";
+
     if (x < 0 || y < 0 || z < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
+ return policy::raise_domain_error<T>(function,
             "domain error, all arguments must be non-negative, "
             "only sensible result is %1%.",
- std::numeric_limits<T>::quiet_NaN());
+ std::numeric_limits<T>::quiet_NaN(), pol);
     }
     if (x + y == 0 || y + z == 0 || z + x == 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
+ return policy::raise_domain_error<T>(function,
             "domain error, at most one argument can be zero, "
             "only sensible result is %1%.",
- std::numeric_limits<T>::quiet_NaN());
+ std::numeric_limits<T>::quiet_NaN(), pol);
     }
 
     // Carlson scales error as the 6th power of tolerance,
     // but this seems not to work for types larger than
     // 80-bit reals, this heuristic seems to work OK:
- if(tools::digits<T>() > 64)
+ if(policy::digits<T, Policy>() > 64)
     {
       tolerance = pow(tools::epsilon<T>(), T(1)/4.25f);
       BOOST_MATH_INSTRUMENT_CODE(tolerance);
@@ -83,7 +84,7 @@
         z = (z + lambda) / 4;
     }
     // Check to see if we gave up too soon:
- tools::check_series_iterations(BOOST_CURRENT_FUNCTION, k);
+ policy::check_series_iterations(function, k, pol);
     BOOST_MATH_INSTRUMENT_CODE(k);
 
     // Taylor series expansion to the 5th order
@@ -97,17 +98,24 @@
 
 } // namespace detail
 
-template <class T1, class T2, class T3>
+template <class T1, class T2, class T3, class Policy>
 inline typename tools::promote_args<T1, T2, T3>::type
- ellint_rf(T1 x, T2 y, T3 z)
+ ellint_rf(T1 x, T2 y, T3 z, const Policy& pol)
 {
    typedef typename tools::promote_args<T1, T2, T3>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
       detail::ellint_rf_imp(
          static_cast<value_type>(x),
          static_cast<value_type>(y),
- static_cast<value_type>(z)), BOOST_CURRENT_FUNCTION);
+ static_cast<value_type>(z), pol), "boost::math::ellint_rf<%1%>(%1%,%1%,%1%)");
+}
+
+template <class T1, class T2, class T3>
+inline typename tools::promote_args<T1, T2, T3>::type
+ ellint_rf(T1 x, T2 y, T3 z)
+{
+ return ellint_rf(x, y, z, policy::policy<>());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rj.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rj.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/ellint_rj.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -15,8 +15,7 @@
 
 #include <boost/math/special_functions/math_fwd.hpp>
 #include <boost/math/tools/config.hpp>
-#include <boost/math/tools/error_handling.hpp>
-#include <boost/math/tools/evaluation_type.hpp>
+#include <boost/math/policy/error_handling.hpp>
 #include <boost/math/special_functions/ellint_rc.hpp>
 
 // Carlson's elliptic integral of the third kind
@@ -25,8 +24,8 @@
 
 namespace boost { namespace math { namespace detail{
 
-template <typename T>
-T ellint_rj_imp(T x, T y, T z, T p)
+template <typename T, typename Policy>
+T ellint_rj_imp(T x, T y, T z, T p, const Policy& pol)
 {
     T value, u, lambda, alpha, beta, sigma, factor, tolerance;
     T X, Y, Z, P, EA, EB, EC, E2, E3, S1, S2, S3;
@@ -35,31 +34,33 @@
     using namespace std;
     using namespace boost::math::tools;
 
+ static const char* function = "boost::math::ellint_rj<%1%>(%1%,%1%,%1%)";
+
     if (x < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument x must be non-negative, but got x = %1%", x);
+ return policy::raise_domain_error<T>(function,
+ "Argument x must be non-negative, but got x = %1%", x, pol);
     }
     if(y < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument y must be non-negative, but got y = %1%", y);
+ return policy::raise_domain_error<T>(function,
+ "Argument y must be non-negative, but got y = %1%", y, pol);
     }
     if(z < 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument z must be non-negative, but got z = %1%", z);
+ return policy::raise_domain_error<T>(function,
+ "Argument z must be non-negative, but got z = %1%", z, pol);
     }
     if(p == 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
- "Argument p must not be zero, but got p = %1%", p);
+ return policy::raise_domain_error<T>(function,
+ "Argument p must not be zero, but got p = %1%", p, pol);
     }
     if (x + y == 0 || y + z == 0 || z + x == 0)
     {
- return domain_error<T>(BOOST_CURRENT_FUNCTION,
+ return policy::raise_domain_error<T>(function,
             "At most one argument can be zero, "
- "only possible result is %1%.", std::numeric_limits<T>::quiet_NaN());
+ "only possible result is %1%.", std::numeric_limits<T>::quiet_NaN(), pol);
     }
 
     // error scales as the 6th power of tolerance
@@ -86,10 +87,10 @@
        BOOST_ASSERT(pmy >= 0);
 
        T p = pmy + y;
- value = ellint_rj(x, y, z, p);
+ value = ellint_rj(x, y, z, p, pol);
        value *= pmy;
- value -= 3 * ellint_rf(x, y, z);
- value += 3 * sqrt((x * y * z) / (x * z + p * q)) * ellint_rc(x * z + p * q, p * q);
+ 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 /= (y + q);
        return value;
     }
@@ -116,7 +117,7 @@
         alpha = p * (sx + sy + sz) + sx * sy * sz;
         alpha *= alpha;
         beta = p * (p + lambda) * (p + lambda);
- sigma += factor * ellint_rc(alpha, beta);
+ sigma += factor * ellint_rc(alpha, beta, pol);
         factor /= 4;
         x = (x + lambda) / 4;
         y = (y + lambda) / 4;
@@ -124,7 +125,7 @@
         p = (p + lambda) / 4;
     }
     // Check to see if we gave up too soon:
- tools::check_series_iterations(BOOST_CURRENT_FUNCTION, k);
+ policy::check_series_iterations(function, k, pol);
 
     // Taylor series expansion to the 5th order
     EA = X * Y + Y * Z + Z * X;
@@ -142,18 +143,26 @@
 
 } // namespace detail
 
-template <class T1, class T2, class T3, class T4>
+template <class T1, class T2, class T3, class T4, class Policy>
 inline typename tools::promote_args<T1, T2, T3, T4>::type
- ellint_rj(T1 x, T2 y, T3 z, T4 p)
+ ellint_rj(T1 x, T2 y, T3 z, T4 p, const Policy& pol)
 {
    typedef typename tools::promote_args<T1, T2, T3, T4>::type result_type;
- typedef typename tools::evaluation<result_type>::type value_type;
- return tools::checked_narrowing_cast<result_type>(
+ typedef typename policy::evaluation<result_type, Policy>::type value_type;
+ return policy::checked_narrowing_cast<result_type, Policy>(
       detail::ellint_rj_imp(
          static_cast<value_type>(x),
          static_cast<value_type>(y),
          static_cast<value_type>(z),
- static_cast<value_type>(p)), BOOST_CURRENT_FUNCTION);
+ static_cast<value_type>(p),
+ pol), "boost::math::ellint_rj<%1%>(%1%,%1%,%1%,%1%)");
+}
+
+template <class T1, class T2, class T3, class T4>
+inline typename tools::promote_args<T1, T2, T3, T4>::type
+ ellint_rj(T1 x, T2 y, T3 z, T4 p)
+{
+ return ellint_rj(x, y, z, p, policy::policy<>());
 }
 
 }} // namespaces

Modified: sandbox/math_toolkit/policy/boost/math/tools/toms748_solve.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/tools/toms748_solve.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/tools/toms748_solve.hpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -7,7 +7,7 @@
 #define BOOST_MATH_TOOLS_SOLVE_ROOT_HPP
 
 #include <boost/math/tools/precision.hpp>
-#include <boost/math/tools/error_handling.hpp>
+#include <boost/math/policy/error_handling.hpp>
 #include <boost/math/tools/config.hpp>
 #include <boost/math/special_functions/sign.hpp>
 #include <boost/cstdint.hpp>

Modified: sandbox/math_toolkit/policy/libs/math/test/test_poisson.cpp
==============================================================================
--- sandbox/math_toolkit/policy/libs/math/test/test_poisson.cpp (original)
+++ sandbox/math_toolkit/policy/libs/math/test/test_poisson.cpp 2007-07-14 05:27:54 EDT (Sat, 14 Jul 2007)
@@ -432,7 +432,7 @@
      typedef policy<discrete_quantile<integer_outside> > P4;
      typedef policy<discrete_quantile<integer_inside> > P5;
      typedef policy<discrete_quantile<integer_nearest> > P6;
- RealType tol = boost::math::tools::epsilon<RealType>() * 10;
+ RealType tol = boost::math::tools::epsilon<RealType>() * 20;
      if(!boost::is_floating_point<RealType>::value)
         tol *= 7;
      //


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