Skip to content

Commit

Permalink
MP nan testing for kepF().
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed Oct 19, 2023
1 parent f5aa19f commit 89c2b74
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/kepF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mppp::real>(s, "cfunc", {kepF(h, k, lam)}, kw::prec = prec);

s.compile();

auto *cf_ptr = reinterpret_cast<void (*)(mppp::real *, const mppp::real *, const mppp::real *, const mppp::real *)>(
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<double>::quiet_NaN(), prec};
cf_ptr(&out, ins.data(), nullptr, nullptr);
REQUIRE(isnan(out));

ins[0] = mppp::real{std::numeric_limits<double>::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<double>::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

0 comments on commit 89c2b74

Please sign in to comment.