|
Boost-Commit : |
From: john_at_[hidden]
Date: 2007-08-14 06:38:54
Author: johnmaddock
Date: 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
New Revision: 38649
URL: http://svn.boost.org/trac/boost/changeset/38649
Log:
Reinstated tools::digits<>(): it has it's uses as a default backup used by policy::digits<>(), and makes the conceptual requirement a lot easier.
Text files modified:
sandbox/math_toolkit/boost/math/concepts/real_concept.hpp | 43 +++++----------------------------------
sandbox/math_toolkit/boost/math/concepts/std_real_concept.hpp | 15 ++-----------
sandbox/math_toolkit/boost/math/policy/policy.hpp | 21 +++++++++++++++++-
sandbox/math_toolkit/boost/math/tools/ntl.hpp | 14 +-----------
sandbox/math_toolkit/boost/math/tools/precision.hpp | 11 ++++++++++
5 files changed, 41 insertions(+), 63 deletions(-)
Modified: sandbox/math_toolkit/boost/math/concepts/real_concept.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/concepts/real_concept.hpp (original)
+++ sandbox/math_toolkit/boost/math/concepts/real_concept.hpp 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
@@ -323,15 +323,12 @@
return tools::epsilon<long double>();
}
-} // namespace tools
-
-namespace policies{
-
template <>
-inline int digits<concepts::real_concept, policy<> >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ // Assume number of significand bits is same as long double,
- // unless std::numeric_limits<T>::is_specialized to provide digits.
- return boost::math::policies::digits<long double, boost::math::policies::policy<> >();
+inline int digits<concepts::real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
+{
+ // Assume number of significand bits is same as long double,
+ // unless std::numeric_limits<T>::is_specialized to provide digits.
+ return tools::digits<long double>();
// Note that if numeric_limits real concept is NOT specialized to provide digits10
// (or max_digits10) then the default precision of 6 decimal digits will be used
// by Boost test (giving misleading error messages like
@@ -339,35 +336,7 @@
// and by Boost lexical cast and serialization causing loss of accuracy.
}
-template <>
-inline int digits<concepts::real_concept, policy<detail::forwarding_arg1, detail::forwarding_arg2 > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<real> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<integer_round_down> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<integer_round_up> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<integer_round_outwards> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<integer_round_inwards> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-template <>
-inline int digits<concepts::real_concept, policy<discrete_quantile<integer_round_nearest> > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
-{ return digits<concepts::real_concept, policy<> >(); }
-
-}
+} // namespace tools
} // namespace math
} // namespace boost
Modified: sandbox/math_toolkit/boost/math/concepts/std_real_concept.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/concepts/std_real_concept.hpp (original)
+++ sandbox/math_toolkit/boost/math/concepts/std_real_concept.hpp 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
@@ -329,23 +329,14 @@
return tools::epsilon<long double>();
}
-} // namespace tools
-
-namespace policies{
-
template <>
-inline int digits<concepts::std_real_concept, boost::math::policies::policy<> >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
+inline int digits<concepts::std_real_concept>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
{ // Assume number of significand bits is same as long double,
// unless std::numeric_limits<T>::is_specialized to provide digits.
- return digits<long double, policy<> >();
-}
-template <>
-inline int digits<concepts::std_real_concept, policy<detail::forwarding_arg1, detail::forwarding_arg2 > >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept))
-{ return digits<concepts::std_real_concept, policy<> >(); }
-
-
+ return digits<long double>();
}
+} // namespace tools
} // namespace math
} // namespace boost
Modified: sandbox/math_toolkit/boost/math/policy/policy.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/policy/policy.hpp (original)
+++ sandbox/math_toolkit/boost/math/policy/policy.hpp 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
@@ -653,18 +653,35 @@
>::type type;
};
+namespace detail{
+
template <class T, class Policy>
-inline int digits(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
+inline int digits_imp(mpl::true_ const&)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
#else
BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
#endif
- typedef typename precision<T, Policy>::type p_t;
+ typedef typename boost::math::policies::precision<T, Policy>::type p_t;
return p_t::value;
}
+template <class T, class Policy>
+inline int digits_imp(mpl::false_ const&)
+{
+ return tools::digits<T>();
+}
+
+} // namespace detail
+
+template <class T, class Policy>
+inline int digits()
+{
+ typedef mpl::bool_< std::numeric_limits<T>::is_specialized > tag_type;
+ return detail::digits_imp<T, Policy>(tag_type());
+}
+
namespace detail{
template <class A1,
Modified: sandbox/math_toolkit/boost/math/tools/ntl.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/ntl.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/ntl.hpp 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
@@ -62,24 +62,14 @@
namespace boost{ namespace math{
-namespace policies{
-
-template<>
-inline int digits<NTL::RR, boost::math::policies::policy<> >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(NTL::RR))
-{
- return NTL::RR::precision();
-}
+namespace tools{
template<>
-inline int digits<NTL::RR, boost::math::policies::policy<boost::math::policies::detail::forwarding_arg1, boost::math::policies::detail::forwarding_arg2> >(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(NTL::RR))
+inline int digits<NTL::RR>(BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(NTL::RR))
{
return NTL::RR::precision();
}
-}
-
-namespace tools{
-
template <>
inline float real_cast<float, NTL::RR>(NTL::RR t)
{
Modified: sandbox/math_toolkit/boost/math/tools/precision.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/precision.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/precision.hpp 2007-08-14 06:38:54 EDT (Tue, 14 Aug 2007)
@@ -34,6 +34,17 @@
// See Conceptual Requirements for Real Number Types.
template <class T>
+inline int digits(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
+{
+#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
+ BOOST_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
+#else
+ BOOST_ASSERT(::std::numeric_limits<T>::is_specialized);
+#endif
+ return std::numeric_limits<T>::digits;
+}
+
+template <class T>
inline T max_value(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
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