Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
19d1b8d8
Commit
19d1b8d8
authored
Jan 20, 2018
by
Tiago Peixoto
Browse files
Fix compilation issue with clang
parent
f22bdb74
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/graph/inference/support/cache.hh
View file @
19d1b8d8
...
...
@@ -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
())
{
...
...
src/graph/inference/support/util.hh
View file @
19d1b8d8
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment