16#if defined(HPFEM_USE_BOOST_MATH)
17#include <boost/math/special_functions/bessel.hpp>
25#if defined(HPFEM_USE_BOOST_MATH)
29using SpecialMathPolicy = boost::math::policies::policy<
30 boost::math::policies::domain_error<boost::math::policies::errno_on_error>,
31 boost::math::policies::pole_error<boost::math::policies::errno_on_error>,
32 boost::math::policies::overflow_error<boost::math::policies::errno_on_error>,
33 boost::math::policies::evaluation_error<boost::math::policies::errno_on_error>,
34 boost::math::policies::promote_double<false>>;
41#if defined(HPFEM_USE_BOOST_MATH)
42 return boost::math::cyl_bessel_j(nu, x, detail::SpecialMathPolicy());
44 return std::cyl_bessel_j(nu, x);
51#if defined(HPFEM_USE_BOOST_MATH)
52 return boost::math::cyl_neumann(nu, x, detail::SpecialMathPolicy());
54 return std::cyl_neumann(nu, x);
60#if defined(HPFEM_USE_BOOST_MATH)
61 return boost::math::sph_bessel(order, x, detail::SpecialMathPolicy());
63 return std::sph_bessel(order, x);
69#if defined(HPFEM_USE_BOOST_MATH)
70 return boost::math::sph_neumann(order, x, detail::SpecialMathPolicy());
72 return std::sph_neumann(order, x);
80 return (order < 0 && (order % 2) != 0) ? -value : value;
86 return (order < 0 && (order % 2) != 0) ? -value : value;
108 return sph_bessel(
static_cast<unsigned>(order), x);
113 return sph_neumann(
static_cast<unsigned>(order), x);
128 if (max_order < 0)
throw InvalidArgument(
"spherical_bessel_j: max_order must be non-negative");
129 std::vector<Complex> j(
static_cast<std::size_t
>(max_order) + 1,
Complex{0.0, 0.0});
130 if (std::abs(z) < 1e-300) {
135 const int start = max_order + 20 +
static_cast<int>(std::ceil(std::abs(z)));
138 for (
int n = start; n > 0; --n) {
139 const Complex previous =
static_cast<Real>(2 * n + 1) / z * current - next;
142 if (n - 1 <= max_order) j[
static_cast<std::size_t
>(n - 1)] = current;
143 if (std::abs(current) > 1e200) {
144 constexpr Real kScale = 1e-200;
147 for (
auto& v : j) v *= kScale;
150 const Complex scale = std::sin(z) / z / j[0];
151 for (
auto& v : j) v *= scale;
163 if (max_order < 0)
throw InvalidArgument(
"bessel_i_scaled: max_order must be non-negative");
164 if (!(x >= 0))
throw InvalidArgument(
"bessel_i_scaled: x must be non-negative");
165 std::vector<Real> out(
static_cast<std::size_t
>(max_order) + 1, 0.0);
170 const int start = max_order + 32 +
static_cast<int>(std::ceil(std::sqrt(80.0 * x)));
172 Real current = 1e-300;
174 for (
int n = start; n > 0; --n) {
175 sum += 2.0 * current;
176 const Real previous = 2.0 * n / x * current + next;
179 if (n - 1 <= max_order) out[
static_cast<std::size_t
>(n - 1)] = current;
180 if (current > 1e200) {
181 constexpr Real kScale = 1e-200;
185 for (
auto& v : out) v *= kScale;
189 for (
auto& v : out) v /= sum;
Definition axisymmetric_estimator.hpp:39
double Real
Definition types.hpp:15
Complex spherical_hankel1(int order, Real x)
Definition special_functions.hpp:118
Complex hankel1_derivative(int order, Real x)
Derivative .
Definition special_functions.hpp:100
Real spherical_bessel_y(int order, Real x)
Spherical Bessel function of the second kind , n ≥ 0, x > 0.
Definition special_functions.hpp:112
Complex hankel1(int order, Real x)
Hankel function of the first kind , x > 0.
Definition special_functions.hpp:95
Real cyl_bessel_j(Real nu, Real x)
Definition special_functions.hpp:40
Real spherical_bessel_j(int order, Real x)
Spherical Bessel function of the first kind , n ≥ 0, real x ≥ 0.
Definition special_functions.hpp:107
Real sph_bessel(unsigned order, Real x)
Spherical Bessel function of the first kind , x ≥ 0 (std::sph_bessel).
Definition special_functions.hpp:59
Real bessel_j_derivative(int order, Real x)
Derivative .
Definition special_functions.hpp:90
std::vector< Real > bessel_i_scaled(int max_order, Real x)
Definition special_functions.hpp:162
Real bessel_y(int order, Real x)
Bessel function of the second kind , x > 0, any integer order.
Definition special_functions.hpp:84
Real bessel_j(int order, Real x)
Definition special_functions.hpp:78
Real cyl_neumann(Real nu, Real x)
Definition special_functions.hpp:50
Real sph_neumann(unsigned order, Real x)
Spherical Bessel function of the second kind , x > 0 (std::sph_neumann).
Definition special_functions.hpp:68
std::complex< double > Complex
Definition types.hpp:16