maths: make stirling inline rather than constexpr

stirling uses cmath functions which aren't constexpr, such as std::pow.
this sometimes works under linux/gcc but fails under clang/freebsd
This commit is contained in:
Danny Robson 2016-05-12 17:32:41 +10:00
parent e17158b0bb
commit 60286202fd

View File

@ -399,11 +399,13 @@ namespace util {
//-----------------------------------------------------------------------------
/// stirlings approximation of factorials
constexpr uintmax_t
inline uintmax_t
stirling (unsigned n)
{
using real_t = double;
return static_cast<uintmax_t> (
std::sqrt (2 * PI<float> * n) * std::pow (n / E<float>, n)
std::sqrt (2 * PI<real_t> * n) * std::pow (n / E<real_t>, n)
);
}