Skip to content

Commit 7115c97

Browse files
authored
Merge pull request #697 from frstrtr/ci-steward/dgb-msvc-mpi
dgb: portable pi constant for MSVC Windows release lane (M_PI undeclared)
2 parents 52020cd + 627d812 commit 7115c97

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/impl/dgb/coin/binomial_conf_interval.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
namespace dgb {
2929
namespace coin {
3030

31+
// MSVC does not define M_PI (non-standard POSIX macro) without _USE_MATH_DEFINES;
32+
// use a portable constexpr to keep the Windows/MSVC release lane building.
33+
constexpr double kPi = 3.14159265358979323846;
34+
3135
// Oracle erf -- Abramowitz & Stegun formula 7.1.26 (util/math.py:100).
3236
// erf(-x) = -erf(x) handled via sign capture, exactly as the oracle.
3337
inline double erf_as7126(double x)
@@ -57,7 +61,7 @@ inline double ierf(double z)
5761
{
5862
double guess = 0.0;
5963
for (int i = 0; i < 10; ++i) {
60-
const double dy = 2.0 * std::exp(-guess * guess) / std::sqrt(M_PI);
64+
const double dy = 2.0 * std::exp(-guess * guess) / std::sqrt(kPi);
6165
const double y_over_dy = (erf_as7126(guess) - z) / dy;
6266
const double prev = guess;
6367
guess = guess - y_over_dy;

0 commit comments

Comments
 (0)