Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49405 - in sandbox/math_toolkit: boost/math/policies boost/math/tools libs/math/doc/sf_and_dist libs/math/src/tr1
From: john_at_[hidden]
Date: 2008-10-20 12:54:25


Author: johnmaddock
Date: 2008-10-20 12:54:24 EDT (Mon, 20 Oct 2008)
New Revision: 49405
URL: http://svn.boost.org/trac/boost/changeset/49405

Log:
Added some specializations of the policy classes to reduce compile times.
Updated history.
Text files modified:
   sandbox/math_toolkit/boost/math/policies/policy.hpp | 17 ++++++
   sandbox/math_toolkit/boost/math/tools/promotion.hpp | 24 +++++++++
   sandbox/math_toolkit/libs/math/doc/sf_and_dist/roadmap.qbk | 5 +
   sandbox/math_toolkit/libs/math/src/tr1/c_policy.hpp | 106 +++++++++++++++++++++++++++++++++++++++
   4 files changed, 150 insertions(+), 2 deletions(-)

Modified: sandbox/math_toolkit/boost/math/policies/policy.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/policies/policy.hpp (original)
+++ sandbox/math_toolkit/boost/math/policies/policy.hpp 2008-10-20 12:54:24 EDT (Mon, 20 Oct 2008)
@@ -603,6 +603,23 @@
    typedef policy<detail::forwarding_arg1, detail::forwarding_arg2> type;
 };
 
+template <>
+struct normalise<policy<detail::forwarding_arg1, detail::forwarding_arg2>,
+ promote_float<false>,
+ promote_double<false>,
+ discrete_quantile<>,
+ assert_undefined<>,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy>
+{
+ typedef policy<detail::forwarding_arg1, detail::forwarding_arg2> type;
+};
+
 inline policy<> make_policy()
 { return policy<>(); }
 

Modified: sandbox/math_toolkit/boost/math/tools/promotion.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/promotion.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/promotion.hpp 2008-10-20 12:54:24 EDT (Mon, 20 Oct 2008)
@@ -69,6 +69,12 @@
       { // If T is integral type, then promote to double.
         typedef typename mpl::if_<is_integral<T>, double, T>::type type;
       };
+ // These full specialisations reduce mpl::if_ usage and speed up
+ // compilation:
+ template <> struct promote_arg<float> { typedef float type; };
+ template <> struct promote_arg<double>{ typedef double type; };
+ template <> struct promote_arg<long double> { typedef long double type; };
+ template <> struct promote_arg<int> { typedef double type; };
 
       template <class T1, class T2>
       struct promote_args_2
@@ -89,6 +95,24 @@
           // else one or the other is a user-defined type:
           typename mpl::if_< ::boost::is_convertible<T1P, T2P>, T2P, T1P>::type>::type type;
       }; // promote_arg2
+ // These full specialisations reduce mpl::if_ usage and speed up
+ // compilation:
+ template <> struct promote_args_2<float, float> { typedef float type; };
+ template <> struct promote_args_2<double, double>{ typedef double type; };
+ template <> struct promote_args_2<long double, long double> { typedef long double type; };
+ template <> struct promote_args_2<int, int> { typedef double type; };
+ template <> struct promote_args_2<int, float> { typedef double type; };
+ template <> struct promote_args_2<float, int> { typedef double type; };
+ template <> struct promote_args_2<int, double> { typedef double type; };
+ template <> struct promote_args_2<double, int> { typedef double type; };
+ template <> struct promote_args_2<int, long double> { typedef long double type; };
+ template <> struct promote_args_2<long double, int> { typedef long double type; };
+ template <> struct promote_args_2<float, double> { typedef double type; };
+ template <> struct promote_args_2<double, float> { typedef double type; };
+ template <> struct promote_args_2<float, long double> { typedef long double type; };
+ template <> struct promote_args_2<long double, float> { typedef long double type; };
+ template <> struct promote_args_2<double, long double> { typedef long double type; };
+ template <> struct promote_args_2<long double, double> { typedef long double type; };
 
       template <class T1, class T2=float, class T3=float, class T4=float, class T5=float, class T6=float>
       struct promote_args

