]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_jacobi_theta.cpp
2 * Copyright Evan Miller, 2020
3 * Use, modification and distribution are subject to the
4 * Boost Software License, Version 1.0. (See accompanying file
5 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #include <pch_light.hpp>
9 #include <boost/math/concepts/real_concept.hpp>
10 #include "test_jacobi_theta.hpp"
12 // Test file for the Jacobi Theta functions, a.k.a the four horsemen of the
13 // Jacobi elliptic integrals. At the moment only Wolfrma Alpha spot checks are
14 // used. We should generate extra-precise numbers with NTL::RR or some such.
16 void expected_results()
19 // Define the max and mean errors expected for
20 // various compilers and platforms.
28 ".*Small Tau.*", // test data group
29 ".*", 1000, 200); // test function
36 ".*Wolfram Alpha.*", // test data group
37 ".*", 60, 15); // test function
39 // Catch all cases come last:
46 ".*", // test data group
47 ".*", 20, 5); // test function
49 // Finish off by printing out the compiler/stdlib/platform names,
50 // we do this to make it easier to mark up expected error rates.
52 std::cout
<< "Tests run with " << BOOST_COMPILER
<< ", "
53 << BOOST_STDLIB
<< ", " << BOOST_PLATFORM
<< std::endl
;
56 BOOST_AUTO_TEST_CASE( test_main
)
59 BOOST_MATH_CONTROL_FP
;
62 using namespace boost::math
;
64 BOOST_CHECK_THROW(jacobi_theta1(0.0, 0.0), std::domain_error
);
65 BOOST_CHECK_THROW(jacobi_theta1(0.0, 1.0), std::domain_error
);
67 BOOST_CHECK_THROW(jacobi_theta2(0.0, 0.0), std::domain_error
);
68 BOOST_CHECK_THROW(jacobi_theta2(0.0, 1.0), std::domain_error
);
70 BOOST_CHECK_THROW(jacobi_theta3(0.0, 0.0), std::domain_error
);
71 BOOST_CHECK_THROW(jacobi_theta3(0.0, 1.0), std::domain_error
);
73 BOOST_CHECK_THROW(jacobi_theta4(0.0, 0.0), std::domain_error
);
74 BOOST_CHECK_THROW(jacobi_theta4(0.0, 1.0), std::domain_error
);
76 BOOST_CHECK_THROW(jacobi_theta1tau(0.0, 0.0), std::domain_error
);
77 BOOST_CHECK_THROW(jacobi_theta1tau(0.0, -1.0), std::domain_error
);
79 BOOST_CHECK_THROW(jacobi_theta2tau(0.0, 0.0), std::domain_error
);
80 BOOST_CHECK_THROW(jacobi_theta2tau(0.0, -1.0), std::domain_error
);
82 BOOST_CHECK_THROW(jacobi_theta3tau(0.0, 0.0), std::domain_error
);
83 BOOST_CHECK_THROW(jacobi_theta3tau(0.0, -1.0), std::domain_error
);
85 BOOST_CHECK_THROW(jacobi_theta4tau(0.0, 0.0), std::domain_error
);
86 BOOST_CHECK_THROW(jacobi_theta4tau(0.0, -1.0), std::domain_error
);
88 double eps
= std::numeric_limits
<double>::epsilon();
89 for (double q
=0.0078125; q
<1.0; q
+= 0.0078125) { // = 1/128
90 for (double z
=-8.0; z
<=8.0; z
+= 0.125) {
91 test_periodicity(z
, q
, 100 * eps
);
92 test_argument_translation(z
, q
, 100 * eps
);
93 test_sums_of_squares(z
, q
, 100 * eps
);
94 // The addition formula is complicated, cut it some extra slack
95 test_addition_formulas(z
, constants::ln_two
<double>(), q
, sqrt(sqrt(eps
)));
96 test_duplication_formula(z
, q
, 100 * eps
);
97 test_transformations_of_nome(z
, q
, 100 * eps
);
98 test_watsons_identities(z
, 0.5, q
, 101 * eps
);
99 test_landen_transformations(z
, -log(q
)/constants::pi
<double>(), sqrt(eps
));
100 test_elliptic_functions(z
, q
, 5 * sqrt(eps
));
102 test_elliptic_integrals(q
, 10 * eps
);
105 test_special_values(eps
);
107 for (double s
=0.125; s
<3.0; s
+=0.125) {
108 test_mellin_transforms(2.0 + s
, eps
, 3 * eps
);
109 test_laplace_transforms(s
, eps
, 4 * eps
);
112 test_spots(0.0F
, "float");
113 test_spots(0.0, "double");
114 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
115 test_spots(0.0L, "long double");
116 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
117 test_spots(concepts::real_concept(0), "real_concept");
120 std::cout
<< "<note>The long double tests have been disabled on this platform "
121 "either because the long double overloads of the usual math functions are "
122 "not available at all, or because they are too inaccurate for these tests "
123 "to pass.</note>" << std::endl
;