mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Renamed next_* functions to float_*.
[SVN r45216]
This commit is contained in:
@@ -685,17 +685,17 @@ namespace boost
|
||||
template <class T>
|
||||
T nextafter(const T&, const T&);
|
||||
template <class T, class Policy>
|
||||
T next_greater(const T&, const Policy&);
|
||||
T float_next(const T&, const Policy&);
|
||||
template <class T>
|
||||
T next_greater(const T&);
|
||||
T float_next(const T&);
|
||||
template <class T, class Policy>
|
||||
T next_less(const T&, const Policy&);
|
||||
T float_prior(const T&, const Policy&);
|
||||
template <class T>
|
||||
T next_less(const T&);
|
||||
T float_prior(const T&);
|
||||
template <class T, class Policy>
|
||||
T edit_distance(const T&, const T&, const Policy&);
|
||||
T float_distance(const T&, const T&, const Policy&);
|
||||
template <class T>
|
||||
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 <int N, class T>\
|
||||
inline typename boost::math::tools::promote_args<T>::type pow(T v){ return boost::math::pow<N>(v, Policy()); }\
|
||||
template <class T> T nextafter(const T& a, const T& b){ return boost::math::nextafter(a, b, Policy()); }\
|
||||
template <class T> T next_greater(const T& a){ return boost::math::next_greater(a, Policy()); }\
|
||||
template <class T> T next_less(const T& a){ return boost::math::next_less(a, Policy()); }\
|
||||
template <class T> T edit_distance(const T& a, const T& b){ return boost::math::edit_distance(a, b, Policy()); }\
|
||||
template <class T> T float_next(const T& a){ return boost::math::float_next(a, Policy()); }\
|
||||
template <class T> T float_prior(const T& a){ return boost::math::float_prior(a, Policy()); }\
|
||||
template <class T> T float_distance(const T& a, const T& b){ return boost::math::float_distance(a, b, Policy()); }\
|
||||
|
||||
|
||||
#endif // BOOST_MATH_SPECIAL_MATH_FWD_HPP
|
||||
|
||||
@@ -43,11 +43,11 @@ inline T get_smallest_value()
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
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<T>(
|
||||
@@ -70,9 +70,9 @@ T next_greater(const T& val, const Policy& pol)
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
template <class Policy>
|
||||
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<double>(
|
||||
@@ -87,17 +87,17 @@ inline double next_greater(const double& val, const Policy& pol)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
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 <class T, class Policy>
|
||||
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<T>(
|
||||
@@ -121,9 +121,9 @@ T next_less(const T& val, const Policy& pol)
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
template <class Policy>
|
||||
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<double>(
|
||||
@@ -138,15 +138,15 @@ inline double next_less(const double& val, const Policy& pol)
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
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 <class T, class Policy>
|
||||
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 <class T>
|
||||
@@ -156,13 +156,13 @@ inline T nextafter(const T& val, const T& direction)
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
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<T>(
|
||||
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<T>(), b, pol);
|
||||
return 1 + float_distance(boost::math::sign(b) * detail::get_smallest_value<T>(), b, pol);
|
||||
if(b == 0)
|
||||
return 1 + edit_distance(boost::math::sign(a) * detail::get_smallest_value<T>(), a, pol);
|
||||
return 1 + float_distance(boost::math::sign(a) * detail::get_smallest_value<T>(), a, pol);
|
||||
if(boost::math::sign(a) != boost::math::sign(b))
|
||||
return 2 + edit_distance(boost::math::sign(b) * detail::get_smallest_value<T>(), b, pol)
|
||||
+ edit_distance(boost::math::sign(a) * detail::get_smallest_value<T>(), a, pol);
|
||||
return 2 + float_distance(boost::math::sign(b) * detail::get_smallest_value<T>(), b, pol)
|
||||
+ float_distance(boost::math::sign(a) * detail::get_smallest_value<T>(), a, pol);
|
||||
|
||||
if((std::min)(fabs(a), fabs(b)) / (std::max)(fabs(a), fabs(b)) < 2 * tools::epsilon<T>())
|
||||
{
|
||||
bool biga = fabs(a) > fabs(b);
|
||||
T split = ldexp(biga ? b : a, tools::digits<T>() - 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 <class T>
|
||||
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
|
||||
|
||||
@@ -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 <class RealType>
|
||||
|
||||
@@ -21,22 +21,22 @@ void check()
|
||||
check_result<long double>(boost::math::nextafter<long double>(l, l));
|
||||
#endif
|
||||
|
||||
check_result<float>(boost::math::next_greater<float>(f));
|
||||
check_result<double>(boost::math::next_greater<double>(d));
|
||||
check_result<float>(boost::math::float_next<float>(f));
|
||||
check_result<double>(boost::math::float_next<double>(d));
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
check_result<long double>(boost::math::next_greater<long double>(l));
|
||||
check_result<long double>(boost::math::float_next<long double>(l));
|
||||
#endif
|
||||
|
||||
check_result<float>(boost::math::next_less<float>(f));
|
||||
check_result<double>(boost::math::next_less<double>(d));
|
||||
check_result<float>(boost::math::float_prior<float>(f));
|
||||
check_result<double>(boost::math::float_prior<double>(d));
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
check_result<long double>(boost::math::next_less<long double>(l));
|
||||
check_result<long double>(boost::math::float_prior<long double>(l));
|
||||
#endif
|
||||
|
||||
check_result<float>(boost::math::edit_distance<float>(f, f));
|
||||
check_result<double>(boost::math::edit_distance<double>(d, d));
|
||||
check_result<float>(boost::math::float_distance<float>(f, f));
|
||||
check_result<double>(boost::math::float_distance<double>(d, d));
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
check_result<long double>(boost::math::edit_distance<long double>(l, l));
|
||||
check_result<long double>(boost::math::float_distance<long double>(l, l));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -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 <class T>
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user