C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2016-09-06 08:27:19 +10:00
parent e0b0aa5130
commit 92dc4470c4
9 changed files with 175 additions and 109 deletions

View File

@ -33,7 +33,8 @@ struct rnd_01 : public exprtk::ifunction<T>
inline T operator()()
{
// Note: Do not use this in production
return T(::rand() / T(RAND_MAX + 1));
// Result is in the interval [0,1)
return T(::rand() / T(RAND_MAX + 1.0));
}
};
@ -61,7 +62,7 @@ void monte_carlo_pi()
const T approximate_pi = expression.value();
const T real_pi = T(3.141592653589793238462);
const T real_pi = T(3.141592653589793238462643383279502); // or close enough...
printf("pi ~ %20.17f\terror: %20.17f\n",
approximate_pi,