Modified: sandbox/math_toolkit/libs/math/doc/sf_and_dist/roadmap.qbk
==============================================================================
--- sandbox/math_toolkit/libs/math/doc/sf_and_dist/roadmap.qbk (original)
+++ sandbox/math_toolkit/libs/math/doc/sf_and_dist/roadmap.qbk 2008-10-20 12:54:24 EDT (Mon, 20 Oct 2008)
@@ -1,5 +1,10 @@
 [template history[]
 
+[h4 Boost-1.38.0]
+
+* Added support for MPFR as a bignum type.
+* Added some full specializations of the policy classes to reduce compile times.
+
 [h4 Boost-1.37.0]
 
 * Improved accuracy and testing of the inverse hypergeometric functions.

Modified: sandbox/math_toolkit/libs/math/src/tr1/c_policy.hpp
==============================================================================
--- sandbox/math_toolkit/libs/math/src/tr1/c_policy.hpp (original)
+++ sandbox/math_toolkit/libs/math/src/tr1/c_policy.hpp 2008-10-20 12:54:24 EDT (Mon, 20 Oct 2008)
@@ -6,6 +6,108 @@
 #include <boost/math/policies/policy.hpp>
 #include <boost/math/special_functions/math_fwd.hpp>
 
+namespace boost{ namespace math{ namespace policies{
+
+template <>
+struct policy<
+ domain_error<errno_on_error>,
+ pole_error<errno_on_error>,
+ overflow_error<errno_on_error>,
+ evaluation_error<errno_on_error>,
+ rounding_error<errno_on_error>,
+ default_policy, default_policy, default_policy, default_policy, default_policy, default_policy>
+{
+public:
+ typedef domain_error<errno_on_error> domain_error_type;
+ typedef pole_error<errno_on_error> pole_error_type;
+ typedef overflow_error<errno_on_error> overflow_error_type;
+ typedef underflow_error<errno_on_error> underflow_error_type;
+ typedef denorm_error<errno_on_error> denorm_error_type;
+ typedef evaluation_error<errno_on_error> evaluation_error_type;
+ typedef rounding_error<errno_on_error> rounding_error_type;
+ typedef indeterminate_result_error<> indeterminate_result_error_type;
+#if BOOST_MATH_DIGITS10_POLICY == 0
+ typedef digits2<> precision_type;
+#else
+ typedef detail::precision<digits10<>, digits2<> >::type precision_type;
+#endif
+ typedef promote_float<> promote_float_type;
+ typedef promote_double<> promote_double_type;
+ typedef discrete_quantile<> discrete_quantile_type;
+ typedef assert_undefined<> assert_undefined_type;
+ typedef max_series_iterations<> max_series_iterations_type;
+ typedef max_root_iterations<> max_root_iterations_type;
+};
+
+template <>
+struct policy<
+ domain_error<errno_on_error>,
+ pole_error<errno_on_error>,
+ overflow_error<errno_on_error>,
+ evaluation_error<errno_on_error>,
+ rounding_error<errno_on_error>,
+ detail::forwarding_arg1,
+ detail::forwarding_arg2,
+ default_policy, default_policy, default_policy, default_policy, default_policy, default_policy>
+{
+public:
+ typedef domain_error<errno_on_error> domain_error_type;
+ typedef pole_error<errno_on_error> pole_error_type;
+ typedef overflow_error<errno_on_error> overflow_error_type;
+ typedef underflow_error<errno_on_error> underflow_error_type;
+ typedef denorm_error<errno_on_error> denorm_error_type;
+ typedef evaluation_error<errno_on_error> evaluation_error_type;
+ typedef rounding_error<errno_on_error> rounding_error_type;
+ typedef indeterminate_result_error<> indeterminate_result_error_type;
+#if BOOST_MATH_DIGITS10_POLICY == 0
+ typedef digits2<> precision_type;
+#else
+ typedef detail::precision<digits10<>, digits2<> >::type precision_type;
+#endif
+ typedef promote_float<false> promote_float_type;
+ typedef promote_double<false> promote_double_type;
+ typedef discrete_quantile<> discrete_quantile_type;
+ typedef assert_undefined<> assert_undefined_type;
+ typedef max_series_iterations<> max_series_iterations_type;
+ typedef max_root_iterations<> max_root_iterations_type;
+};
+
+template <>
+struct normalise<policy<domain_error<errno_on_error>, pole_error<errno_on_error>, overflow_error<errno_on_error>, evaluation_error<errno_on_error>, rounding_error<errno_on_error> >,
+ promote_float<false>,
+ promote_double<false>,
+ discrete_quantile<>,
+ assert_undefined<>,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy>
+{
+ typedef policy<domain_error<errno_on_error>, pole_error<errno_on_error>, overflow_error<errno_on_error>, evaluation_error<errno_on_error>, rounding_error<errno_on_error>, detail::forwarding_arg1, detail::forwarding_arg2> type;
+};
+
+template <>
+struct normalise<policy<domain_error<errno_on_error>, pole_error<errno_on_error>, overflow_error<errno_on_error>, evaluation_error<errno_on_error>, rounding_error<errno_on_error>, detail::forwarding_arg1, detail::forwarding_arg2 >,
+ promote_float<false>,
+ promote_double<false>,
+ discrete_quantile<>,
+ assert_undefined<>,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy,
+ default_policy>
+{
+ typedef policy<domain_error<errno_on_error>, pole_error<errno_on_error>, overflow_error<errno_on_error>, evaluation_error<errno_on_error>, rounding_error<errno_on_error>, detail::forwarding_arg1, detail::forwarding_arg2> type;
+};
+
+}}} // namespaces
+
 namespace c_policies{
 
 using boost::math::policies::policy;
@@ -20,8 +122,8 @@
    domain_error<errno_on_error>,
    pole_error<errno_on_error>,
    overflow_error<errno_on_error>,
- rounding_error<errno_on_error>,
- evaluation_error<errno_on_error>
+ evaluation_error<errno_on_error>,
+ rounding_error<errno_on_error>
> c_policy;
 
 BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS(c_policy)


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