C++20 modernization: use new standard mathematical constants
parent
0f7ab97e69
commit
e86aeaf787
|
@ -22,6 +22,7 @@
|
|||
#include <limits>
|
||||
#include <stack>
|
||||
#include <cfenv>
|
||||
#include <numbers>
|
||||
|
||||
#include <dynmex.h>
|
||||
|
||||
|
@ -1877,13 +1878,13 @@ Evaluate::evaluateBlock(int it_, double *__restrict__ y, const double *__restric
|
|||
switch (op3)
|
||||
{
|
||||
case TrinaryOpcode::normcdf:
|
||||
Stack.push(0.5*(1+erf((v1-v2)/v3/M_SQRT2)));
|
||||
Stack.push(0.5*(1+erf((v1-v2)/v3/numbers::sqrt2)));
|
||||
#ifdef DEBUG
|
||||
tmp_out << " |normcdf(" << v1 << ", " << v2 << ", " << v3 << ")|";
|
||||
#endif
|
||||
break;
|
||||
case TrinaryOpcode::normpdf:
|
||||
Stack.push(1/(v3*sqrt(2*M_PI)*exp(pow((v1-v2)/v3, 2)/2)));
|
||||
Stack.push(1/(v3*sqrt(2*numbers::pi)*exp(pow((v1-v2)/v3, 2)/2)));
|
||||
#ifdef DEBUG
|
||||
tmp_out << " |normpdf(" << v1 << ", " << v2 << ", " << v3 << ")|";
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
**
|
||||
** Pseudo code of the algorithm is given at http://home.online.no/~pjacklam/notes/invnorm
|
||||
**
|
||||
** Copyright © 2010-2019 Dynare Team
|
||||
** Copyright © 2010-2023 Dynare Team
|
||||
**
|
||||
** This file is part of Dynare.
|
||||
**
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <numbers>
|
||||
|
||||
#include <omp.h>
|
||||
|
||||
|
@ -106,7 +107,7 @@ icdf(const T uniform)
|
|||
{
|
||||
T tmp, tmp_;
|
||||
tmp = .5*erfc(-gaussian/sqrt(2.0))-uniform;
|
||||
tmp_ = tmp*sqrt(2*M_PI)*exp(.5*gaussian*gaussian);
|
||||
tmp_ = tmp*sqrt(2*numbers::pi)*exp(.5*gaussian*gaussian);
|
||||
gaussian = gaussian - tmp_/(1+.5*gaussian*tmp_);
|
||||
}
|
||||
if (uniform == 0)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 150547b560c1259225712369df330a5e3266a2d7
|
||||
Subproject commit 3cc531315bd5abe5fe9d53145ec3c3de6723f1e0
|
Loading…
Reference in New Issue