From de64f02ad3582308d9efa8682fd5b2cc25913ea6 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 16 Nov 2023 09:38:01 +0100 Subject: [PATCH] Add test case --- test/Jamfile.v2 | 1 + test/scipy_issue_14901_ncf.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 test/scipy_issue_14901_ncf.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 44c76058b..34a3ce777 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -896,6 +896,7 @@ test-suite distribution_tests : [ run git_issue_800.cpp ../../test/build//boost_unit_test_framework ] [ run git_issue_845.cpp ../../test/build//boost_unit_test_framework ] [ run scipy_issue_14901.cpp ../../test/build//boost_unit_test_framework ] + [ run scipy_issue_14901_ncf.cpp ../../test/build//boost_unit_test_framework ] [ run scipy_issue_15101.cpp ../../test/build//boost_unit_test_framework ] [ run scipy_issue_17146.cpp ../../test/build//boost_unit_test_framework ] [ run scipy_issue_17388.cpp ../../test/build//boost_unit_test_framework ] diff --git a/test/scipy_issue_14901_ncf.cpp b/test/scipy_issue_14901_ncf.cpp new file mode 100644 index 000000000..0be738269 --- /dev/null +++ b/test/scipy_issue_14901_ncf.cpp @@ -0,0 +1,27 @@ +// Copyright Matt Borland, 2023 +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See: https://github.com/scipy/scipy/issues/14901 + +#include +#include +#include "math_unit_test.hpp" + +#pragma STDC FENV_ACCESS ON + +int main() +{ + auto ncf1 = boost::math::non_central_f(1, 1, 1); + const auto cdf1 = boost::math::cdf(ncf1, 2); + + CHECK_ULP_CLOSE(cdf1, 1 - 0.5230393170884924, 20); + + if (std::fetestexcept(FE_INVALID) || std::fetestexcept(FE_DIVBYZERO)) + { + return 1; + } + + return boost::math::test::report_errors(); +}