Boost logo

Boost-Commit :

From: johnmaddock_at_[hidden]
Date: 2007-07-22 13:25:42


Author: johnmaddock
Date: 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
New Revision: 7501
URL: http://svn.boost.org/trac/boost/changeset/7501

Log:
Added more policy docs, and associated macros.

Text files modified:
   sandbox/math_toolkit/policy/boost/math/distributions/pareto.hpp | 2
   sandbox/math_toolkit/policy/boost/math/special_functions/bessel.hpp | 26 -
   sandbox/math_toolkit/policy/boost/math/special_functions/detail/ibeta_inverse.hpp | 17
   sandbox/math_toolkit/policy/boost/math/special_functions/laguerre.hpp | 22 -
   sandbox/math_toolkit/policy/boost/math/special_functions/math_fwd.hpp | 625 +++++++++++++++++++++++++++++++++++++++
   sandbox/math_toolkit/policy/libs/math/doc/policy.qbk | 87 +++++
   sandbox/math_toolkit/policy/libs/math/test/compile_test/instantiate.hpp | 261 ++++++++++++++--
   7 files changed, 944 insertions(+), 96 deletions(-)

Modified: sandbox/math_toolkit/policy/boost/math/distributions/pareto.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/distributions/pareto.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/distributions/pareto.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -328,7 +328,7 @@
         return result;
       }
       using namespace std;
