]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/math/test/test_jacobi_zeta.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / math / test / test_jacobi_zeta.hpp
CommitLineData
7c673cae
FG
1// Copyright John Maddock 2015.
2// Use, modification and distribution are subject to the
3// Boost Software License, Version 1.0. (See accompanying file
4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifdef _MSC_VER
7# pragma warning(disable : 4756) // overflow in constant arithmetic
8// Constants are too big for float case, but this doesn't matter for test.
9#endif
10
11#include <boost/math/concepts/real_concept.hpp>
12#define BOOST_TEST_MAIN
13#include <boost/test/unit_test.hpp>
92f5a8d4 14#include <boost/test/tools/floating_point_comparison.hpp>
7c673cae
FG
15#include <boost/math/special_functions/math_fwd.hpp>
16#include <boost/math/constants/constants.hpp>
17//#include <boost/math/special_functions/next.hpp>
18#include <boost/array.hpp>
19#include "functor.hpp"
20
21#include "handle_test_result.hpp"
22#include "table_type.hpp"
23
24#ifndef SC_
25#define SC_(x) static_cast<typename table_type<T>::type>(BOOST_JOIN(x, L))
26#endif
27
28template <class Real, typename T>
29void do_test_jacobi_zeta(const T& data, const char* type_name, const char* test)
30{
31#if !(defined(ERROR_REPORTING_MODE) && !defined(JACOBI_ZETA_FUNCTION_TO_TEST))
32 typedef Real value_type;
33
34 std::cout << "Testing: " << test << std::endl;
35
36#ifdef JACOBI_ZETA_FUNCTION_TO_TEST
37 value_type(*fp2)(value_type, value_type) = JACOBI_ZETA_FUNCTION_TO_TEST;
38#elif defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS)
39 value_type (*fp2)(value_type, value_type) = boost::math::ellint_d<value_type, value_type>;
40#else
41 value_type(*fp2)(value_type, value_type) = boost::math::jacobi_zeta;
42#endif
43 boost::math::tools::test_result<value_type> result;
44
45 result = boost::math::tools::test_hetero<Real>(
46 data,
47 bind_func<Real>(fp2, 1, 0),
48 extract_result<Real>(2));
49 handle_test_result(result, data[result.worst()], result.worst(),
50 type_name, "jacobi_zeta", test);
51
52 std::cout << std::endl;
53#endif
54}
55
56template <typename T>
57void test_spots(T, const char* type_name)
58{
59 BOOST_MATH_STD_USING
60 // Function values calculated on http://functions.wolfram.com/
61 // Note that Mathematica's EllipticE accepts k^2 as the second parameter.
1e59de90 62 static const std::array<std::array<T, 3>, 18> data1 = {{
7c673cae
FG
63 { { SC_(0.5), SC_(0.5), SC_(0.055317014255129651475392155709691519) } },
64 { { SC_(-0.5), SC_(0.5), SC_(-0.055317014255129651475392155709691519) } },
65 { { SC_(0), SC_(0.5), SC_(0) } },
66 { { SC_(1), T(0.5), SC_(0.061847782565098669252626761181452815) } },
67// { { boost::math::float_prior(boost::math::constants::half_pi<T>()), T(0.5), SC_(0) } },
68 { { SC_(1), T(0), SC_(0) } },
69 { { SC_(1), T(1), SC_(0.84147098480789650665250232163029900) } },
70 { { SC_(2), T(0.5), SC_(-0.051942537457672732722176231281435254) } },
71 { { SC_(5), T(0.5), SC_(-0.037609329968145259476447488930872898) } },
72 { { SC_(0.5), SC_(1), SC_(0.479425538604203000273287935215571388081803367940600675188616) } },
73 { { boost::math::constants::half_pi<T>() - static_cast<T>(1) / 1024, SC_(1), SC_(0.999999523162879692486369202949889069215510235208243466564977) } },
74 { { boost::math::constants::half_pi<T>() + static_cast<T>(1) / 1024, SC_(1), SC_(-0.999999523162879692486369202949889069215510235208243466564977) } },
75 { { SC_(2), SC_(1), SC_(-0.90929742682568169539601986591174484270225497144789026837897) } },
76 { { SC_(3), SC_(1), SC_(-0.14112000805986722210074480280811027984693326425226558415188) } },
77 { { SC_(4), SC_(1), SC_(0.756802495307928251372639094511829094135912887336472571485416) } },
78 { { SC_(-0.5), SC_(1), SC_(-0.479425538604203000273287935215571388081803367940600675188616) } },
79 { { SC_(-2), SC_(1), SC_(0.90929742682568169539601986591174484270225497144789026837897) } },
80 { { SC_(-3), SC_(1), SC_(0.14112000805986722210074480280811027984693326425226558415188) } },
81 { { SC_(-4), SC_(1), SC_(-0.756802495307928251372639094511829094135912887336472571485416) } },
82 }};
83
84 do_test_jacobi_zeta<T>(data1, type_name, "Elliptic Integral Jacobi Zeta: Mathworld Data");
85
86#include "jacobi_zeta_data.ipp"
87
88 do_test_jacobi_zeta<T>(jacobi_zeta_data, type_name, "Elliptic Integral Jacobi Zeta: Random Data");
89
90#include "jacobi_zeta_big_phi.ipp"
91
92 do_test_jacobi_zeta<T>(jacobi_zeta_big_phi, type_name, "Elliptic Integral Jacobi Zeta: Large Phi Values");
93}
94