// 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_2) struct one_over_one_plus_x_squared_test { template void operator()(const T&) const { constexpr int m = 4; constexpr float cx = 1.0; auto f = make_fvar(cx); //f = 1 / ((f *= f) += 1); f = ((f *= f) += 1).inverse(); BOOST_REQUIRE(f.derivative(0) == 0.5); BOOST_REQUIRE(f.derivative(1) == -0.5); BOOST_REQUIRE(f.derivative(2) == 0.5); BOOST_REQUIRE(f.derivative(3) == 0.0); BOOST_REQUIRE(f.derivative(4) == -3.0); } }; BOOST_AUTO_TEST_CASE(one_over_one_plus_x_squared) { boost::fusion::for_each(bin_float_types, one_over_one_plus_x_squared_test()); boost::fusion::for_each(multiprecision_float_types, one_over_one_plus_x_squared_test()); } struct exp_test_test { template void operator()(const T&) const { using std::exp; constexpr int m = 4; const T cx = 2.0; const auto x = make_fvar(cx); auto y = exp(x); for (int i=0 ; i<=m ; ++i) { //std::cout.precision(100); //std::cout << "y.derivative("<