- return dist.location() * pow(2, (1/dist.shape()));
+ return dist.location() * pow(RealType(2), (1/dist.shape()));
     } // median
 
     template <class RealType, class Policy>

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/bessel.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/bessel.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/bessel.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -27,32 +27,6 @@
 
 namespace detail{
 
-typedef mpl::int_<0> bessel_no_int_tag; // No integer optimisation possible.
-typedef mpl::int_<1> bessel_maybe_int_tag; // Maybe integer optimisation.
-typedef mpl::int_<2> bessel_int_tag; // Definite integer optimistaion.
-
-template <class T1, class T2, class Policy>
-struct bessel_traits
-{
- typedef typename tools::promote_args<
- T1, T2
- >::type result_type;
-
- typedef typename policy::precision<result_type, 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> > >,
- bessel_no_int_tag,
- typename mpl::if_<
- is_integral<T1>,
- bessel_int_tag,
- bessel_maybe_int_tag
- >::type
- >::type optimisation_tag;
-};
-
 template <class T, class Policy>
 struct bessel_j_small_z_series_term
 {

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/detail/ibeta_inverse.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/detail/ibeta_inverse.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/detail/ibeta_inverse.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -853,8 +853,14 @@
 inline typename tools::promote_args<T1, T2, T3>::type
    ibeta_inv(T1 a, T2 b, T3 p)
 {
- BOOST_FPU_EXCEPTION_GUARD
- return ibeta_inv(a, b, p, static_cast<T1*>(0), policy::policy<>());
+ return ibeta_inv(a, b, p, static_cast<T1*>(0), policy::policy<>());
+}
+
+template <class T1, class T2, class T3, class Policy>
+inline typename tools::promote_args<T1, T2, T3>::type
+ ibeta_inv(T1 a, T2 b, T3 p, const Policy& pol)
+{
+ return ibeta_inv(a, b, p, static_cast<T1*>(0), pol);
 }
 
 template <class T1, class T2, class T3, class T4, class Policy>
@@ -906,6 +912,13 @@
    return ibetac_inv(a, b, q, static_cast<RT1*>(0), policy::policy<>());
 }
 
+template <class RT1, class RT2, class RT3, class Policy>
+inline typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_inv(RT1 a, RT2 b, RT3 q, const Policy& pol)
+{
+ return ibetac_inv(a, b, q, static_cast<RT1*>(0), pol);
+}
+
 } // namespace math
 } // namespace boost
 

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/laguerre.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/laguerre.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/laguerre.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -14,28 +14,6 @@
 namespace boost{
 namespace math{
 
-//
-// Some forward declarations:
-//
-template <class T, class Policy>
-typename tools::promote_args<T>::type
- laguerre(unsigned n, unsigned m, T x, const Policy&);
-
-
-template <class T1, class T2>
-struct laguerre_result
-{
- typedef typename mpl::if_<
- policy::is_policy<T2>,
- typename tools::promote_args<T1>::type,
- typename tools::promote_args<T2>::type
- >::type type;
-};
-
-template <class T1, class T2>
-typename laguerre_result<T1, T2>::type
- laguerre(unsigned n, T1 m, T2 x);
-
 // Recurrance relation for Laguerre polynomials:
 template <class T1, class T2, class T3>
 inline typename tools::promote_args<T1, T2, T3>::type

Modified: sandbox/math_toolkit/policy/boost/math/special_functions/math_fwd.hpp
==============================================================================
--- sandbox/math_toolkit/policy/boost/math/special_functions/math_fwd.hpp (original)
+++ sandbox/math_toolkit/policy/boost/math/special_functions/math_fwd.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -20,6 +20,8 @@
 #define BOOST_MATH_SPECIAL_MATH_FWD_HPP
 
 #include <boost/math/tools/promotion.hpp> // for argument promotion.
+#include <boost/math/policy/policy.hpp>
+#include <boost/mpl/comparison.hpp>
 #include <complex>
 
 namespace boost
@@ -36,42 +38,106 @@
    typename tools::promote_args<RT1, RT2, A>::type
          beta(RT1 a, RT2 b, A x); // Beta function (3 arguments).
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ beta(RT1 a, RT2 b, RT3 x, const Policy& pol); // Beta function (3 arguments).
+
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          betac(RT1 a, RT2 b, RT3 x);
 
    template <class RT1, class RT2, class RT3, class Policy>
- inline typename tools::promote_args<RT1, RT2, RT3>::type
- beta(RT1 a, RT2 b, RT3 x, const Policy&);
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ betac(RT1 a, RT2 b, RT3 x, const Policy& pol);
 
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          ibeta(RT1 a, RT2 b, RT3 x); // Incomplete beta function.
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta(RT1 a, RT2 b, RT3 x, const Policy& pol); // Incomplete beta function.
+
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          ibetac(RT1 a, RT2 b, RT3 x); // Incomplete beta complement function.
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac(RT1 a, RT2 b, RT3 x, const Policy& pol); // Incomplete beta complement function.
+
    template <class T1, class T2, class T3, class T4>
    typename tools::promote_args<T1, T2, T3, T4>::type
          ibeta_inv(T1 a, T2 b, T3 p, T4* py);
 
+ template <class T1, class T2, class T3, class T4, class Policy>
+ typename tools::promote_args<T1, T2, T3, T4>::type
+ ibeta_inv(T1 a, T2 b, T3 p, T4* py, const Policy& pol);
+
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          ibeta_inv(RT1 a, RT2 b, RT3 p); // Incomplete beta inverse function.
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_inv(RT1 a, RT2 b, RT3 p, const Policy&); // Incomplete beta inverse function.
+
+ template <class RT1, class RT2, class RT3>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_inva(RT1 a, RT2 b, RT3 p); // Incomplete beta inverse function.
+
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_inva(RT1 a, RT2 b, RT3 p, const Policy&); // Incomplete beta inverse function.
+
+ template <class RT1, class RT2, class RT3>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_invb(RT1 a, RT2 b, RT3 p); // Incomplete beta inverse function.
+
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_invb(RT1 a, RT2 b, RT3 p, const Policy&); // Incomplete beta inverse function.
+
    template <class T1, class T2, class T3, class T4>
    typename tools::promote_args<T1, T2, T3, T4>::type
          ibetac_inv(T1 a, T2 b, T3 q, T4* py);
 
+ template <class T1, class T2, class T3, class T4, class Policy>
+ typename tools::promote_args<T1, T2, T3, T4>::type
+ ibetac_inv(T1 a, T2 b, T3 q, T4* py, const Policy& pol);
+
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          ibetac_inv(RT1 a, RT2 b, RT3 q); // Incomplete beta complement inverse function.
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_inv(RT1 a, RT2 b, RT3 q, const Policy&); // Incomplete beta complement inverse function.
+
+ template <class RT1, class RT2, class RT3>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_inva(RT1 a, RT2 b, RT3 q); // Incomplete beta complement inverse function.
+
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_inva(RT1 a, RT2 b, RT3 q, const Policy&); // Incomplete beta complement inverse function.
+
+ template <class RT1, class RT2, class RT3>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_invb(RT1 a, RT2 b, RT3 q); // Incomplete beta complement inverse function.
+
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibetac_invb(RT1 a, RT2 b, RT3 q, const Policy&); // Incomplete beta complement inverse function.
+
    template <class RT1, class RT2, class RT3>
    typename tools::promote_args<RT1, RT2, RT3>::type
          ibeta_derivative(RT1 a, RT2 b, RT3 x); // derivative of incomplete beta
 
+ template <class RT1, class RT2, class RT3, class Policy>
+ typename tools::promote_args<RT1, RT2, RT3>::type
+ ibeta_derivative(RT1 a, RT2 b, RT3 x, const Policy& pol); // derivative of incomplete beta
+
    // erf & erfc error functions.
    template <class RT> // Error function.
    typename tools::promote_args<RT>::type erf(RT z);
@@ -88,6 +154,8 @@
    template <class RT, class Policy>// Error function inverse.
    typename tools::promote_args<RT>::type erf_inv(RT z, const Policy& pol);
 
+ template <class RT>// Error function complement inverse.
+ typename tools::promote_args<RT>::type erfc_inv(RT z);
    template <class RT, class Policy>// Error function complement inverse.
    typename tools::promote_args<RT>::type erfc_inv(RT z, const Policy& pol);
 
@@ -100,10 +168,18 @@
    typename tools::promote_args<T>::type
          legendre_p(int l, T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type
+ legendre_p(int l, T x, const Policy& pol);
+
    template <class T>
    typename tools::promote_args<T>::type
          legendre_q(unsigned l, T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type
+ legendre_q(unsigned l, T x, const Policy& pol);
+
    template <class T1, class T2, class T3>
    typename tools::promote_args<T1, T2, T3>::type
          legendre_next(unsigned l, unsigned m, T1 x, T2 Pl, T3 Plm1);
@@ -112,6 +188,10 @@
    typename tools::promote_args<T>::type
          legendre_p(int l, int m, T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type
+ legendre_p(int l, int m, T x, const Policy& pol);
+
    template <class T1, class T2, class T3>
    typename tools::promote_args<T1, T2, T3>::type
          laguerre_next(unsigned n, T1 x, T2 Ln, T3 Lnm1);
@@ -122,8 +202,34 @@
 
    template <class T>
    typename tools::promote_args<T>::type
+ laguerre(unsigned n, T x);
+
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type
+ laguerre(unsigned n, unsigned m, T x, const Policy& pol);
+
+ template <class T1, class T2>
+ struct laguerre_result
+ {
+ typedef typename mpl::if_<
+ policy::is_policy<T2>,
+ typename tools::promote_args<T1>::type,
+ typename tools::promote_args<T2>::type
+ >::type type;
+ };
+
+ template <class T1, class T2>
+ typename laguerre_result<T1, T2>::type
+ laguerre(unsigned n, T1 m, T2 x);
+
+ template <class T>
+ typename tools::promote_args<T>::type
       hermite(unsigned n, T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type
+ hermite(unsigned n, T x, const Policy& pol);
+
    template <class T1, class T2, class T3>
    typename tools::promote_args<T1, T2, T3>::type
       hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);
@@ -132,46 +238,83 @@
    std::complex<typename tools::promote_args<T1, T2>::type>
          spherical_harmonic(unsigned n, int m, T1 theta, T2 phi);
 
+ template <class T1, class T2, class Policy>
+ std::complex<typename tools::promote_args<T1, T2>::type>
+ spherical_harmonic(unsigned n, int m, T1 theta, T2 phi, const Policy& pol);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type
          spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type
+ spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi, const Policy& pol);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type
          spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type
+ spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy& pol);
+
    // Elliptic integrals:
    template <class T1, class T2, class T3>
    typename tools::promote_args<T1, T2, T3>::type
          ellint_rf(T1 x, T2 y, T3 z);
 
+ template <class T1, class T2, class T3, class Policy>
+ typename tools::promote_args<T1, T2, T3>::type
+ ellint_rf(T1 x, T2 y, T3 z, const Policy& pol);
+
    template <class T1, class T2, class T3>
    typename tools::promote_args<T1, T2, T3>::type
          ellint_rd(T1 x, T2 y, T3 z);
 
+ template <class T1, class T2, class T3, class Policy>
+ typename tools::promote_args<T1, T2, T3>::type
+ ellint_rd(T1 x, T2 y, T3 z, const Policy& pol);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type
          ellint_rc(T1 x, T2 y);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type
+ ellint_rc(T1 x, T2 y, const Policy& pol);
+
    template <class T1, class T2, class T3, class T4>
    typename tools::promote_args<T1, T2, T3, T4>::type
          ellint_rj(T1 x, T2 y, T3 z, T4 p);
 
+ template <class T1, class T2, class T3, class T4, class Policy>
+ typename tools::promote_args<T1, T2, T3, T4>::type
+ ellint_rj(T1 x, T2 y, T3 z, T4 p, const Policy& pol);
+
    template <typename T>
    typename tools::promote_args<T>::type ellint_2(T k);
 
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi, const Policy& pol);
+
    template <typename T>
    typename tools::promote_args<T>::type ellint_1(T k);
 
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi, const Policy& pol);
+
    template <class T1, class T2, class T3>
    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>
+ typename tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi, const Policy& pol);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type ellint_3(T1 k, T2 v);
 
