diff --git a/include/boost/math/special_functions/math_fwd.hpp b/include/boost/math/special_functions/math_fwd.hpp index 4a69ad3f2..c833219f5 100644 --- a/include/boost/math/special_functions/math_fwd.hpp +++ b/include/boost/math/special_functions/math_fwd.hpp @@ -685,17 +685,17 @@ namespace boost template T nextafter(const T&, const T&); template - T next_greater(const T&, const Policy&); + T float_next(const T&, const Policy&); template - T next_greater(const T&); + T float_next(const T&); template - T next_less(const T&, const Policy&); + T float_prior(const T&, const Policy&); template - T next_less(const T&); + T float_prior(const T&); template - T edit_distance(const T&, const T&, const Policy&); + T float_distance(const T&, const T&, const Policy&); template - T edit_distance(const T&, const T&); + T float_distance(const T&, const T&); } // namespace math } // namespace boost @@ -1044,9 +1044,9 @@ namespace boost template \ inline typename boost::math::tools::promote_args::type pow(T v){ return boost::math::pow(v, Policy()); }\ template T nextafter(const T& a, const T& b){ return boost::math::nextafter(a, b, Policy()); }\ - template T next_greater(const T& a){ return boost::math::next_greater(a, Policy()); }\ - template T next_less(const T& a){ return boost::math::next_less(a, Policy()); }\ - template T edit_distance(const T& a, const T& b){ return boost::math::edit_distance(a, b, Policy()); }\ + template T float_next(const T& a){ return boost::math::float_next(a, Policy()); }\ + template T float_prior(const T& a){ return boost::math::float_prior(a, Policy()); }\ + template T float_distance(const T& a, const T& b){ return boost::math::float_distance(a, b, Policy()); }\ #endif // BOOST_MATH_SPECIAL_MATH_FWD_HPP diff --git a/include/boost/math/special_functions/next.hpp b/include/boost/math/special_functions/next.hpp index 87b4aac3c..86e3ea97e 100644 --- a/include/boost/math/special_functions/next.hpp +++ b/include/boost/math/special_functions/next.hpp @@ -43,11 +43,11 @@ inline T get_smallest_value() } template -T next_greater(const T& val, const Policy& pol) +T float_next(const T& val, const Policy& pol) { BOOST_MATH_STD_USING int expon; - static const char* function = "next_greater<%1%>(%1%)"; + static const char* function = "float_next<%1%>(%1%)"; if(!(boost::math::isfinite)(val)) return policies::raise_domain_error( @@ -70,9 +70,9 @@ T next_greater(const T& val, const Policy& pol) #ifdef BOOST_MSVC template -inline double next_greater(const double& val, const Policy& pol) +inline double float_next(const double& val, const Policy& pol) { - static const char* function = "next_greater<%1%>(%1%)"; + static const char* function = "float_next<%1%>(%1%)"; if(!(boost::math::isfinite)(val)) return policies::raise_domain_error( @@ -87,17 +87,17 @@ inline double next_greater(const double& val, const Policy& pol) #endif template -inline T next_greater(const T& val) +inline T float_next(const T& val) { - return next_greater(val, policies::policy<>()); + return float_next(val, policies::policy<>()); } template -T next_less(const T& val, const Policy& pol) +T float_prior(const T& val, const Policy& pol) { BOOST_MATH_STD_USING int expon; - static const char* function = "next_less<%1%>(%1%)"; + static const char* function = "float_prior<%1%>(%1%)"; if(!(boost::math::isfinite)(val)) return policies::raise_domain_error( @@ -121,9 +121,9 @@ T next_less(const T& val, const Policy& pol) #ifdef BOOST_MSVC template -inline double next_less(const double& val, const Policy& pol) +inline double float_prior(const double& val, const Policy& pol) { - static const char* function = "next_less<%1%>(%1%)"; + static const char* function = "float_prior<%1%>(%1%)"; if(!(boost::math::isfinite)(val)) return policies::raise_domain_error( @@ -138,15 +138,15 @@ inline double next_less(const double& val, const Policy& pol) #endif template -inline T next_less(const T& val) +inline T float_prior(const T& val) { - return next_less(val, policies::policy<>()); + return float_prior(val, policies::policy<>()); } template inline T nextafter(const T& val, const T& direction, const Policy& pol) { - return val < direction ? boost::math::next_greater(val, pol) : val == direction ? val : boost::math::next_less(val, pol); + return val < direction ? boost::math::float_next(val, pol) : val == direction ? val : boost::math::float_prior(val, pol); } template @@ -156,13 +156,13 @@ inline T nextafter(const T& val, const T& direction) } template -T edit_distance(const T& a, const T& b, const Policy& pol) +T float_distance(const T& a, const T& b, const Policy& pol) { BOOST_MATH_STD_USING // // Error handling: // - static const char* function = "edit_distance<%1%>(%1%, %1%)"; + static const char* function = "float_distance<%1%>(%1%, %1%)"; if(!(boost::math::isfinite)(a)) return policies::raise_domain_error( function, @@ -177,18 +177,18 @@ T edit_distance(const T& a, const T& b, const Policy& pol) if(a == b) return 0; if(a == 0) - return 1 + edit_distance(boost::math::sign(b) * detail::get_smallest_value(), b, pol); + return 1 + float_distance(boost::math::sign(b) * detail::get_smallest_value(), b, pol); if(b == 0) - return 1 + edit_distance(boost::math::sign(a) * detail::get_smallest_value(), a, pol); + return 1 + float_distance(boost::math::sign(a) * detail::get_smallest_value(), a, pol); if(boost::math::sign(a) != boost::math::sign(b)) - return 2 + edit_distance(boost::math::sign(b) * detail::get_smallest_value(), b, pol) - + edit_distance(boost::math::sign(a) * detail::get_smallest_value(), a, pol); + return 2 + float_distance(boost::math::sign(b) * detail::get_smallest_value(), b, pol) + + float_distance(boost::math::sign(a) * detail::get_smallest_value(), a, pol); if((std::min)(fabs(a), fabs(b)) / (std::max)(fabs(a), fabs(b)) < 2 * tools::epsilon()) { bool biga = fabs(a) > fabs(b); T split = ldexp(biga ? b : a, tools::digits() - 2); - return edit_distance(a, split, pol) + edit_distance(split, b, pol); + return float_distance(a, split, pol) + float_distance(split, b, pol); } BOOST_MATH_STD_USING @@ -229,9 +229,9 @@ T edit_distance(const T& a, const T& b, const Policy& pol) } template -T edit_distance(const T& a, const T& b) +T float_distance(const T& a, const T& b) { - return boost::math::edit_distance(a, b, policies::policy<>()); + return boost::math::float_distance(a, b, policies::policy<>()); } }} // namespaces diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index f676d3e5a..b753941e1 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -247,9 +247,9 @@ void instantiate(RealType) #endif boost::math::pow<2>(v1); boost::math::nextafter(v1, v1); - boost::math::next_greater(v1); - boost::math::next_less(v1); - boost::math::edit_distance(v1, v1); + boost::math::float_next(v1); + boost::math::float_prior(v1); + boost::math::float_distance(v1, v1); // // All over again, with a policy this time: // @@ -373,9 +373,9 @@ void instantiate(RealType) #endif boost::math::pow<2>(v1, pol); boost::math::nextafter(v1, v1, pol); - boost::math::next_greater(v1, pol); - boost::math::next_less(v1, pol); - boost::math::edit_distance(v1, v1, pol); + boost::math::float_next(v1, pol); + boost::math::float_prior(v1, pol); + boost::math::float_distance(v1, v1, pol); // // All over again with the versions in test:: // @@ -492,9 +492,9 @@ void instantiate(RealType) #endif test::pow<2>(v1); test::nextafter(v1, v1); - test::next_greater(v1); - test::next_less(v1); - test::edit_distance(v1, v1); + test::float_next(v1); + test::float_prior(v1); + test::float_distance(v1, v1); } template diff --git a/test/compile_test/sf_next_incl_test.cpp b/test/compile_test/sf_next_incl_test.cpp index feac333ee..d491b1720 100644 --- a/test/compile_test/sf_next_incl_test.cpp +++ b/test/compile_test/sf_next_incl_test.cpp @@ -21,22 +21,22 @@ void check() check_result(boost::math::nextafter(l, l)); #endif - check_result(boost::math::next_greater(f)); - check_result(boost::math::next_greater(d)); + check_result(boost::math::float_next(f)); + check_result(boost::math::float_next(d)); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS - check_result(boost::math::next_greater(l)); + check_result(boost::math::float_next(l)); #endif - check_result(boost::math::next_less(f)); - check_result(boost::math::next_less(d)); + check_result(boost::math::float_prior(f)); + check_result(boost::math::float_prior(d)); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS - check_result(boost::math::next_less(l)); + check_result(boost::math::float_prior(l)); #endif - check_result(boost::math::edit_distance(f, f)); - check_result(boost::math::edit_distance(d, d)); + check_result(boost::math::float_distance(f, f)); + check_result(boost::math::float_distance(d, d)); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS - check_result(boost::math::edit_distance(l, l)); + check_result(boost::math::float_distance(l, l)); #endif } diff --git a/test/test_next.cpp b/test/test_next.cpp index 131b38f71..909a60601 100644 --- a/test/test_next.cpp +++ b/test/test_next.cpp @@ -17,20 +17,20 @@ void test_value(const T& val, const char* name) std::cout << "Testing type " << name << " with initial value " << val << std::endl; - BOOST_CHECK_EQUAL(edit_distance(next_greater(val), val), 1); - BOOST_CHECK(next_greater(val) > val); - BOOST_CHECK_EQUAL(edit_distance(next_less(val), val), 1); - BOOST_CHECK(next_less(val) < val); - BOOST_CHECK_EQUAL(edit_distance(nextafter(val, upper), val), 1); + BOOST_CHECK_EQUAL(float_distance(float_next(val), val), 1); + BOOST_CHECK(float_next(val) > val); + BOOST_CHECK_EQUAL(float_distance(float_prior(val), val), 1); + BOOST_CHECK(float_prior(val) < val); + BOOST_CHECK_EQUAL(float_distance(nextafter(val, upper), val), 1); BOOST_CHECK(nextafter(val, upper) > val); - BOOST_CHECK_EQUAL(edit_distance(nextafter(val, lower), val), 1); + BOOST_CHECK_EQUAL(float_distance(nextafter(val, lower), val), 1); BOOST_CHECK(nextafter(val, lower) < val); - BOOST_CHECK_EQUAL(edit_distance(next_greater(next_greater(val)), val), 2); - BOOST_CHECK_EQUAL(edit_distance(next_less(next_less(val)), val), 2); - BOOST_CHECK_EQUAL(edit_distance(next_less(next_greater(val)), val), 0); - BOOST_CHECK_EQUAL(edit_distance(next_greater(next_less(val)), val), 0); - BOOST_CHECK_EQUAL(next_less(next_greater(val)), val); - BOOST_CHECK_EQUAL(next_greater(next_less(val)), val); + BOOST_CHECK_EQUAL(float_distance(float_next(float_next(val)), val), 2); + BOOST_CHECK_EQUAL(float_distance(float_prior(float_prior(val)), val), 2); + BOOST_CHECK_EQUAL(float_distance(float_prior(float_next(val)), val), 0); + BOOST_CHECK_EQUAL(float_distance(float_next(float_prior(val)), val), 0); + BOOST_CHECK_EQUAL(float_prior(float_next(val)), val); + BOOST_CHECK_EQUAL(float_next(float_prior(val)), val); } template @@ -82,17 +82,17 @@ void test_values(const T& val, const char* name) T v2 = val; for(unsigned j = 0; j < primes[i]; ++j) { - v1 = boost::math::next_greater(v1); - v2 = boost::math::next_less(v2); + v1 = boost::math::float_next(v1); + v2 = boost::math::float_prior(v2); } - BOOST_CHECK_EQUAL(boost::math::edit_distance(v1, val), primes[i]); - BOOST_CHECK_EQUAL(boost::math::edit_distance(v2, val), primes[i]); + BOOST_CHECK_EQUAL(boost::math::float_distance(v1, val), primes[i]); + BOOST_CHECK_EQUAL(boost::math::float_distance(v2, val), primes[i]); } } int test_main(int, char* []) { - std::cout << boost::math::edit_distance(1.0, 0.0) << std::endl; + std::cout << boost::math::float_distance(1.0, 0.0) << std::endl; test_values(1.0f, "float"); test_values(1.0, "double"); test_values(1.0L, "long double");