From 89c2b744675aa477ccb4fc03a3916521a74a7de0 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Thu, 19 Oct 2023 11:42:02 +0200 Subject: [PATCH] MP nan testing for kepF(). --- test/kepF.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/kepF.cpp b/test/kepF.cpp index d3f346917..8e62b9453 100644 --- a/test/kepF.cpp +++ b/test/kepF.cpp @@ -483,6 +483,43 @@ TEST_CASE("cfunc mp") REQUIRE(eps_close(sin(lamval), sin(Fval + hval * cos(Fval) - kval * sin(Fval)))); } } + + // Check nan/invalid values handling. + llvm_state s; + + add_cfunc(s, "cfunc", {kepF(h, k, lam)}, kw::prec = prec); + + s.compile(); + + auto *cf_ptr = reinterpret_cast( + s.jit_lookup("cfunc")); + + mppp::real out(0, prec); + REQUIRE(ins.size() == 3u); + + ins[0] = mppp::real{.1, prec}; + ins[1] = mppp::real{.2, prec}; + ins[2] = mppp::real{std::numeric_limits::quiet_NaN(), prec}; + cf_ptr(&out, ins.data(), nullptr, nullptr); + REQUIRE(isnan(out)); + + ins[0] = mppp::real{std::numeric_limits::quiet_NaN(), prec}; + ins[1] = mppp::real{.1, prec}; + ins[2] = mppp::real{.2, prec}; + cf_ptr(&out, ins.data(), nullptr, nullptr); + REQUIRE(isnan(out)); + + ins[0] = mppp::real{.1, prec}; + ins[1] = mppp::real{std::numeric_limits::quiet_NaN(), prec}; + ins[2] = mppp::real{.2, prec}; + cf_ptr(&out, ins.data(), nullptr, nullptr); + REQUIRE(isnan(out)); + + ins[0] = mppp::real{.2, prec}; + ins[1] = mppp::real{1., prec}; + ins[2] = mppp::real{1., prec}; + cf_ptr(&out, ins.data(), nullptr, nullptr); + REQUIRE(isnan(out)); } #endif