2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Revert test_autodiff_4 - these two tests break test_autodiff_3. Attempt to fix asinh() test that fails on gcc-mingw for unknown reason.

This commit is contained in:
Matt Pulver
2019-02-23 11:56:16 -05:00
parent fd1262bdcf
commit b7ea8cef5c
4 changed files with 67 additions and 55 deletions

View File

@@ -1241,6 +1241,7 @@ test-suite misc :
[ run test_autodiff_1.cpp ../../test/build//boost_unit_test_framework : : : <toolset>msvc:<cxxflags>/bigobj [ requires cxx11_inline_namespaces ] ]
[ run test_autodiff_2.cpp ../../test/build//boost_unit_test_framework : : : <toolset>msvc:<cxxflags>/bigobj [ requires cxx11_inline_namespaces ] ]
[ run test_autodiff_3.cpp ../../test/build//boost_unit_test_framework : : : <toolset>msvc:<cxxflags>/bigobj [ requires cxx11_inline_namespaces ] ]
[ run test_autodiff_4.cpp ../../test/build//boost_unit_test_framework : : : <toolset>msvc:<cxxflags>/bigobj [ requires cxx11_inline_namespaces ] ]
;
build-project ../example ;

View File

@@ -444,7 +444,8 @@ struct asinh_test_test
const T cx = 1;
auto x = make_fvar<T,m>(cx);
auto y = asinh(x);
BOOST_REQUIRE(y.derivative(0) == asinh(cx));
//BOOST_REQUIRE(y.derivative(0) == asinh(cx)); // Fails for gcc-mingw - similar to acosh()?
BOOST_REQUIRE(y.derivative(0) == asinh(static_cast<T>(x)));
BOOST_REQUIRE_CLOSE(y.derivative(1), 1/boost::math::constants::root_two<T>(), eps);
BOOST_REQUIRE_CLOSE(y.derivative(2), -1/(2*boost::math::constants::root_two<T>()), eps);
BOOST_REQUIRE_CLOSE(y.derivative(3), 1/(4*boost::math::constants::root_two<T>()), eps);

View File

@@ -251,58 +251,4 @@ BOOST_AUTO_TEST_CASE(iround_and_itrunc)
boost::fusion::for_each(multiprecision_float_types, iround_and_itrunc_test());
}
struct lround_llround_truncl_test
{
template<typename T>
void operator()(const T&) const
{
using std::lround;
using std::llround;
//using std::truncl; // truncl not supported by boost::multiprecision types.
constexpr int m = 3;
const T cx = 3.25;
auto x = make_fvar<T,m>(cx);
long yl = lround(x);
BOOST_REQUIRE(yl == lround(cx));
long long yll = llround(x);
BOOST_REQUIRE(yll == llround(cx));
//long double yld = truncl(x);
//BOOST_REQUIRE(yld == truncl(cx));
}
};
BOOST_AUTO_TEST_CASE(lround_llround_truncl)
{
boost::fusion::for_each(bin_float_types, lround_llround_truncl_test());
boost::fusion::for_each(multiprecision_float_types, lround_llround_truncl_test());
}
struct multiprecision_test
{
template<typename T>
void operator()(const T&) const
{
const T eps = 4000*std::numeric_limits<T>::epsilon(); // percent
constexpr int Nw=3;
constexpr int Nx=2;
constexpr int Ny=4;
constexpr int Nz=3;
const auto w = make_fvar<T,Nw>(11);
const auto x = make_fvar<T,0,Nx>(12);
const auto y = make_fvar<T,0,0,Ny>(13);
const auto z = make_fvar<T,0,0,0,Nz>(14);
const auto v = mixed_partials_f(w,x,y,z); // auto = autodiff_fvar<T,Nw,Nx,Ny,Nz>
// Calculated from Mathematica symbolic differentiation.
const T answer = boost::lexical_cast<T>("1976.3196007477977177798818752904187209081211892187"
"5499076582535951111845769110560421820940516423255314");
BOOST_REQUIRE_CLOSE(v.derivative(Nw,Nx,Ny,Nz), answer, eps); // Doesn't work for cpp_dec_float
}
};
BOOST_AUTO_TEST_CASE(multiprecision)
{
//multiprecision_test()(boost::multiprecision::cpp_bin_float_50());
boost::fusion::for_each(bin_float_types, multiprecision_test());
}
BOOST_AUTO_TEST_SUITE_END()

64
test/test_autodiff_4.cpp Normal file
View File

@@ -0,0 +1,64 @@
// Copyright Matthew Pulver 2018 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
#include "test_autodiff.hpp"
BOOST_AUTO_TEST_SUITE(test_autodiff_4)
struct lround_llround_truncl_test
{
template<typename T>
void operator()(const T&) const
{
using std::lround;
using std::llround;
//using std::truncl; // truncl not supported by boost::multiprecision types.
constexpr int m = 3;
const T cx = 3.25;
auto x = make_fvar<T,m>(cx);
long yl = lround(x);
BOOST_REQUIRE(yl == lround(cx));
long long yll = llround(x);
BOOST_REQUIRE(yll == llround(cx));
//long double yld = truncl(x);
//BOOST_REQUIRE(yld == truncl(cx));
}
};
BOOST_AUTO_TEST_CASE(lround_llround_truncl)
{
boost::fusion::for_each(bin_float_types, lround_llround_truncl_test());
boost::fusion::for_each(multiprecision_float_types, lround_llround_truncl_test());
}
struct multiprecision_test
{
template<typename T>
void operator()(const T&) const
{
const T eps = 4000*std::numeric_limits<T>::epsilon(); // percent
constexpr int Nw=3;
constexpr int Nx=2;
constexpr int Ny=4;
constexpr int Nz=3;
const auto w = make_fvar<T,Nw>(11);
const auto x = make_fvar<T,0,Nx>(12);
const auto y = make_fvar<T,0,0,Ny>(13);
const auto z = make_fvar<T,0,0,0,Nz>(14);
const auto v = mixed_partials_f(w,x,y,z); // auto = autodiff_fvar<T,Nw,Nx,Ny,Nz>
// Calculated from Mathematica symbolic differentiation.
const T answer = boost::lexical_cast<T>("1976.3196007477977177798818752904187209081211892187"
"5499076582535951111845769110560421820940516423255314");
BOOST_REQUIRE_CLOSE(v.derivative(Nw,Nx,Ny,Nz), answer, eps); // Doesn't work for cpp_dec_float
}
};
BOOST_AUTO_TEST_CASE(multiprecision)
{
//multiprecision_test()(boost::multiprecision::cpp_bin_float_50());
boost::fusion::for_each(bin_float_types, multiprecision_test());
}
BOOST_AUTO_TEST_SUITE_END()