@@ -181,17 +324,26 @@
    struct max_factorial;
    template <class RT>
    RT factorial(unsigned int);
+ template <class RT, class Policy>
+ RT factorial(unsigned int, const Policy& pol);
    template <class RT>
    RT unchecked_factorial(unsigned int);
    template <class RT>
    RT double_factorial(unsigned i);
+ template <class RT, class Policy>
+ RT double_factorial(unsigned i, const Policy& pol);
 
    template <class RT>
    typename tools::promote_args<RT>::type falling_factorial(RT x, unsigned n);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type falling_factorial(RT x, unsigned n, const Policy& pol);
+
    template <class RT>
    typename tools::promote_args<RT>::type rising_factorial(RT x, unsigned n);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type rising_factorial(RT x, unsigned n, const Policy& pol);
 
    // Fpclassify - classify floating-point as NaN or infinity...
    template <class T>
@@ -204,92 +356,559 @@
    template <class RT>
    typename tools::promote_args<RT>::type tgamma1pm1(RT z);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type tgamma1pm1(RT z, const Policy& pol);
+
    template <class RT1, class RT2>
    typename tools::promote_args<RT1, RT2>::type tgamma(RT1 a, RT2 z);
 
+ template <class RT1, class RT2, class Policy>
+ typename tools::promote_args<RT1, RT2>::type tgamma(RT1 a, RT2 z, const Policy& pol);
+
    template <class RT>
    typename tools::promote_args<RT>::type lgamma(RT z, int* sign);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type lgamma(RT z, int* sign, const Policy& pol);
+
    template <class RT>
    typename tools::promote_args<RT>::type lgamma(RT x);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type lgamma(RT x, const Policy& pol);
+
    template <class RT1, class RT2>
    typename tools::promote_args<RT1, RT2>::type tgamma_lower(RT1 a, RT2 z);
 
+ template <class RT1, class RT2, class Policy>
+ typename tools::promote_args<RT1, RT2>::type tgamma_lower(RT1 a, RT2 z, const Policy&);
+
    template <class RT1, class RT2>
    typename tools::promote_args<RT1, RT2>::type gamma_q(RT1 a, RT2 z);
 
+ template <class RT1, class RT2, class Policy>
+ typename tools::promote_args<RT1, RT2>::type gamma_q(RT1 a, RT2 z, const Policy&);
+
    template <class RT1, class RT2>
    typename tools::promote_args<RT1, RT2>::type gamma_p(RT1 a, RT2 z);
 
