2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Add better bessel_iterator tests.

This commit is contained in:
jzmaddock
2024-02-10 10:33:36 +00:00
parent 319a521430
commit 48b249115f
5 changed files with 87 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
#define BOOST_MATH_BESSEL_ITERATORS_HPP
#include <boost/math/tools/recurrence.hpp>
#include <boost/math/special_functions/bessel.hpp>
namespace boost {
namespace math {
@@ -154,7 +155,7 @@ namespace boost {
if (v > 1)
boost::math::policies::raise_domain_error("bessel_i_forwards_iterator<%1%>", "Order must be < 0 stable forwards recurrence but got %1%", v, Policy());
}
bessel_i_forwards_iterator(const T& v, const T& x, const T& I_v_plus_1, const T& I_v)
bessel_i_forwards_iterator(const T& v, const T& x, const T& I_v_minus_1, const T& I_v)
: it(detail::bessel_ik_recurrence<T>(v, x), I_v_plus_1, I_v)
{
if (v > 1)

View File

@@ -15,6 +15,8 @@
#include <boost/math/tools/fraction.hpp>
#include <boost/math/tools/cxx03_warn.hpp>
#include <boost/math/tools/assert.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/policies/error_handling.hpp>
namespace boost {
namespace math {

View File

@@ -181,6 +181,7 @@ test-suite special_fun :
[ run test_bessel_y_prime.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run test_bessel_i_prime.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run test_bessel_k_prime.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run bessel_iterator_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run test_beta.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ]
[ run test_bessel_airy_zeros.cpp ../../test/build//boost_unit_test_framework ]
[ run test_bernoulli_constants.cpp ../../test/build//boost_unit_test_framework ]

View File

@@ -0,0 +1,79 @@
// (C) Copyright John Maddock, 2024
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/math/special_functions/bessel_iterators.hpp>
BOOST_AUTO_TEST_CASE(test_main)
{
using boost::math::bessel_j_backwards_iterator;
using boost::math::bessel_i_backwards_iterator;
using boost::math::bessel_i_forwards_iterator;
BOOST_CHECK_THROW(bessel_j_backwards_iterator<double>(-2.3, 5.0), std::domain_error);
BOOST_CHECK_THROW(bessel_j_backwards_iterator<double>(-2.3, 5.0, 2.0), std::domain_error);
BOOST_CHECK_THROW(bessel_j_backwards_iterator<double>(-2.3, 5.0, 2.0, 2.0), std::domain_error);
double tolerance = std::numeric_limits<double>::epsilon() * 5;
{
bessel_j_backwards_iterator<double> i(12, 2.0);
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_j(8, 2.0), tolerance);
}
{
bessel_j_backwards_iterator<double> i(12, 2.0, boost::math::cyl_bessel_j(12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_j(8, 2.0), tolerance);
}
{
bessel_j_backwards_iterator<double> i(12, 2.0, boost::math::cyl_bessel_j(13, 2.0), boost::math::cyl_bessel_j(12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_j(8, 2.0), tolerance);
}
{
bessel_i_backwards_iterator<double> i(12, 2.0);
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(8, 2.0), tolerance);
}
{
bessel_i_backwards_iterator<double> i(12, 2.0, boost::math::cyl_bessel_i(12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(8, 2.0), tolerance);
}
{
bessel_i_backwards_iterator<double> i(12, 2.0, boost::math::cyl_bessel_i(13, 2.0), boost::math::cyl_bessel_i(12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(8, 2.0), tolerance);
}
{
bessel_i_forwards_iterator<double> i(-12, 2.0);
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(-8, 2.0), tolerance);
}
{
bessel_i_forwards_iterator<double> i(-12, 2.0, boost::math::cyl_bessel_i(-12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(-8, 2.0), tolerance);
}
{
bessel_i_forwards_iterator<double> i(-12, 2.0, boost::math::cyl_bessel_i(-13, 2.0), boost::math::cyl_bessel_i(-12, 2.0));
for (unsigned j = 0; j < 4; ++j)
++i;
BOOST_CHECK_CLOSE_FRACTION(*i, boost::math::cyl_bessel_i(-8, 2.0), tolerance);
}
}

View File

@@ -7,6 +7,9 @@
#include "math_unit_test.hpp"
#include <boost/math/special_functions/lambert_w.hpp>
#include <boost/math/tools/condition_numbers.hpp>
#if !defined(TEST) || (TEST > 1)
#include <boost/multiprecision/cpp_bin_float.hpp>
#endif
using std::abs;
using std::log;