From 55e2b17b020e236f6d4b3bac541c08ae5d715aee Mon Sep 17 00:00:00 2001 From: Jacob Hass Date: Fri, 2 Jan 2026 10:29:52 -0800 Subject: [PATCH] Added boost tuple support --- .../math/distributions/non_central_f.hpp | 24 +++++++++++++++++-- test/test_nc_f.cpp | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/boost/math/distributions/non_central_f.hpp b/include/boost/math/distributions/non_central_f.hpp index 5013c2408..63736a2b5 100644 --- a/include/boost/math/distributions/non_central_f.hpp +++ b/include/boost/math/distributions/non_central_f.hpp @@ -17,6 +17,7 @@ #include #include #include +#include // complements namespace boost { @@ -24,8 +25,6 @@ namespace boost { namespace detail { - /* Need to rewrite this according to `find_non_centrality` in - non_central_chi_squared.hpp */ template struct non_centrality_finder_f { @@ -128,6 +127,27 @@ namespace boost result, function); } + template + BOOST_MATH_GPU_ENABLED static RealType find_non_centrality(const complemented4_type& c) + { + constexpr auto function = "non_central_f_distribution<%1%>::find_non_centrality"; + typedef typename policies::evaluation::type eval_type; + typedef typename policies::normalise< + Policy, + policies::promote_float, + policies::promote_double, + policies::discrete_quantile<>, + policies::assert_undefined<> >::type forwarding_policy; + eval_type result = detail::find_non_centrality_f( + static_cast(c.dist), + static_cast(c.param1), + static_cast(c.param2), + static_cast(c.param3), + forwarding_policy()); + return policies::checked_narrowing_cast( + result, + function); + } private: // Data member, initialized by constructor. RealType v1; // alpha. diff --git a/test/test_nc_f.cpp b/test/test_nc_f.cpp index 22cc667d5..064e9eb88 100644 --- a/test/test_nc_f.cpp +++ b/test/test_nc_f.cpp @@ -143,6 +143,8 @@ void test_spot( quantile(complement(dist, Q)), x, tol * 10); BOOST_CHECK_CLOSE( dist.find_non_centrality(a, b, P, x), ncp, tol * 10); + BOOST_CHECK_CLOSE( + dist.find_non_centrality(boost::math::complement(a, b, P, x)), ncp, tol * 10); } if(boost::math::tools::digits() > 50) {