diff --git a/include/boost/math/concepts/real_concept.hpp b/include/boost/math/concepts/real_concept.hpp index 420545daf..a419d96cc 100644 --- a/include/boost/math/concepts/real_concept.hpp +++ b/include/boost/math/concepts/real_concept.hpp @@ -237,6 +237,47 @@ inline real_concept sqrt(real_concept a) inline real_concept tanh(real_concept a) { return std::tanh(a.value()); } +// +// Conversion and truncation routines: +// +template +inline int iround(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::iround(v.value(), pol); } +inline int iround(const concepts::real_concept& v) +{ return boost::math::iround(v.value(), policies::policy<>()); } +template +inline long lround(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::lround(v.value(), pol); } +inline long lround(const concepts::real_concept& v) +{ return boost::math::lround(v.value(), policies::policy<>()); } + +#ifdef BOOST_HAS_LONG_LONG +template +inline long long llround(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::llround(v.value(), pol); } +inline long long llround(const concepts::real_concept& v) +{ return boost::math::llround(v.value(), policies::policy<>()); } +#endif + +template +inline int itrunc(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::itrunc(v.value(), pol); } +inline int itrunc(const concepts::real_concept& v) +{ return boost::math::itrunc(v.value(), policies::policy<>()); } +template +inline long ltrunc(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::ltrunc(v.value(), pol); } +inline long ltrunc(const concepts::real_concept& v) +{ return boost::math::ltrunc(v.value(), policies::policy<>()); } + +#ifdef BOOST_HAS_LONG_LONG +template +inline long long lltrunc(const concepts::real_concept& v, const Policy& pol) +{ return boost::math::lltrunc(v.value(), pol); } +inline long long lltrunc(const concepts::real_concept& v) +{ return boost::math::lltrunc(v.value(), policies::policy<>()); } +#endif + // Streaming: template inline std::basic_ostream& operator<<(std::basic_ostream& os, const real_concept& a) @@ -324,77 +365,6 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC } // namespace tools -// -// Conversion and truncation routines: -// -template -inline int iround(const concepts::real_concept& v, const Policy& pol) -{ - return iround(v.value(), pol); -} -inline int iround(const concepts::real_concept& v) -{ - return iround(v.value(), policies::policy<>()); -} - -template -inline long lround(const concepts::real_concept& v, const Policy& pol) -{ - return lround(v.value(), pol); -} -inline long lround(const concepts::real_concept& v) -{ - return lround(v.value(), policies::policy<>()); -} - -#ifdef BOOST_HAS_LONG_LONG - -template -inline long long llround(const concepts::real_concept& v, const Policy& pol) -{ - return llround(v.value(), pol); -} -inline long long llround(const concepts::real_concept& v) -{ - return llround(v.value(), policies::policy<>()); -} - -#endif - -template -inline int itrunc(const concepts::real_concept& v, const Policy& pol) -{ - return itrunc(v.value(), pol); -} -inline int itrunc(const concepts::real_concept& v) -{ - return itrunc(v.value(), policies::policy<>()); -} - -template -inline long ltrunc(const concepts::real_concept& v, const Policy& pol) -{ - return ltrunc(v.value(), pol); -} -inline long ltrunc(const concepts::real_concept& v) -{ - return ltrunc(v.value(), policies::policy<>()); -} - -#ifdef BOOST_HAS_LONG_LONG - -template -inline long long lltrunc(const concepts::real_concept& v, const Policy& pol) -{ - return lltrunc(v.value(), pol); -} -inline long long lltrunc(const concepts::real_concept& v) -{ - return lltrunc(v.value(), policies::policy<>()); -} - -#endif - #if defined(__SGI_STL_PORT) // // We shouldn't really need these type casts any more, but there are some diff --git a/include/boost/math/concepts/std_real_concept.hpp b/include/boost/math/concepts/std_real_concept.hpp index 25408575b..00391c644 100644 --- a/include/boost/math/concepts/std_real_concept.hpp +++ b/include/boost/math/concepts/std_real_concept.hpp @@ -223,6 +223,77 @@ inline boost::math::concepts::std_real_concept tanh(boost::math::concepts::std_r namespace boost{ namespace math{ namespace concepts{ +// +// Conversion and truncation routines: +// +template +inline int iround(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::iround(v.value(), pol); +} +inline int iround(const concepts::std_real_concept& v) +{ + return boost::math::iround(v.value(), policies::policy<>()); +} + +template +inline long lround(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::lround(v.value(), pol); +} +inline long lround(const concepts::std_real_concept& v) +{ + return boost::math::lround(v.value(), policies::policy<>()); +} + +#ifdef BOOST_HAS_LONG_LONG + +template +inline long long llround(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::llround(v.value(), pol); +} +inline long long llround(const concepts::std_real_concept& v) +{ + return boost::math::llround(v.value(), policies::policy<>()); +} + +#endif + +template +inline int itrunc(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::itrunc(v.value(), pol); +} +inline int itrunc(const concepts::std_real_concept& v) +{ + return boost::math::itrunc(v.value(), policies::policy<>()); +} + +template +inline long ltrunc(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::ltrunc(v.value(), pol); +} +inline long ltrunc(const concepts::std_real_concept& v) +{ + return boost::math::ltrunc(v.value(), policies::policy<>()); +} + +#ifdef BOOST_HAS_LONG_LONG + +template +inline long long lltrunc(const concepts::std_real_concept& v, const Policy& pol) +{ + return boost::math::lltrunc(v.value(), pol); +} +inline long long lltrunc(const concepts::std_real_concept& v) +{ + return boost::math::lltrunc(v.value(), policies::policy<>()); +} + +#endif + // Streaming: template inline std::basic_ostream& operator<<(std::basic_ostream& os, const std_real_concept& a) @@ -282,77 +353,6 @@ inline int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_ } // namespace tools -// -// Conversion and truncation routines: -// -template -inline int iround(const concepts::std_real_concept& v, const Policy& pol) -{ - return iround(v.value(), pol); -} -inline int iround(const concepts::std_real_concept& v) -{ - return iround(v.value(), policies::policy<>()); -} - -template -inline long lround(const concepts::std_real_concept& v, const Policy& pol) -{ - return lround(v.value(), pol); -} -inline long lround(const concepts::std_real_concept& v) -{ - return lround(v.value(), policies::policy<>()); -} - -#ifdef BOOST_HAS_LONG_LONG - -template -inline long long llround(const concepts::std_real_concept& v, const Policy& pol) -{ - return llround(v.value(), pol); -} -inline long long llround(const concepts::std_real_concept& v) -{ - return llround(v.value(), policies::policy<>()); -} - -#endif - -template -inline int itrunc(const concepts::std_real_concept& v, const Policy& pol) -{ - return itrunc(v.value(), pol); -} -inline int itrunc(const concepts::std_real_concept& v) -{ - return itrunc(v.value(), policies::policy<>()); -} - -template -inline long ltrunc(const concepts::std_real_concept& v, const Policy& pol) -{ - return ltrunc(v.value(), pol); -} -inline long ltrunc(const concepts::std_real_concept& v) -{ - return ltrunc(v.value(), policies::policy<>()); -} - -#ifdef BOOST_HAS_LONG_LONG - -template -inline long long lltrunc(const concepts::std_real_concept& v, const Policy& pol) -{ - return lltrunc(v.value(), pol); -} -inline long long lltrunc(const concepts::std_real_concept& v) -{ - return lltrunc(v.value(), policies::policy<>()); -} - -#endif - } // namespace math } // namespace boost diff --git a/include/boost/math/special_functions/detail/round_fwd.hpp b/include/boost/math/special_functions/detail/round_fwd.hpp new file mode 100644 index 000000000..0f5fb0c49 --- /dev/null +++ b/include/boost/math/special_functions/detail/round_fwd.hpp @@ -0,0 +1,80 @@ +// Copyright John Maddock 2008. + +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_MATH_SPECIAL_ROUND_FWD_HPP +#define BOOST_MATH_SPECIAL_ROUND_FWD_HPP + +#include + +#ifdef _MSC_VER +#pragma once +#endif + +namespace boost +{ + namespace math + { + + template + T trunc(const T& v, const Policy& pol); + template + T trunc(const T& v); + template + int itrunc(const T& v, const Policy& pol); + template + int itrunc(const T& v); + template + long ltrunc(const T& v, const Policy& pol); + template + long ltrunc(const T& v); +#ifdef BOOST_HAS_LONG_LONG + template + long long lltrunc(const T& v, const Policy& pol); + template + long long lltrunc(const T& v); +#endif + template + T round(const T& v, const Policy& pol); + template + T round(const T& v); + template + int iround(const T& v, const Policy& pol); + template + int iround(const T& v); + template + long lround(const T& v, const Policy& pol); + template + long lround(const T& v); +#ifdef BOOST_HAS_LONG_LONG + template + long long llround(const T& v, const Policy& pol); + template + long long llround(const T& v); +#endif + template + T modf(const T& v, T* ipart, const Policy& pol); + template + T modf(const T& v, T* ipart); + template + T modf(const T& v, int* ipart, const Policy& pol); + template + T modf(const T& v, int* ipart); + template + T modf(const T& v, long* ipart, const Policy& pol); + template + T modf(const T& v, long* ipart); +#ifdef BOOST_HAS_LONG_LONG + template + T modf(const T& v, long long* ipart, const Policy& pol); + template + T modf(const T& v, long long* ipart); +#endif + + } +} +#endif // BOOST_MATH_SPECIAL_ROUND_FWD_HPP + diff --git a/include/boost/math/special_functions/math_fwd.hpp b/include/boost/math/special_functions/math_fwd.hpp index 1c810b4c0..947b182b3 100644 --- a/include/boost/math/special_functions/math_fwd.hpp +++ b/include/boost/math/special_functions/math_fwd.hpp @@ -23,6 +23,7 @@ #pragma once #endif +#include #include // for argument promotion. #include #include @@ -656,20 +657,6 @@ namespace boost template typename tools::promote_args::type zeta(T s); - template - T trunc(const T& v, const Policy& pol); - template - T trunc(const T& v); - template - int itrunc(const T& v, const Policy& pol); - template - int itrunc(const T& v); - template - long ltrunc(const T& v, const Policy& pol); - template - long ltrunc(const T& v); - - } // namespace math } // namespace boost @@ -677,13 +664,13 @@ namespace boost #define BOOST_MATH_DETAIL_LL_FUNC(Policy)\ \ template \ - inline T modf(const T& v, long long* ipart){ return boost::math::modf(v, ipart, Policy()); }\ + inline T modf(const T& v, long long* ipart){ using boost::math::modf; return modf(v, ipart, Policy()); }\ \ template \ - inline long long lltrunc(const T& v){ return boost::math::lltrunc(v, Policy()); }\ + inline long long lltrunc(const T& v){ using boost::math::lltrunc; return lltrunc(v, Policy()); }\ \ template \ - inline long long llround(const T& v){ return boost::math::llround(v, Policy()); }\ + inline long long llround(const T& v){ using boost::math::llround; return llround(v, Policy()); }\ #else #define BOOST_MATH_DETAIL_LL_FUNC(Policy) @@ -988,31 +975,31 @@ namespace boost inline typename boost::math::tools::promote_args::type zeta(T s){ return boost::math::zeta(s, Policy()); }\ \ template \ - inline T round(const T& v){ return boost::math::round(v, Policy()); }\ + inline T round(const T& v){ using boost::math::round; return round(v, Policy()); }\ \ template \ - inline int iround(const T& v){ return boost::math::iround(v, Policy()); }\ + inline int iround(const T& v){ using boost::math::iround; return iround(v, Policy()); }\ \ template \ - inline long lround(const T& v){ return boost::math::lround(v, Policy()); }\ + inline long lround(const T& v){ using boost::math::lround; return lround(v, Policy()); }\ \ template \ - inline T trunc(const T& v){ return boost::math::trunc(v, Policy()); }\ + inline T trunc(const T& v){ using boost::math::trunc; return trunc(v, Policy()); }\ \ template \ - inline int itrunc(const T& v){ return boost::math::itrunc(v, Policy()); }\ + inline int itrunc(const T& v){ using boost::math::itrunc; return itrunc(v, Policy()); }\ \ template \ - inline long ltrunc(const T& v){ return boost::math::ltrunc(v, Policy()); }\ + inline long ltrunc(const T& v){ using boost::math::ltrunc; return ltrunc(v, Policy()); }\ \ template \ - inline T modf(const T& v, T* ipart){ return boost::math::modf(v, ipart, Policy()); }\ + inline T modf(const T& v, T* ipart){ using boost::math::modf; return modf(v, ipart, Policy()); }\ \ template \ - inline T modf(const T& v, int* ipart){ return boost::math::modf(v, ipart, Policy()); }\ + inline T modf(const T& v, int* ipart){ using boost::math::modf; return modf(v, ipart, Policy()); }\ \ template \ - inline T modf(const T& v, long* ipart){ return boost::math::modf(v, ipart, Policy()); }\ + inline T modf(const T& v, long* ipart){ using boost::math::modf; return modf(v, ipart, Policy()); }\ \ template \ inline typename boost::math::tools::promote_args::type pow(T v){ return boost::math::pow(v, Policy()); }\ diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index e58b995dd..b44d8daad 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -21,6 +21,7 @@ #endif #include +#include #if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__hppa) # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS @@ -189,7 +190,14 @@ using std::ceil;\ using std::floor;\ using std::log10;\ - using std::sqrt; + using std::sqrt;\ + using boost::math::round;\ + using boost::math::iround;\ + using boost::math::lround;\ + using boost::math::trunc;\ + using boost::math::itrunc;\ + using boost::math::ltrunc;\ + using boost::math::modf; namespace boost{ namespace math{ diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 710f26697..48cba9afc 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -347,19 +347,25 @@ void instantiate(RealType) boost::math::expint(i, i, pol); boost::math::zeta(v1, pol); boost::math::zeta(i, pol); - boost::math::trunc(v1, pol); - boost::math::itrunc(v1, pol); - boost::math::ltrunc(v1, pol); - boost::math::round(v1, pol); - boost::math::iround(v1, pol); - boost::math::lround(v1, pol); - boost::math::modf(v1, &v1, pol); - boost::math::modf(v1, &i, pol); - boost::math::modf(v1, &l, pol); + // + // These next functions are intended to be found via ADL: + // + BOOST_MATH_STD_USING + trunc(v1, pol); + itrunc(v1, pol); + ltrunc(v1, pol); + round(v1, pol); + iround(v1, pol); + lround(v1, pol); + modf(v1, &v1, pol); + modf(v1, &i, pol); + modf(v1, &l, pol); #ifdef BOOST_HAS_LONG_LONG - boost::math::lltrunc(v1, pol); - boost::math::llround(v1, pol); - boost::math::modf(v1, &ll, pol); + using boost::math::lltrunc; + using boost::math::llround; + lltrunc(v1, pol); + llround(v1, pol); + modf(v1, &ll, pol); #endif boost::math::pow<2>(v1, pol); //