From 60286202fdf085c5037d058bbc938e39bd3cb369 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 12 May 2016 17:32:41 +1000 Subject: [PATCH] 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 --- maths.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/maths.hpp b/maths.hpp index ec4750e5..74196267 100644 --- a/maths.hpp +++ b/maths.hpp @@ -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 ( - std::sqrt (2 * PI * n) * std::pow (n / E, n) + std::sqrt (2 * PI * n) * std::pow (n / E, n) ); }