mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Add testing to quadrature
This commit is contained in:
@@ -29,6 +29,10 @@
|
||||
#include <boost/multiprecision/complex128.hpp>
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdfloat>)
|
||||
# include <stdfloat>
|
||||
#endif
|
||||
|
||||
using std::exp;
|
||||
using std::cos;
|
||||
using std::tan;
|
||||
@@ -586,17 +590,35 @@ BOOST_AUTO_TEST_CASE(exp_sinh_quadrature_test)
|
||||
*/
|
||||
|
||||
#ifdef TEST1
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_left_limit_infinite<std::float32_t>();
|
||||
test_right_limit_infinite<std::float32_t>();
|
||||
test_nr_examples<std::float32_t>();
|
||||
test_crc<std::float32_t>();
|
||||
#else
|
||||
test_left_limit_infinite<float>();
|
||||
test_right_limit_infinite<float>();
|
||||
test_nr_examples<float>();
|
||||
test_crc<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifdef TEST2
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_left_limit_infinite<std::float64_t>();
|
||||
test_right_limit_infinite<std::float64_t>();
|
||||
test_nr_examples<std::float64_t>();
|
||||
test_crc<std::float64_t>();
|
||||
#else
|
||||
test_left_limit_infinite<double>();
|
||||
test_right_limit_infinite<double>();
|
||||
test_nr_examples<double>();
|
||||
test_crc<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
#ifdef TEST3
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#pragma warning(disable:4127) // Conditional expression is constant
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdfloat>)
|
||||
# include <stdfloat>
|
||||
#endif
|
||||
|
||||
using std::expm1;
|
||||
using std::atan;
|
||||
using std::tan;
|
||||
@@ -456,6 +460,16 @@ BOOST_AUTO_TEST_CASE(gauss_quadrature_test)
|
||||
{
|
||||
#ifdef TEST1
|
||||
std::cout << "Testing 15 point approximation:\n";
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_linear<std::float64_t, 15>();
|
||||
test_quadratic<std::float64_t, 15>();
|
||||
test_ca<std::float64_t, 15>();
|
||||
test_three_quadrature_schemes_examples<std::float64_t, 15>();
|
||||
test_integration_over_real_line<std::float64_t, 15>();
|
||||
test_right_limit_infinite<std::float64_t, 15>();
|
||||
test_left_limit_infinite<std::float64_t, 15>();
|
||||
#else
|
||||
test_linear<double, 15>();
|
||||
test_quadratic<double, 15>();
|
||||
test_ca<double, 15>();
|
||||
@@ -463,9 +477,20 @@ BOOST_AUTO_TEST_CASE(gauss_quadrature_test)
|
||||
test_integration_over_real_line<double, 15>();
|
||||
test_right_limit_infinite<double, 15>();
|
||||
test_left_limit_infinite<double, 15>();
|
||||
#endif
|
||||
|
||||
// test one case where we do not have pre-computed constants:
|
||||
std::cout << "Testing 17 point approximation:\n";
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_linear<std::float64_t, 17>();
|
||||
test_quadratic<std::float64_t, 17>();
|
||||
test_ca<std::float64_t, 17>();
|
||||
test_three_quadrature_schemes_examples<std::float64_t, 17>();
|
||||
test_integration_over_real_line<std::float64_t, 17>();
|
||||
test_right_limit_infinite<std::float64_t, 17>();
|
||||
test_left_limit_infinite<std::float64_t, 17>();
|
||||
#else
|
||||
test_linear<double, 17>();
|
||||
test_quadratic<double, 17>();
|
||||
test_ca<double, 17>();
|
||||
@@ -473,6 +498,8 @@ BOOST_AUTO_TEST_CASE(gauss_quadrature_test)
|
||||
test_integration_over_real_line<double, 17>();
|
||||
test_right_limit_infinite<double, 17>();
|
||||
test_left_limit_infinite<double, 17>();
|
||||
#endif
|
||||
|
||||
test_complex_lambert_w<std::complex<double>>();
|
||||
test_complex_lambert_w<std::complex<long double>>();
|
||||
#endif
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#pragma warning(disable:4127) // Conditional expression is constant
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdfloat>)
|
||||
# include <stdfloat>
|
||||
#endif
|
||||
|
||||
#if !defined(TEST1) && !defined(TEST2) && !defined(TEST3)
|
||||
# define TEST1
|
||||
# define TEST2
|
||||
@@ -445,6 +449,24 @@ BOOST_AUTO_TEST_CASE(gauss_quadrature_test)
|
||||
{
|
||||
|
||||
#ifdef TEST1
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_linear<std::float64_t, 7>();
|
||||
test_quadratic<std::float64_t, 7>();
|
||||
test_ca<std::float64_t, 7>();
|
||||
test_three_quadrature_schemes_examples<std::float64_t, 7>();
|
||||
test_integration_over_real_line<std::float64_t, 7>();
|
||||
test_right_limit_infinite<std::float64_t, 7>();
|
||||
test_left_limit_infinite<std::float64_t, 7>();
|
||||
|
||||
test_linear<std::float64_t, 9>();
|
||||
test_quadratic<std::float64_t, 9>();
|
||||
test_ca<std::float64_t, 9>();
|
||||
test_three_quadrature_schemes_examples<std::float64_t, 9>();
|
||||
test_integration_over_real_line<std::float64_t, 9>();
|
||||
test_right_limit_infinite<std::float64_t, 9>();
|
||||
test_left_limit_infinite<std::float64_t, 9>();
|
||||
#else
|
||||
test_linear<double, 7>();
|
||||
test_quadratic<double, 7>();
|
||||
test_ca<double, 7>();
|
||||
@@ -460,6 +482,7 @@ BOOST_AUTO_TEST_CASE(gauss_quadrature_test)
|
||||
test_integration_over_real_line<double, 9>();
|
||||
test_right_limit_infinite<double, 9>();
|
||||
test_left_limit_infinite<double, 9>();
|
||||
#endif
|
||||
|
||||
#if LDBL_MANT_DIG < 100 && defined(BOOST_MATH_RUN_MP_TESTS)
|
||||
test_linear<cpp_bin_float_quad, 10>();
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <boost/math/quadrature/naive_monte_carlo.hpp>
|
||||
|
||||
#if __has_include(<stdfloat>)
|
||||
# include <stdfloat>
|
||||
#endif
|
||||
|
||||
using std::abs;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
@@ -452,93 +456,249 @@ BOOST_AUTO_TEST_CASE(naive_monte_carlo_test)
|
||||
{
|
||||
std::cout << "Default hardware concurrency = " << std::thread::hardware_concurrency() << std::endl;
|
||||
#if !defined(TEST) || TEST == 1
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_finite_singular_boundary<std::float64_t>();
|
||||
test_finite_singular_boundary<std::float32_t>();
|
||||
#else
|
||||
test_finite_singular_boundary<double>();
|
||||
test_finite_singular_boundary<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 2
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_pi<std::float32_t>();
|
||||
test_pi<std::float64_t>();
|
||||
#else
|
||||
test_pi<float>();
|
||||
test_pi<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 3
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_pi_multithreaded<std::float32_t>();
|
||||
test_constant<std::float32_t>();
|
||||
#else
|
||||
test_pi_multithreaded<float>();
|
||||
test_constant<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//test_pi<long double>();
|
||||
#if !defined(TEST) || TEST == 4
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_constant<std::float64_t>();
|
||||
test_cancel_and_restart<std::float32_t>();
|
||||
#else
|
||||
test_constant<double>();
|
||||
//test_constant<long double>();
|
||||
test_cancel_and_restart<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 5
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_exception_from_integrand<std::float32_t>();
|
||||
test_variance<std::float32_t>();
|
||||
#else
|
||||
test_exception_from_integrand<float>();
|
||||
test_variance<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 6
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_variance<std::float64_t>();
|
||||
test_multithreaded_variance<std::float64_t>();
|
||||
#else
|
||||
test_variance<double>();
|
||||
test_multithreaded_variance<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 7
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_product<std::float32_t, 1>();
|
||||
test_product<std::float32_t, 2>();
|
||||
#else
|
||||
test_product<float, 1>();
|
||||
test_product<float, 2>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 8
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_product<std::float32_t, 3>();
|
||||
test_product<std::float32_t, 4>();
|
||||
test_product<std::float32_t, 5>();
|
||||
#else
|
||||
test_product<float, 3>();
|
||||
test_product<float, 4>();
|
||||
test_product<float, 5>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 9
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_product<std::float32_t, 6>();
|
||||
test_product<std::float64_t, 1>();
|
||||
#else
|
||||
test_product<float, 6>();
|
||||
test_product<double, 1>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 10
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_product<std::float64_t, 2>();
|
||||
#else
|
||||
test_product<double, 2>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 11
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_product<std::float64_t, 3>();
|
||||
test_product<std::float64_t, 4>();
|
||||
#else
|
||||
test_product<double, 3>();
|
||||
test_product<double, 4>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 12
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_upper_bound_infinite<std::float32_t>();
|
||||
test_upper_bound_infinite<std::float64_t>();
|
||||
#else
|
||||
test_upper_bound_infinite<float>();
|
||||
test_upper_bound_infinite<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 13
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_lower_bound_infinite<std::float32_t>();
|
||||
test_lower_bound_infinite<std::float64_t>();
|
||||
#else
|
||||
test_lower_bound_infinite<float>();
|
||||
test_lower_bound_infinite<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 14
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_lower_bound_infinite2<std::float32_t>();
|
||||
#else
|
||||
test_lower_bound_infinite2<float>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 15
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_double_infinite<std::float32_t>();
|
||||
test_double_infinite<std::float64_t>();
|
||||
#else
|
||||
test_double_infinite<float>();
|
||||
test_double_infinite<double>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 16
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_radovic<std::float32_t, 1>();
|
||||
test_radovic<std::float32_t, 2>();
|
||||
#else
|
||||
test_radovic<float, 1>();
|
||||
test_radovic<float, 2>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 17
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_radovic<std::float32_t, 3>();
|
||||
test_radovic<std::float64_t, 1>();
|
||||
#else
|
||||
test_radovic<float, 3>();
|
||||
test_radovic<double, 1>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 18
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_radovic<std::float64_t, 2>();
|
||||
test_radovic<std::float64_t, 3>();
|
||||
#else
|
||||
test_radovic<double, 2>();
|
||||
test_radovic<double, 3>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 19
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_radovic<std::float64_t, 4>();
|
||||
test_radovic<std::float64_t, 5>();
|
||||
#else
|
||||
test_radovic<double, 4>();
|
||||
test_radovic<double, 5>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 20
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_alternative_rng_1<std::float32_t, 3>();
|
||||
#else
|
||||
test_alternative_rng_1<float, 3>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 21
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_alternative_rng_1<std::float64_t, 3>();
|
||||
#else
|
||||
test_alternative_rng_1<double, 3>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 22
|
||||
|
||||
#ifdef __STDCPP_FLOAT32_T__
|
||||
test_alternative_rng_2<std::float32_t, 3>();
|
||||
#else
|
||||
test_alternative_rng_2<float, 3>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#if !defined(TEST) || TEST == 23
|
||||
|
||||
#ifdef __STDCPP_FLOAT64_T__
|
||||
test_alternative_rng_2<std::float64_t, 3>();
|
||||
#else
|
||||
test_alternative_rng_2<double, 3>();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
#ifdef BOOST_HAS_FLOAT128
|
||||
#include <boost/multiprecision/complex128.hpp>
|
||||
#endif
|
||||
|
||||
#if __has_include(<stdfloat>)
|
||||
# include <stdfloat>
|
||||
#endif
|
||||
|
||||
using boost::multiprecision::cpp_bin_float_50;
|
||||
using boost::multiprecision::cpp_bin_float_100;
|
||||
using boost::math::quadrature::trapezoidal;
|
||||
@@ -230,8 +235,14 @@ void test_rational_sin()
|
||||
|
||||
BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
{
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_constant<std::float32_t>();
|
||||
test_constant<std::float64_t>();
|
||||
#else
|
||||
test_constant<float>();
|
||||
test_constant<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_constant<long double>();
|
||||
#endif
|
||||
@@ -241,8 +252,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_constant<cpp_bin_float_50>();
|
||||
test_constant<cpp_bin_float_100>();
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_rational_periodic<std::float32_t>();
|
||||
test_rational_periodic<std::float64_t>();
|
||||
#else
|
||||
test_rational_periodic<float>();
|
||||
test_rational_periodic<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_rational_periodic<long double>();
|
||||
#endif
|
||||
@@ -255,8 +271,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_rational_periodic<cpp_bin_float_100>();
|
||||
#endif
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_bump_function<std::float32_t>();
|
||||
test_bump_function<std::float64_t>();
|
||||
#else
|
||||
test_bump_function<float>();
|
||||
test_bump_function<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_bump_function<long double>();
|
||||
#endif
|
||||
@@ -268,8 +289,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_rational_periodic<cpp_bin_float_50>();
|
||||
#endif
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_zero_function<std::float32_t>();
|
||||
test_zero_function<std::float64_t>();
|
||||
#else
|
||||
test_zero_function<float>();
|
||||
test_zero_function<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_zero_function<long double>();
|
||||
#endif
|
||||
@@ -282,8 +308,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_zero_function<cpp_bin_float_100>();
|
||||
#endif
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_sinsq<std::float32_t>();
|
||||
test_sinsq<std::float64_t>();
|
||||
#else
|
||||
test_sinsq<float>();
|
||||
test_sinsq<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_sinsq<long double>();
|
||||
#endif
|
||||
@@ -296,8 +327,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_sinsq<cpp_bin_float_100>();
|
||||
#endif
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_slowly_converging<std::float32_t>();
|
||||
test_slowly_converging<std::float64_t>();
|
||||
#else
|
||||
test_slowly_converging<float>();
|
||||
test_slowly_converging<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_slowly_converging<long double>();
|
||||
#endif
|
||||
@@ -305,8 +341,13 @@ BOOST_AUTO_TEST_CASE(trapezoidal_quadrature)
|
||||
test_slowly_converging<boost::math::concepts::real_concept>();
|
||||
#endif
|
||||
|
||||
#if defined(__STDCPP_FLOAT32_T__) && defined(__STDCPP_FLOAT64_T__)
|
||||
test_rational_sin<std::float32_t>();
|
||||
test_rational_sin<std::float64_t>();
|
||||
#else
|
||||
test_rational_sin<float>();
|
||||
test_rational_sin<double>();
|
||||
#endif
|
||||
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
|
||||
test_rational_sin<long double>();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user