11// /////////////////////////////////////////////////////////////////////////////
2- // Copyright Christopher Kormanyos 2021 - 2024 .
2+ // Copyright Christopher Kormanyos 2021 - 2025 .
33// Distributed under the Boost Software License,
44// Version 1.0. (See accompanying file LICENSE_1_0.txt
55// or copy at http://www.boost.org/LICENSE_1_0.txt)
3131#if (defined(STDFLOAT_FLOAT64_NATIVE_TYPE) || (defined(__STDCPP_FLOAT64_T__) && (__STDCPP_FLOAT64_T__ == 1)))
3232
3333using local_float_type = std::float64_t ;
34- static_assert ((std::numeric_limits<local_float_type>::digits >= 53 ), " Error: Incorrect my_float_type type definition" );
34+ static_assert ((std::numeric_limits<local_float_type>::digits >= 53 ), " Error: Incorrect local_float_type type definition" );
3535
3636#elif (defined(STDFLOAT_FLOAT32_NATIVE_TYPE) || (defined(__STDCPP_FLOAT32_T__) && (__STDCPP_FLOAT32_T__ == 1)))
3737
3838using local_float_type = std::float32_t ;
39- static_assert ((std::numeric_limits<local_float_type>::digits >= 24 ), " Error: Incorrect my_float_type type definition" );
39+ static_assert ((std::numeric_limits<local_float_type>::digits >= 24 ), " Error: Incorrect local_float_type type definition" );
4040
4141#else
4242
4343using local_float_type = double ;
44- static_assert ((std::numeric_limits<local_float_type>::digits >= 53 ), " Error: Incorrect my_float_type type definition" );
44+ static_assert ((std::numeric_limits<local_float_type>::digits >= 53 ), " Error: Incorrect local_float_type type definition" );
4545
4646#endif
4747
@@ -56,50 +56,55 @@ using my_float_type = ::local_float_type;
5656#include < math/calculus/integral.h>
5757#include < math/constants/constants.h>
5858
59- namespace
59+ namespace local
6060{
6161 template <typename FloatingPointType>
6262 auto cyl_bessel_j (const std::uint_fast8_t n, const FloatingPointType& x) -> FloatingPointType
6363 {
6464 using local_float_type = FloatingPointType;
6565
66- constexpr auto epsilon = std::numeric_limits<local_float_type>::epsilon ();
67-
6866 using std::sqrt;
6967
70- const auto tol = sqrt (epsilon);
71-
72- const auto integration_result =
73- math::integral (static_cast <local_float_type>(0 ),
74- math::constants::pi<local_float_type>(),
75- tol,
76- [&x, &n](const local_float_type& t) noexcept
77- {
78- using std::cos;
79- using std::sin;
80-
81- return
82- static_cast <local_float_type>
83- (
84- cos (x * sin (t) - (t * static_cast <local_float_type>(n)))
85- );
86- });
68+ const local_float_type tol { sqrt (std::numeric_limits<local_float_type>::epsilon ()) };
69+
70+ const local_float_type
71+ integration_result
72+ {
73+ math::integral
74+ (
75+ static_cast <local_float_type>(0 ),
76+ math::constants::pi<local_float_type>(),
77+ tol,
78+ [&x, &n](const local_float_type& t) noexcept
79+ {
80+ using std::cos;
81+ using std::sin;
82+
83+ return cos (static_cast <local_float_type>((x * sin (t)) - (t * static_cast <local_float_type>(n))));
84+ }
85+ )
86+ };
8787
8888 return integration_result / math::constants::pi<local_float_type>();
8989 }
90- }
90+ } // namespace local
9191
9292auto app::benchmark::run_trapezoid_integral () -> bool
9393{
94- constexpr auto app_benchmark_tolerance =
95- static_cast <my_float_type>
96- (
94+ constexpr my_float_type
95+ app_benchmark_tolerance
96+ {
9797 std::numeric_limits<my_float_type>::epsilon () * static_cast <my_float_type>(100 .0L )
98- ) ;
98+ } ;
9999
100- // Compute y = cyl_bessel_j(2, 1.23) = 0.16636938378681407351267852431513159437103348245333
100+ // Test the value of a Bessel function.
101+ // Here is a control value from Wolfram Alpha.
101102 // N[BesselJ[2, 123/100], 50]
102- const auto j2 = cyl_bessel_j (static_cast <std::uint_fast8_t >(UINT8_C (2 )), static_cast <my_float_type>(1 .23L ));
103+ // 0.16636938378681407351267852431513159437103348245333
104+
105+ // Compute cyl_bessel_j(2, 1.23)
106+
107+ const my_float_type j2 { local::cyl_bessel_j (std::uint_fast8_t { UINT8_C (2 ) }, static_cast <my_float_type>(1 .23L )) };
103108
104109 const bool app_benchmark_result_is_ok =
105110 detail::is_close_fraction
0 commit comments