Commit 19d1b8d8 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix compilation issue with clang

parent f22bdb74
......@@ -38,15 +38,16 @@ extern vector<double> __lgamma_cache;
void init_safelog(size_t x);
inline double safelog(auto x)
template <class T>
inline double safelog(T x)
{
if (x == 0)
return 0;
return log(x);
}
template <bool Init=true>
inline double safelog_fast(auto x)
template <bool Init=true, class T>
inline double safelog_fast(T x)
{
if (size_t(x) >= __safelog_cache.size())
{
......@@ -60,13 +61,14 @@ inline double safelog_fast(auto x)
void init_xlogx(size_t x);
inline double xlogx(auto x)
template <class T>
inline double xlogx(T x)
{
return x * safelog(x);
}
template <bool Init=true>
inline double xlogx_fast(auto x)
template <bool Init=true, class T>
inline double xlogx_fast(T x)
{
if (size_t(x) >= __xlogx_cache.size())
{
......@@ -80,8 +82,8 @@ inline double xlogx_fast(auto x)
void init_lgamma(size_t x);
template <bool Init=true>
inline double lgamma_fast(auto x)
template <bool Init=true, class T>
inline double lgamma_fast(T x)
{
if (size_t(x) >= __lgamma_cache.size())
{
......
......@@ -29,7 +29,8 @@ namespace graph_tool
{
using namespace boost;
inline double lbinom(auto N, auto k)
template <class T1, class T2>
inline double lbinom(T1 N, T2 k)
{
if (N == 0 || k == 0 || k >= N)
return 0;
......@@ -38,15 +39,16 @@ inline double lbinom(auto N, auto k)
return ((lgamma(N + 1) - lgamma(k + 1)) - lgamma(N - k + 1));
}
template <bool Init=true>
inline double lbinom_fast(auto N, auto k)
template <bool Init=true, class T1, class T2>
inline double lbinom_fast(T1 N, T2 k)
{
if (N == 0 || k == 0 || k > N)
return 0;
return ((lgamma_fast<Init>(N + 1) - lgamma_fast<Init>(k + 1)) - lgamma_fast<Init>(N - k + 1));
}
inline double lbinom_careful(auto N, auto k)
template <class T1, class T2>
inline double lbinom_careful(T1 N, T2 k)
{
if (N == 0 || k == 0 || k >= N)
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment