mirror of
https://github.com/boostorg/math.git
synced 2026-01-29 07:42:11 +00:00
Merge accumulated Boost.Math fixes from Trunk: predominantly fixes for expression template and or arbitrary precision types. Plus refactored test code to make it usable with types other than float/double/long double.
[SVN r76269]
This commit is contained in:
@@ -77,6 +77,15 @@ bool check_complex(const std::complex<T>& a, const std::complex<T>& b, int max_e
|
||||
}
|
||||
}
|
||||
|
||||
if((boost::math::isnan)(a.real()))
|
||||
{
|
||||
BOOST_ERROR("Found non-finite value for real part: " << a);
|
||||
}
|
||||
if((boost::math::isnan)(a.imag()))
|
||||
{
|
||||
BOOST_ERROR("Found non-finite value for inaginary part: " << a);
|
||||
}
|
||||
|
||||
T rel = boost::math::fabs((b-a)/b) / eps;
|
||||
if( rel > max_error)
|
||||
{
|
||||
@@ -276,7 +285,7 @@ void check_spots(const T&)
|
||||
// but an attempt to access it will terminate the program!!!!
|
||||
if(std::numeric_limits<T>::has_quiet_NaN)
|
||||
nan = std::numeric_limits<T>::quiet_NaN();
|
||||
if(boost::math::detail::test_is_nan(nan))
|
||||
if((boost::math::isnan)(nan))
|
||||
test_nan = true;
|
||||
#endif
|
||||
#if defined(__DECCXX) && !defined(_IEEE_FP)
|
||||
@@ -303,11 +312,11 @@ void check_spots(const T&)
|
||||
{
|
||||
result = boost::math::acos(ct(zero,nan));
|
||||
BOOST_CHECK_CLOSE(result.real(), half_pi, eps*200);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(mzero,nan));
|
||||
BOOST_CHECK_CLOSE(result.real(), half_pi, eps*200);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
if(test_infinity)
|
||||
{
|
||||
@@ -323,8 +332,8 @@ void check_spots(const T&)
|
||||
if(test_nan)
|
||||
{
|
||||
result = boost::math::acos(ct(one, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
if(test_infinity)
|
||||
{
|
||||
@@ -363,41 +372,70 @@ void check_spots(const T&)
|
||||
if(test_nan)
|
||||
{
|
||||
result = boost::math::acos(ct(infinity, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(std::fabs(result.imag()) == infinity);
|
||||
|
||||
result = boost::math::acos(ct(-infinity, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(std::fabs(result.imag()) == infinity);
|
||||
|
||||
result = boost::math::acos(ct(nan, zero));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(nan, -zero));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(nan, one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(nan, -one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(nan, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acos(ct(nan, infinity));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(result.imag() == -infinity);
|
||||
|
||||
result = boost::math::acos(ct(nan, -infinity));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(result.imag() == infinity);
|
||||
}
|
||||
if(boost::math::signbit(mzero))
|
||||
{
|
||||
result = boost::math::acos(ct(-1.25f, zero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() < 0);
|
||||
result = boost::math::asin(ct(-1.75f, mzero));
|
||||
BOOST_CHECK(result.real() < 0);
|
||||
BOOST_CHECK(result.imag() < 0);
|
||||
result = boost::math::atan(ct(mzero, -1.75f));
|
||||
BOOST_CHECK(result.real() < 0);
|
||||
BOOST_CHECK(result.imag() < 0);
|
||||
|
||||
result = boost::math::acos(ct(zero, zero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
BOOST_CHECK((boost::math::signbit)(result.imag()));
|
||||
result = boost::math::acos(ct(zero, mzero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
BOOST_CHECK(0 == (boost::math::signbit)(result.imag()));
|
||||
result = boost::math::acos(ct(mzero, zero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
BOOST_CHECK((boost::math::signbit)(result.imag()));
|
||||
result = boost::math::acos(ct(mzero, mzero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
BOOST_CHECK(0 == (boost::math::signbit)(result.imag()));
|
||||
}
|
||||
|
||||
//
|
||||
// C99 spot tests for acosh:
|
||||
@@ -408,7 +446,7 @@ void check_spots(const T&)
|
||||
|
||||
result = boost::math::acosh(ct(zero, mzero));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
BOOST_CHECK_CLOSE(result.imag(), half_pi, eps*200);
|
||||
BOOST_CHECK_CLOSE(result.imag(), -half_pi, eps*200);
|
||||
|
||||
result = boost::math::acosh(ct(mzero, zero));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
@@ -416,7 +454,7 @@ void check_spots(const T&)
|
||||
|
||||
result = boost::math::acosh(ct(mzero, mzero));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
BOOST_CHECK_CLOSE(result.imag(), half_pi, eps*200);
|
||||
BOOST_CHECK_CLOSE(result.imag(), -half_pi, eps*200);
|
||||
|
||||
if(test_infinity)
|
||||
{
|
||||
@@ -432,8 +470,8 @@ void check_spots(const T&)
|
||||
if(test_nan)
|
||||
{
|
||||
result = boost::math::acosh(ct(one, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
if(test_infinity)
|
||||
{
|
||||
@@ -474,31 +512,37 @@ void check_spots(const T&)
|
||||
{
|
||||
result = boost::math::acosh(ct(infinity, nan));
|
||||
BOOST_CHECK(result.real() == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(-infinity, nan));
|
||||
BOOST_CHECK(result.real() == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(nan, one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(nan, infinity));
|
||||
BOOST_CHECK(result.real() == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(nan, -one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(nan, -infinity));
|
||||
BOOST_CHECK(result.real() == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::acosh(ct(nan, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
if(boost::math::signbit(mzero))
|
||||
{
|
||||
result = boost::math::acosh(ct(-2.5f, zero));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() > 0);
|
||||
}
|
||||
//
|
||||
// C99 spot checks for asinh:
|
||||
@@ -541,16 +585,16 @@ void check_spots(const T&)
|
||||
if(test_nan)
|
||||
{
|
||||
result = boost::math::asinh(ct(one, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(-one, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(zero, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
|
||||
if(test_infinity)
|
||||
@@ -592,39 +636,45 @@ void check_spots(const T&)
|
||||
{
|
||||
result = boost::math::asinh(ct(infinity, nan));
|
||||
BOOST_CHECK(result.real() == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(-infinity, nan));
|
||||
BOOST_CHECK(result.real() == -infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(nan, zero));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
|
||||
result = boost::math::asinh(ct(nan, mzero));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK(result.imag() == 0);
|
||||
|
||||
result = boost::math::asinh(ct(nan, one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(nan, -one));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(nan, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(nan, infinity));
|
||||
BOOST_CHECK(std::fabs(result.real()) == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::asinh(ct(nan, -infinity));
|
||||
BOOST_CHECK(std::fabs(result.real()) == infinity);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
if(boost::math::signbit(mzero))
|
||||
{
|
||||
result = boost::math::asinh(ct(zero, 1.5f));
|
||||
BOOST_CHECK(result.real() > 0);
|
||||
BOOST_CHECK(result.imag() > 0);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -650,11 +700,11 @@ void check_spots(const T&)
|
||||
{
|
||||
result = boost::math::atanh(ct(zero, nan));
|
||||
BOOST_CHECK(result.real() == zero);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(-zero, nan));
|
||||
BOOST_CHECK(result.real() == zero);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
|
||||
if(test_infinity)
|
||||
@@ -694,12 +744,12 @@ void check_spots(const T&)
|
||||
if(test_nan)
|
||||
{
|
||||
result = boost::math::atanh(ct(pi, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(-pi, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
}
|
||||
|
||||
if(test_infinity)
|
||||
@@ -741,19 +791,19 @@ void check_spots(const T&)
|
||||
{
|
||||
result = boost::math::atanh(ct(infinity, nan));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(-infinity, nan));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(nan, pi));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(nan, -pi));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
result = boost::math::atanh(ct(nan, infinity));
|
||||
BOOST_CHECK(result.real() == 0);
|
||||
@@ -764,10 +814,16 @@ void check_spots(const T&)
|
||||
BOOST_CHECK_CLOSE(result.imag(), -half_pi, eps*200);
|
||||
|
||||
result = boost::math::atanh(ct(nan, nan));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.real()));
|
||||
BOOST_CHECK(boost::math::detail::test_is_nan(result.imag()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.real()));
|
||||
BOOST_CHECK((boost::math::isnan)(result.imag()));
|
||||
|
||||
}
|
||||
if(boost::math::signbit(mzero))
|
||||
{
|
||||
result = boost::math::atanh(ct(-2.0f, mzero));
|
||||
BOOST_CHECK(result.real() < 0);
|
||||
BOOST_CHECK(result.imag() < 0);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user