+ template <class RT1, class RT2, class Policy>
+ typename tools::promote_args<RT1, RT2>::type gamma_p(RT1 a, RT2 z, const Policy&);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type tgamma_delta_ratio(T1 z, T2 delta);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type tgamma_delta_ratio(T1 z, T2 delta, const Policy&);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type tgamma_ratio(T1 a, T2 b);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type tgamma_ratio(T1 a, T2 b, const Policy&);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type gamma_p_derivative(T1 a, T2 x);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type gamma_p_derivative(T1 a, T2 x, const Policy&);
+
    // gamma inverse.
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type gamma_p_inv(T1 a, T2 p);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type gamma_p_inva(T1 a, T2 p, const Policy&);
+
+ template <class T1, class T2>
+ typename tools::promote_args<T1, T2>::type gamma_p_inva(T1 a, T2 p);
+
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type gamma_p_inv(T1 a, T2 p, const Policy&);
+
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type gamma_q_inv(T1 a, T2 q);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type gamma_q_inv(T1 a, T2 q, const Policy&);
+
+ template <class T1, class T2>
+ typename tools::promote_args<T1, T2>::type gamma_q_inva(T1 a, T2 q);
+
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type gamma_q_inva(T1 a, T2 q, const Policy&);
+
    // digamma:
    template <class T>
    typename tools::promote_args<T>::type digamma(T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type digamma(T x, const Policy&);
+
    // Hypotenuse function sqrt(x ^ 2 + y ^ 2).
    template <class T1, class T2>
    typename tools::promote_args<T1, T2>::type
          hypot(T1 x, T2 y);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type
+ hypot(T1 x, T2 y, const Policy&);
+
    // cbrt - cube root.
    template <class RT>
    typename tools::promote_args<RT>::type cbrt(RT z);
 
+ template <class RT, class Policy>
+ typename tools::promote_args<RT>::type cbrt(RT z, const Policy&);
+
    // log1p is log(x + 1)
    template <class T>
    typename tools::promote_args<T>::type log1p(T);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type log1p(T, const Policy&);
+
    // log1pmx is log(x + 1) - x
    template <class T>
    typename tools::promote_args<T>::type log1pmx(T);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type log1pmx(T, const Policy&);
+
    // Exp (x) minus 1 functions.
    template <class T>
    typename tools::promote_args<T>::type expm1(T);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type expm1(T, const Policy&);
+
    // Power - 1
    template <class T1, class T2>
- inline typename tools::promote_args<T1, T2>::type
+ typename tools::promote_args<T1, T2>::type
          powm1(const T1 a, const T2 z);
 
+ template <class T1, class T2, class Policy>
+ typename tools::promote_args<T1, T2>::type
+ powm1(const T1 a, const T2 z, const Policy&);
+
    // sqrt(1+x) - 1
    template <class T>
    typename tools::promote_args<T>::type sqrt1pm1(const T& val);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type sqrt1pm1(const T& val, const Policy&);
+
    // sinus cardinals:
    template <class T>
    typename tools::promote_args<T>::type sinc_pi(T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type sinc_pi(T x, const Policy&);
+
    template <class T>
    typename tools::promote_args<T>::type sinhc_pi(T x);
 
+ template <class T, class Policy>
+ typename tools::promote_args<T>::type sinhc_pi(T x, const Policy&);
+
    // inverse hyperbolics:
    template<typename T>
    typename tools::promote_args<T>::type asinh(const T x);
 
+ template<typename T, class Policy>
+ typename tools::promote_args<T>::type asinh(const T x, const Policy&);
+
    template<typename T>
    typename tools::promote_args<T>::type acosh(const T x);
 
+ template<typename T, class Policy>
+ typename tools::promote_args<T>::type acosh(const T x, const Policy&);
+
    template<typename T>
    typename tools::promote_args<T>::type atanh(const T x);
 
+ template<typename T, class Policy>
+ typename tools::promote_args<T>::type atanh(const T x, const Policy&);
+
+ namespace detail{
+
+ typedef mpl::int_<0> bessel_no_int_tag; // No integer optimisation possible.
+ typedef mpl::int_<1> bessel_maybe_int_tag; // Maybe integer optimisation.
+ typedef mpl::int_<2> bessel_int_tag; // Definite integer optimistaion.
+
+ template <class T1, class T2, class Policy>
+ struct bessel_traits
+ {
+ typedef typename tools::promote_args<
+ T1, T2
+ >::type result_type;
+
+ typedef typename policy::precision<result_type, 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> > >,
+ bessel_no_int_tag,
+ typename mpl::if_<
+ is_integral<T1>,
+ bessel_int_tag,
+ bessel_maybe_int_tag
+ >::type
+ >::type optimisation_tag;
+ };
+ } // detail
+
+ // Bessel functions:
+ template <class T1, class T2, class Policy>
+ typename detail::bessel_traits<T1, T2, Policy>::result_type cyl_bessel_j(T1 v, T2 x, const Policy& pol);
+
+ template <class T1, class T2>
+ typename detail::bessel_traits<T1, T2, policy::policy<> >::result_type cyl_bessel_j(T1 v, T2 x);
+
+ template <class T, class Policy>
+ typename detail::bessel_traits<T, T, Policy>::result_type sph_bessel(unsigned v, T x, const Policy& pol);
+
+ template <class T>
+ typename detail::bessel_traits<T, T, policy::policy<> >::result_type sph_bessel(unsigned v, T x);
+
+ template <class T1, class T2, class Policy>
+ typename detail::bessel_traits<T1, T2, Policy>::result_type cyl_bessel_i(T1 v, T2 x, const Policy& pol);
+
+ template <class T1, class T2>
+ typename detail::bessel_traits<T1, T2, policy::policy<> >::result_type cyl_bessel_i(T1 v, T2 x);
+
+ template <class T1, class T2, class Policy>
+ typename detail::bessel_traits<T1, T2, Policy>::result_type cyl_bessel_k(T1 v, T2 x, const Policy& pol);
+
+ template <class T1, class T2>
+ typename detail::bessel_traits<T1, T2, policy::policy<> >::result_type cyl_bessel_k(T1 v, T2 x);
+
+ template <class T1, class T2, class Policy>
+ typename detail::bessel_traits<T1, T2, Policy>::result_type cyl_neumann(T1 v, T2 x, const Policy& pol);
+
+ template <class T1, class T2>
+ typename detail::bessel_traits<T1, T2, policy::policy<> >::result_type cyl_neumann(T1 v, T2 x);
+
+ template <class T, class Policy>
+ typename detail::bessel_traits<T, T, Policy>::result_type sph_neumann(unsigned v, T x, const Policy& pol);
+
+ template <class T>
+ typename detail::bessel_traits<T, T, policy::policy<> >::result_type sph_neumann(unsigned v, T x);
+
+ template <class T, class Policy>
+ T sin_pi(T x, const Policy&);
+
+ template <class T>
+ T sin_pi(T x);
+
+ template <class T, class Policy>
+ T cos_pi(T x, const Policy&);
+
+ template <class T>
+ T cos_pi(T x);
+
+ template <class T>
+ int fpclassify BOOST_NO_MACRO_EXPAND(T t);
+
+ template <class T>
+ bool isfinite BOOST_NO_MACRO_EXPAND(T z);
+
+ template <class T>
+ bool isinf BOOST_NO_MACRO_EXPAND(T t);
+
+ template <class T>
+ bool isnan BOOST_NO_MACRO_EXPAND(T t);
+
+ template <class T>
+ bool isnormal BOOST_NO_MACRO_EXPAND(T t);
+
          } // namespace math
 } // namespace boost
 
