]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_minima.cpp
1 // Copyright John Maddock 2006.
2 // Copyright Paul A. Bristow 2007.
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/math/tools/minima.hpp>
11 #define BOOST_TEST_MAIN
12 #include <boost/test/unit_test.hpp>
13 #include <boost/test/tools/floating_point_comparison.hpp>
14 #include <boost/math/special_functions/gamma.hpp>
21 // minima is at (3,4):
22 T
operator()(const T
& v
)
30 void test_minima(T
, const char* /* name */)
32 std::pair
<T
, T
> m
= boost::math::tools::brent_find_minima(poly_test
<T
>(), T(-10), T(10), 50);
33 BOOST_CHECK_CLOSE(m
.first
, T(3), T(0.001));
34 BOOST_CHECK_CLOSE(m
.second
, T(4), T(0.001));
37 #if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
38 fp
= boost::math::lgamma
<T
>;
40 fp
= boost::math::lgamma
;
43 m
= boost::math::tools::brent_find_minima(fp
, T(0.5), T(10), 50);
44 BOOST_CHECK_CLOSE(m
.first
, T(1.461632), T(0.1));
45 #if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
46 fp
= boost::math::tgamma
<T
>;
48 fp
= boost::math::tgamma
;
50 m
= boost::math::tools::brent_find_minima(fp
, T(0.5), T(10), 50);
51 BOOST_CHECK_CLOSE(m
.first
, T(1.461632), T(0.1));
54 BOOST_AUTO_TEST_CASE( test_main
)
56 test_minima(0.1f
, "float");
57 test_minima(0.1, "double");
58 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
59 test_minima(0.1L, "long double");