+#define BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(Policy)\
+ template <class RT1, class RT2>\
+ inline typename boost::math::tools::promote_args<RT1, RT2>::type \
+ beta(RT1 a, RT2 b) { return ::boost::math::beta(a, b, Policy()); }\
+\
+ template <class RT1, class RT2, class A>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, A>::type \
+ beta(RT1 a, RT2 b, A x){ return ::boost::math::beta(a, b, x, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ betac(RT1 a, RT2 b, RT3 x) { return ::boost::math::betac(a, b, x, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibeta(RT1 a, RT2 b, RT3 x){ return ::boost::math::ibeta(a, b, x, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibetac(RT1 a, RT2 b, RT3 x){ return ::boost::math::ibetac(a, b, x, Policy()); }\
+\
+ template <class T1, class T2, class T3, class T4>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3, T4>::type \
+ ibeta_inv(T1 a, T2 b, T3 p, T4* py){ return ::boost::math::ibeta_inv(a, b, p, py, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibeta_inv(RT1 a, RT2 b, RT3 p){ return ::boost::math::ibeta_inv(a, b, p, Policy()); }\
+\
+ template <class T1, class T2, class T3, class T4>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3, T4>::type \
+ ibetac_inv(T1 a, T2 b, T3 q, T4* py){ return ::boost::math::ibeta_inv(a, b, q, py, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibeta_inva(RT1 a, RT2 b, RT3 p){ return ::boost::math::ibeta_inva(a, b, p, Policy()); }\
+\
+ template <class T1, class T2, class T3>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3>::type \
+ ibetac_inva(T1 a, T2 b, T3 q){ return ::boost::math::ibetac_inva(a, b, q, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibeta_invb(RT1 a, RT2 b, RT3 p){ return ::boost::math::ibeta_invb(a, b, p, Policy()); }\
+\
+ template <class T1, class T2, class T3>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3>::type \
+ ibetac_invb(T1 a, T2 b, T3 q){ return ::boost::math::ibeta_invb(a, b, q, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibetac_inv(RT1 a, RT2 b, RT3 q){ return ::boost::math::ibeta_inv(a, b, q, Policy()); }\
+\
+ template <class RT1, class RT2, class RT3>\
+ inline typename boost::math::tools::promote_args<RT1, RT2, RT3>::type \
+ ibeta_derivative(RT1 a, RT2 b, RT3 x){ return ::boost::math::ibeta_derivative(a, b, x, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type erf(RT z) { return ::boost::math::erf(z, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type erfc(RT z){ return ::boost::math::erfc(z, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type erf_inv(RT z) { return ::boost::math::erf_inv(z, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type erfc_inv(RT z){ return ::boost::math::erfc_inv(z, Policy()); }\
+\
+ using boost::math::legendre_next;\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type \
+ legendre_p(int l, T x){ return ::boost::math::legendre_p(l, x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type \
+ legendre_q(unsigned l, T x){ return ::boost::math::legendre_q(l, x, Policy()); }\
+\
+ using ::boost::math::legendre_next;\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type \
+ legendre_p(int l, int m, T x){ return ::boost::math::legendre_p(l, m, x, Policy()); }\
+\
+ using ::boost::math::laguerre_next;\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type \
+ laguerre(unsigned n, T x){ return ::boost::math::laguerre(n, x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::laguerre_result<T1, T2>::type \
+ laguerre(unsigned n, T1 m, T2 x) { return ::boost::math::laguerre(n, m, x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type \
+ hermite(unsigned n, T x){ return ::boost::math::hermite(n, x, Policy()); }\
+\
+ using boost::math::hermite_next;\
+\
+ template <class T1, class T2>\
+ inline std::complex<typename boost::math::tools::promote_args<T1, T2>::type> \
+ spherical_harmonic(unsigned n, int m, T1 theta, T2 phi){ return boost::math::spherical_harmonic(n, m, theta, phi, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ spherical_harmonic_r(unsigned n, int m, T1 theta, T2 phi){ return ::boost::math::spherical_harmonic_r(n, m, theta, phi, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi){ return boost::math::spherical_harmonic_i(n, m, theta, phi, Policy()); }\
+\
+ template <class T1, class T2, class Policy>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ spherical_harmonic_i(unsigned n, int m, T1 theta, T2 phi, const Policy& pol);\
+\
+ template <class T1, class T2, class T3>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3>::type \
+ ellint_rf(T1 x, T2 y, T3 z){ return ::boost::math::ellint_rf(x, y, z, Policy()); }\
+\
+ template <class T1, class T2, class T3>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3>::type \
+ ellint_rd(T1 x, T2 y, T3 z){ return ::boost::math::ellint_rd(x, y, z, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ ellint_rc(T1 x, T2 y){ return ::boost::math::ellint_rc(x, y, Policy()); }\
+\
+ template <class T1, class T2, class T3, class T4>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3, T4>::type \
+ ellint_rj(T1 x, T2 y, T3 z, T4 p){ return boost::math::ellint_rj(x, y, z, p, Policy()); }\
+\
+ template <typename T>\
+ inline typename boost::math::tools::promote_args<T>::type ellint_2(T k){ return boost::math::ellint_2(k, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type ellint_2(T1 k, T2 phi){ return boost::math::ellint_2(k, phi, Policy()); }\
+\
+ template <typename T>\
+ inline typename boost::math::tools::promote_args<T>::type ellint_1(T k){ return boost::math::ellint_1(k, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type ellint_1(T1 k, T2 phi){ return boost::math::ellint_1(k, phi, Policy()); }\
+\
+ template <class T1, class T2, class T3>\
+ inline typename boost::math::tools::promote_args<T1, T2, T3>::type ellint_3(T1 k, T2 v, T3 phi){ return boost::math::ellint_3(k, v, phi, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type ellint_3(T1 k, T2 v){ return boost::math::ellint_3(k, v, Policy()); }\
+\
+ using boost::math::max_factorial;\
+ template <class RT>\
+ inline RT factorial(unsigned int i) { return boost::math::factorial<RT>(i, Policy()); }\
+ using boost::math::unchecked_factorial;\
+ template <class RT>\
+ inline RT double_factorial(unsigned i){ return boost::math::double_factorial<RT>(i, Policy()); }\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type falling_factorial(RT x, unsigned n){ return boost::math::falling_factorial(x, n, Policy()); }\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type rising_factorial(RT x, unsigned n){ return boost::math::rising_factorial(x, n, Policy()); }\
+ using boost::math::fpclassify;\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type tgamma(RT z){ return boost::math::tgamma(z, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type tgamma1pm1(RT z){ return boost::math::tgamma1pm1(z, Policy()); }\
+\
+ template <class RT1, class RT2>\
+ inline typename boost::math::tools::promote_args<RT1, RT2>::type tgamma(RT1 a, RT2 z){ return boost::math::tgamma(a, z, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type lgamma(RT z, int* sign){ return boost::math::lgamma(z, sign, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type lgamma(RT x){ return boost::math::lgamma(x, Policy()); }\
+\
+ template <class RT1, class RT2>\
+ inline typename boost::math::tools::promote_args<RT1, RT2>::type tgamma_lower(RT1 a, RT2 z){ return boost::math::tgamma_lower(a, z, Policy()); }\
+\
+ template <class RT1, class RT2>\
+ inline typename boost::math::tools::promote_args<RT1, RT2>::type gamma_q(RT1 a, RT2 z){ return boost::math::gamma_q(a, z, Policy()); }\
+\
+ template <class RT1, class RT2>\
+ inline typename boost::math::tools::promote_args<RT1, RT2>::type gamma_p(RT1 a, RT2 z){ return boost::math::gamma_p(a, z, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type tgamma_delta_ratio(T1 z, T2 delta){ return boost::math::tgamma_delta_ratio(z, delta, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type tgamma_ratio(T1 a, T2 b) { return boost::math::tgamma_ratio(a, b, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type gamma_p_derivative(T1 a, T2 x){ return boost::math::gamma_p_derivative(a, x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type gamma_p_inv(T1 a, T2 p){ return boost::math::gamma_p_inv(a, p, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type gamma_p_inva(T1 a, T2 p){ return boost::math::gamma_p_inva(a, p, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type gamma_q_inv(T1 a, T2 q){ return boost::math::gamma_q_inv(a, q, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type gamma_q_inva(T1 a, T2 q){ return boost::math::gamma_q_inva(a, q, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type digamma(T x){ return boost::math::digamma(x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ hypot(T1 x, T2 y){ return boost::math::hypot(x, y, Policy()); }\
+\
+ template <class RT>\
+ inline typename boost::math::tools::promote_args<RT>::type cbrt(RT z){ return boost::math::cbrt(z, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type log1p(T x){ return boost::math::log1p(x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type log1pmx(T x){ return boost::math::log1pmx(x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type expm1(T x){ return boost::math::expm1(x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::tools::promote_args<T1, T2>::type \
+ powm1(const T1 a, const T2 z){ return boost::math::powm1(a, z, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type sqrt1pm1(const T& val){ return boost::math::sqrt1pm1(val, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type sinc_pi(T x){ return boost::math::sinc_pi(x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::tools::promote_args<T>::type sinhc_pi(T x){ return boost::math::sinhc_pi(x, Policy()); }\
+\
+ template<typename T>\
+ inline typename boost::math::tools::promote_args<T>::type asinh(const T x){ return boost::math::asinh(x, Policy()); }\
+\
+ template<typename T>\
+ inline typename boost::math::tools::promote_args<T>::type acosh(const T x){ return boost::math::acosh(x, Policy()); }\
+\
+ template<typename T>\
+ inline typename boost::math::tools::promote_args<T>::type atanh(const T x){ return boost::math::atanh(x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::detail::bessel_traits<T1, T2, Policy >::result_type cyl_bessel_j(T1 v, T2 x)\
+ { return boost::math::cyl_bessel_j(v, x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::detail::bessel_traits<T, T, Policy >::result_type sph_bessel(unsigned v, T x)\
+ { return boost::math::sph_bessel(v, x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::detail::bessel_traits<T1, T2, Policy >::result_type \
+ cyl_bessel_i(T1 v, T2 x) { return boost::math::cyl_bessel_i(v, x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::detail::bessel_traits<T1, T2, Policy >::result_type \
+ cyl_bessel_k(T1 v, T2 x) { return boost::math::cyl_bessel_k(v, x, Policy()); }\
+\
+ template <class T1, class T2>\
+ inline typename boost::math::detail::bessel_traits<T1, T2, Policy >::result_type \
+ cyl_neumann(T1 v, T2 x){ return boost::math::cyl_neumann(v, x, Policy()); }\
+\
+ template <class T>\
+ inline typename boost::math::detail::bessel_traits<T, T, Policy >::result_type \
+ sph_neumann(unsigned v, T x){ return boost::math::sph_neumann(v, x, Policy()); }\
+\
+ template <class T>\
+ inline T sin_pi(T x){ return boost::math::sin_pi(x); }\
+\
+ template <class T>\
+ inline T cos_pi(T x){ return boost::math::cos_pi(x); }\
+\
+ using boost::math::fpclassify;\
+ using boost::math::isfinite;\
+ using boost::math::isinf;\
+ using boost::math::isnan;\
+ using boost::math::isnormal;
+
 #endif // BOOST_MATH_SPECIAL_MATH_FWD_HPP

Modified: sandbox/math_toolkit/policy/libs/math/doc/policy.qbk
==============================================================================
--- sandbox/math_toolkit/policy/libs/math/doc/policy.qbk (original)
+++ sandbox/math_toolkit/policy/libs/math/doc/policy.qbk 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -814,6 +814,93 @@
 
 [endsect]
 
+[section:namespace_pol Setting Polices at Namespace Scope]
+
+Sometimes what you really want to do is bring all the special functions,
+or all the distributions into a specific namespace-scope, along with
+a specific policy to use with them. There are two macros defined to
+assist with that:
+
+ BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(Policy)
+
+and:
+
+ BOOST_MATH_DECLARE_DISTRIBUTIONS(Type, Policy)
+
+You can use either of these macros after including any special function
+or distribution header. For example:
+
+ #include <boost/math/special_functions/gamma.hpp>
+
+ namespace myspace{
+
+ using namespace boost::math::policy;
+
+ // Define a policy that does not throw on overflow:
+ typedef policy<overflow_error<errno_on_error> > my_policy;
+
+ // Define the special functions in this scope to use the policy:
+ BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(my_policy)
+
+ }
+
+ //
+ // Now we can use myspace::tgamma etc.
+ // They will automatically use "my_policy":
+ //
+ double t = myspace::tgamma(30.0); // will not throw on overflow
+
+In this example, using BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS results in
+a set of thin inline forwarding functions being defined:
+
+ template <class T>
+ inline T tgamma(T a){ return ::boost::math::tgamma(a, mypolicy()); }
+
+ template <class T>
+ inline T lgamma(T a) ( return ::boost::math::lgamma(a, mypolicy()); }
+
+and so on. Note that a forwarding function is defined for all the special
+functions, however, unless you include the specific header for the special
+function you use (or boost/math/special_functions.hpp), you will get
+linker errors from undefined functions.
+
+We can do the same thing with the distributions, but this time we need to
+specify the floating point type to use:
+
+ #include <boost/math/distributions/cauchy.hpp>
+
+ namespace myspace{
+
+ using namespace boost::math::policy;
+
+ // Define a policy to use, in this case we want all the distribution
+ // accessor functions to compile, even if they are mathematically
+ // undefined:
+ typedef policy<assert_undefined<false> > my_policy;
+
+ BOOST_MATH_DECLARE_DISTRIBUTIONS(double, my_policy)
+
+ }
+
+ //
+ // Now we can use myspace::cauchy etc, which will use policy
+ // myspace::mypolicy:
+ //
+ // This compiles but raises a domain error at runtime:
+ //
+ double d = mean(myspace::cauchy());
+
+In this example the result of BOOST_MATH_DECLARE_DISTRIBUTIONS is to
+declare a typedef for each distribution like this:
+
+ typedef boost::math::cauchy_distribution<double, my_policy> cauchy;
+ tyepdef boost::math::gamma_distribution<double, my_policy> gamma;
+
+and so on. The name given to each typedef is the name of the distribution
+with the "_distribution" suffix removed.
+
+[endsect]
+
 [endsect]
 
 [endsect]

Modified: sandbox/math_toolkit/policy/libs/math/test/compile_test/instantiate.hpp
==============================================================================
--- sandbox/math_toolkit/policy/libs/math/test/compile_test/instantiate.hpp (original)
+++ sandbox/math_toolkit/policy/libs/math/test/compile_test/instantiate.hpp 2007-07-22 13:25:41 EDT (Sun, 22 Jul 2007)
@@ -11,51 +11,19 @@
 # define BOOST_MATH_ASSERT_UNDEFINED_POLICY false
 #endif
 
-#include <boost/math/distributions/bernoulli.hpp>
-#include <boost/math/distributions/beta.hpp>
-#include <boost/math/distributions/binomial.hpp>
-#include <boost/math/distributions/cauchy.hpp>
-#include <boost/math/distributions/chi_squared.hpp>
-#include <boost/math/distributions/exponential.hpp>
-#include <boost/math/distributions/extreme_value.hpp>
-#include <boost/math/distributions/fisher_f.hpp>
-#include <boost/math/distributions/gamma.hpp>
-#include <boost/math/distributions/lognormal.hpp>
-#include <boost/math/distributions/negative_binomial.hpp>
-#include <boost/math/distributions/normal.hpp>
-#include <boost/math/distributions/pareto.hpp>
-#include <boost/math/distributions/poisson.hpp>
-#include <boost/math/distributions/rayleigh.hpp>
-#include <boost/math/distributions/students_t.hpp>
-#include <boost/math/distributions/triangular.hpp>
-#include <boost/math/distributions/uniform.hpp>
-#include <boost/math/distributions/weibull.hpp>
-
-#include <boost/math/special_functions/digamma.hpp>
-#include <boost/math/special_functions/cbrt.hpp>
-#include <boost/math/special_functions/legendre.hpp>
-#include <boost/math/special_functions/laguerre.hpp>
-#include <boost/math/special_functions/hermite.hpp>
-#include <boost/math/special_functions/spherical_harmonic.hpp>
-#include <boost/math/special_functions/ellint_1.hpp>
-#include <boost/math/special_functions/ellint_2.hpp>
-#include <boost/math/special_functions/ellint_3.hpp>
-#include <boost/math/special_functions/ellint_rc.hpp>
-#include <boost/math/special_functions/ellint_rd.hpp>
-#include <boost/math/special_functions/ellint_rf.hpp>
-#include <boost/math/special_functions/ellint_rj.hpp>
-#include <boost/math/special_functions/hypot.hpp>
-#include <boost/math/special_functions/sinc.hpp>
-#include <boost/math/special_functions/sinhc.hpp>
-#include <boost/math/special_functions/asinh.hpp>
-#include <boost/math/special_functions/acosh.hpp>
-#include <boost/math/special_functions/atanh.hpp>
-#include <boost/math/special_functions/sin_pi.hpp>
-#include <boost/math/special_functions/cos_pi.hpp>
-#include <boost/math/special_functions/bessel.hpp>
+#include <boost/math/distributions.hpp>
 
+#include <boost/math/special_functions.hpp>
 #include <boost/math/concepts/distributions.hpp>
 
+typedef boost::math::policy::policy<> test_policy;
+
+namespace test{
+
+BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(test_policy)
+
+}
+
 template <class RealType>
 void instantiate(RealType)
 {
@@ -83,6 +51,26 @@
    function_requires<DistributionConcept<uniform_distribution<RealType> > >();
    function_requires<DistributionConcept<weibull_distribution<RealType> > >();
 
+ function_requires<DistributionConcept<bernoulli_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<beta_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<binomial_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<cauchy_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<chi_squared_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<exponential_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<extreme_value_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<fisher_f_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<gamma_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<lognormal_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<negative_binomial_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<normal_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<rayleigh_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<pareto_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<poisson_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<students_t_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<triangular_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<uniform_distribution<RealType, test_policy> > >();
+ function_requires<DistributionConcept<weibull_distribution<RealType, test_policy> > >();
+
    int i;
    RealType v1(0.5), v2(0.5), v3(0.5);
    boost::math::tgamma(v1);
@@ -176,6 +164,195 @@
    boost::math::sph_bessel(i, 1);
    boost::math::sph_neumann(i, v2);
    boost::math::sph_neumann(i, i);
+ //
+ // All over again, with a policy this time:
+ //
+ test_policy pol;
+ boost::math::tgamma(v1, pol);
+ boost::math::tgamma1pm1(v1, pol);
+ boost::math::lgamma(v1, pol);
+ boost::math::lgamma(v1, &i, pol);
+ boost::math::digamma(v1, pol);
+ boost::math::tgamma_ratio(v1, v2, pol);
+ boost::math::tgamma_delta_ratio(v1, v2, pol);
+ boost::math::factorial<RealType>(i, pol);
+ boost::math::unchecked_factorial<RealType>(i);
+ i = boost::math::max_factorial<RealType>::value;
+ boost::math::double_factorial<RealType>(i, pol);
+ boost::math::rising_factorial(v1, i, pol);
+ boost::math::falling_factorial(v1, i, pol);
+ boost::math::tgamma(v1, v2, pol);
+ boost::math::tgamma_lower(v1, v2, pol);
+ boost::math::gamma_p(v1, v2, pol);
+ boost::math::gamma_q(v1, v2, pol);
+ boost::math::gamma_p_inv(v1, v2, pol);
+ boost::math::gamma_q_inv(v1, v2, pol);
+ boost::math::gamma_p_inva(v1, v2, pol);
+ boost::math::gamma_q_inva(v1, v2, pol);
+ boost::math::erf(v1, pol);
+ boost::math::erfc(v1, pol);
+ boost::math::erf_inv(v1, pol);
+ boost::math::erfc_inv(v1, pol);
+ boost::math::beta(v1, v2, pol);
+ boost::math::beta(v1, v2, v3, pol);
+ boost::math::betac(v1, v2, v3, pol);
+ boost::math::ibeta(v1, v2, v3, pol);
+ boost::math::ibetac(v1, v2, v3, pol);
+ boost::math::ibeta_inv(v1, v2, v3, pol);
+ boost::math::ibetac_inv(v1, v2, v3, pol);
+ boost::math::ibeta_inva(v1, v2, v3, pol);
+ boost::math::ibetac_inva(v1, v2, v3, pol);
+ boost::math::ibeta_invb(v1, v2, v3, pol);
+ boost::math::ibetac_invb(v1, v2, v3, pol);
+ boost::math::gamma_p_derivative(v2, v3, pol);
+ boost::math::ibeta_derivative(v1, v2, v3, pol);
+ boost::math::fpclassify(v1);
+ boost::math::isfinite(v1);
+ boost::math::isnormal(v1);
+ boost::math::isnan(v1);
+ boost::math::isinf(v1);
+ boost::math::log1p(v1, pol);
+ boost::math::expm1(v1, pol);
+ boost::math::cbrt(v1, pol);
+ boost::math::sqrt1pm1(v1, pol);
+ boost::math::powm1(v1, v2, pol);
+ boost::math::legendre_p(1, v1, pol);
+ boost::math::legendre_p(1, 0, v1, pol);
+ boost::math::legendre_q(1, v1, pol);
+ boost::math::legendre_next(2, v1, v2, v3);
+ boost::math::legendre_next(2, 2, v1, v2, v3);
+ boost::math::laguerre(1, v1, pol);
+ boost::math::laguerre(2, 1, v1, pol);
+ boost::math::laguerre_next(2, v1, v2, v3);
+ boost::math::laguerre_next(2, 1, v1, v2, v3);
+ boost::math::hermite(1, v1, pol);
+ boost::math::hermite_next(2, v1, v2, v3);
+ boost::math::spherical_harmonic_r(2, 1, v1, v2, pol);
+ boost::math::spherical_harmonic_i(2, 1, v1, v2, pol);
+ boost::math::ellint_1(v1, pol);
+ boost::math::ellint_1(v1, v2, pol);
+ boost::math::ellint_2(v1, pol);
+ boost::math::ellint_2(v1, v2, pol);
+ boost::math::ellint_3(v1, v2, pol);
+ boost::math::ellint_3(v1, v2, v3, pol);
+ boost::math::ellint_rc(v1, v2, pol);
+ boost::math::ellint_rd(v1, v2, v3, pol);
+ boost::math::ellint_rf(v1, v2, v3, pol);
+ boost::math::ellint_rj(v1, v2, v3, v1, pol);
+ boost::math::hypot(v1, v2, pol);
+ boost::math::sinc_pi(v1, pol);
+ boost::math::sinhc_pi(v1, pol);
+ boost::math::asinh(v1, pol);
+ boost::math::acosh(v1, pol);
+ boost::math::atanh(v1, pol);
+ boost::math::sin_pi(v1, pol);
+ boost::math::cos_pi(v1, pol);
+ boost::math::cyl_neumann(v1, v2, pol);
+ boost::math::cyl_neumann(i, v2, pol);
+ boost::math::cyl_bessel_j(v1, v2, pol);
+ boost::math::cyl_bessel_j(i, v2, pol);
+ boost::math::cyl_bessel_i(v1, v2, pol);
+ boost::math::cyl_bessel_i(i, v2, pol);
+ boost::math::cyl_bessel_k(v1, v2, pol);
+ boost::math::cyl_bessel_k(i, v2, pol);
+ boost::math::sph_bessel(i, v2, pol);
+ boost::math::sph_bessel(i, 1, pol);
+ boost::math::sph_neumann(i, v2, pol);
+ boost::math::sph_neumann(i, i, pol);
+ //
+ // All over again with the versions in test::
+ //
+ test::tgamma(v1);
+ test::tgamma1pm1(v1);
+ test::lgamma(v1);
+ test::lgamma(v1, &i);
+ test::digamma(v1);
+ test::tgamma_ratio(v1, v2);
+ test::tgamma_delta_ratio(v1, v2);
+ test::factorial<RealType>(i);
+ test::unchecked_factorial<RealType>(i);
+ i = test::max_factorial<RealType>::value;
+ test::double_factorial<RealType>(i);
+ test::rising_factorial(v1, i);
+ test::falling_factorial(v1, i);
+ test::tgamma(v1, v2);
+ test::tgamma_lower(v1, v2);
+ test::gamma_p(v1, v2);
+ test::gamma_q(v1, v2);
+ test::gamma_p_inv(v1, v2);
+ test::gamma_q_inv(v1, v2);
+ test::gamma_p_inva(v1, v2);
+ test::gamma_q_inva(v1, v2);
+ test::erf(v1);
+ test::erfc(v1);
+ test::erf_inv(v1);
+ test::erfc_inv(v1);
+ test::beta(v1, v2);
+ test::beta(v1, v2, v3);
+ test::betac(v1, v2, v3);
+ test::ibeta(v1, v2, v3);
+ test::ibetac(v1, v2, v3);
+ test::ibeta_inv(v1, v2, v3);
+ test::ibetac_inv(v1, v2, v3);
+ test::ibeta_inva(v1, v2, v3);
+ test::ibetac_inva(v1, v2, v3);
+ test::ibeta_invb(v1, v2, v3);
+ test::ibetac_invb(v1, v2, v3);
+ test::gamma_p_derivative(v2, v3);
+ test::ibeta_derivative(v1, v2, v3);
+ test::fpclassify(v1);
+ test::isfinite(v1);
+ test::isnormal(v1);
+ test::isnan(v1);
+ test::isinf(v1);
+ test::log1p(v1);
+ test::expm1(v1);
+ test::cbrt(v1);
+ test::sqrt1pm1(v1);
+ test::powm1(v1, v2);
+ test::legendre_p(1, v1);
+ test::legendre_p(1, 0, v1);
+ test::legendre_q(1, v1);
+ test::legendre_next(2, v1, v2, v3);
+ test::legendre_next(2, 2, v1, v2, v3);
+ test::laguerre(1, v1);
+ test::laguerre(2, 1, v1);
+ test::laguerre_next(2, v1, v2, v3);
+ test::laguerre_next(2, 1, v1, v2, v3);
+ test::hermite(1, v1);
+ test::hermite_next(2, v1, v2, v3);
+ test::spherical_harmonic_r(2, 1, v1, v2);
+ test::spherical_harmonic_i(2, 1, v1, v2);
+ test::ellint_1(v1);
+ test::ellint_1(v1, v2);
+ test::ellint_2(v1);
+ test::ellint_2(v1, v2);
+ test::ellint_3(v1, v2);
+ test::ellint_3(v1, v2, v3);
+ test::ellint_rc(v1, v2);
+ test::ellint_rd(v1, v2, v3);
+ test::ellint_rf(v1, v2, v3);
+ test::ellint_rj(v1, v2, v3, v1);
+ test::hypot(v1, v2);
+ test::sinc_pi(v1);
+ test::sinhc_pi(v1);
+ test::asinh(v1);
+ test::acosh(v1);
+ test::atanh(v1);
+ test::sin_pi(v1);
+ test::cos_pi(v1);
+ test::cyl_neumann(v1, v2);
+ test::cyl_neumann(i, v2);
+ test::cyl_bessel_j(v1, v2);
+ test::cyl_bessel_j(i, v2);
+ test::cyl_bessel_i(v1, v2);
+ test::cyl_bessel_i(i, v2);
+ test::cyl_bessel_k(v1, v2);
+ test::cyl_bessel_k(i, v2);
+ test::sph_bessel(i, v2);
+ test::sph_bessel(i, 1);
+ test::sph_neumann(i, v2);
+ test::sph_neumann(i, i);
 }
 
 


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