Commit 6c51a824 authored by Tiago Peixoto's avatar Tiago Peixoto

Fix compilation errors with clang

parent e7a63ff2
......@@ -15,7 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BOOST_PYTHON_MAX_ARITY 40
#include <boost/python.hpp>
#include <cmath>
......@@ -42,6 +41,8 @@
using namespace boost;
using namespace graph_tool;
// ====================
// Entropy calculation
// ====================
......@@ -321,7 +322,8 @@ struct move_sweep_dispatch
cavity_sampler, sequential, parallel, random_move, c,
nmerges, ntries,
merge_map.get_unchecked(num_vertices(g)),
partition_stats, verbose, rng, S, nmoves);
partition_stats, verbose, rng, S, nmoves,
overlap_stats_t());
}
catch (bad_any_cast&)
{
......@@ -342,7 +344,8 @@ struct move_sweep_dispatch
cavity_sampler, sequential, parallel, random_move, c,
nmerges, ntries,
merge_map.get_unchecked(num_vertices(g)),
partition_stats, verbose, rng, S, nmoves);
partition_stats, verbose, rng, S, nmoves,
overlap_stats_t());
}
}
};
......
......@@ -22,6 +22,7 @@
#include <iostream>
#include <queue>
#include <boost/math/special_functions/zeta.hpp>
#include <boost/functional/hash.hpp>
#include "config.h"
#include <unordered_set>
......@@ -40,6 +41,33 @@
#include <omp.h>
#endif
namespace std
{
template <class T1, class T2>
struct hash<std::tuple<T1, T2>>
{
size_t operator()(std::tuple<T1, T2> const& v) const
{
std::size_t seed = 0;
boost::hash_combine(seed, std::get<0>(v));
boost::hash_combine(seed, std::get<1>(v));
return seed;
}
};
template <class T1, class T2, class T3>
struct hash<std::tuple<T1, T2, T3>>
{
size_t operator()(std::tuple<T1, T2, T3> const& v) const
{
std::size_t seed = 0;
boost::hash_combine(seed, std::get<0>(v));
boost::hash_combine(seed, std::get<1>(v));
boost::hash_combine(seed, std::get<2>(v));
return seed;
}
};
}
double spence(double);
......@@ -389,9 +417,9 @@ class partition_stats_t
public:
#ifdef HAVE_SPARSEHASH
typedef dense_hash_map<pair<size_t,size_t>, int, boost::hash<pair<size_t,size_t>>> map_t;
typedef dense_hash_map<pair<size_t,size_t>, int> map_t;
#else
typedef unordered_map<pair<size_t,size_t>, int, boost::hash<pair<size_t,size_t>>> map_t;
typedef unordered_map<pair<size_t,size_t>, int> map_t;
#endif
partition_stats_t() : _enabled(false) {}
......@@ -1816,11 +1844,10 @@ struct merge_cmp_less
}
};
class overlap_stats_t;
//A single Monte Carlo Markov chain sweep
template <class Graph, class BGraph, class EMprop, class Eprop, class Vprop,
class EMat, class EVprop, class VEprop, class SamplerMap, class RNG>
class EMat, class EVprop, class VEprop, class SamplerMap, class OStats,
class RNG>
void move_sweep(EMprop mrs, Vprop mrp, Vprop mrm, Vprop wr, Vprop b,
Vprop clabel, vector<int>& vlist, bool deg_corr, bool dense,
bool multigraph, double beta, Eprop eweight, Vprop vweight,
......@@ -1829,11 +1856,10 @@ void move_sweep(EMprop mrs, Vprop mrp, Vprop mrm, Vprop wr, Vprop b,
SamplerMap cavity_neighbour_sampler, bool sequential,
bool parallel, bool random_move, double c, size_t nmerges,
size_t ntries, Vprop merge_map,
partition_stats_t& partition_stats, bool verbose,
RNG& rng, double& S, size_t& nmoves)
partition_stats_t& partition_stats, bool verbose, RNG& rng,
double& S, size_t& nmoves, OStats overlap_stats)
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
overlap_stats_t overlap_stats;
size_t B = num_vertices(bg);
......
......@@ -796,7 +796,7 @@ struct get_augmented_overlap
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
unordered_map<std::tuple<int, int>, size_t, boost::hash<std::tuple<int, int>>> idx_map;
unordered_map<std::tuple<int, int>, size_t> idx_map;
vector<std::tuple<int, int>> idx_rmap;
size_t pos = 0;
......@@ -851,7 +851,7 @@ struct get_overlap_split
template <class Graph, class VVProp, class VProp>
void operator()(Graph& g, VVProp bv, VProp b) const
{
unordered_map<vector<int>, size_t, boost::hash<vector<int>>> bvset;
unordered_map<vector<int>, size_t> bvset;
for (auto v : vertices_range(g))
{
......
......@@ -232,12 +232,12 @@ public:
typedef std::tuple<size_t, size_t, size_t> key_t; // u, r, s
#ifdef HAVE_SPARSEHASH
dense_hash_map<key_t, int, boost::hash<key_t>> out_us;
dense_hash_map<key_t, int> out_us;
out_us.set_empty_key(key_t(numeric_limits<size_t>::max(),
numeric_limits<size_t>::max(),
numeric_limits<size_t>::max()));
#else
unordered_map<key_t, int, boost::hash<key_t>> out_us;
unordered_map<key_t, int> out_us;
#endif
for (auto u : _parallel_bundles[m])
......@@ -344,27 +344,19 @@ struct overlap_partition_stats_t
typedef vector<int> bv_t;
#ifdef HAVE_SPARSEHASH
typedef dense_hash_map<bv_t, size_t,
boost::hash<bv_t>> bhist_t;
typedef dense_hash_map<cdeg_t, size_t,
boost::hash<cdeg_t>> cdeg_hist_t;
typedef dense_hash_map<bv_t, size_t> bhist_t;
typedef dense_hash_map<cdeg_t, size_t> cdeg_hist_t;
typedef dense_hash_map<bv_t, cdeg_hist_t,
boost::hash<bv_t>> deg_hist_t;
typedef dense_hash_map<bv_t, cdeg_hist_t> deg_hist_t;
typedef dense_hash_map<bv_t, vector<size_t>,
boost::hash<bv_t>> ebhist_t;
typedef dense_hash_map<bv_t, vector<size_t>> ebhist_t;
#else
typedef unordered_map<bv_t, size_t,
boost::hash<bv_t>> bhist_t;
typedef unordered_map<cdeg_t, size_t,
boost::hash<cdeg_t>> cdeg_hist_t;
typedef unordered_map<bv_t, size_t> bhist_t;
typedef unordered_map<cdeg_t, size_t> cdeg_hist_t;
typedef unordered_map<bv_t, cdeg_hist_t,
boost::hash<bv_t>> deg_hist_t;
typedef unordered_map<bv_t, cdeg_hist_t> deg_hist_t;
typedef unordered_map<bv_t, vector<size_t>,
boost::hash<bv_t>> ebhist_t;
typedef unordered_map<bv_t, vector<size_t>> ebhist_t;
#endif
typedef unordered_map<int, int> dmap_t;
......@@ -538,8 +530,7 @@ struct overlap_partition_stats_t
}
// unordered_map<size_t,
// unordered_map<deg_t, size_t,
// boost::hash<deg_t>>> bdeg_hist;
// unordered_map<deg_t, size_t>> bdeg_hist;
// for (auto& bv_h : _deg_hist)
// {
......@@ -639,8 +630,7 @@ struct overlap_partition_stats_t
//const double z2 = boost::math::zeta(2);
// unordered_map<size_t,
// unordered_map<deg_t, size_t,
// boost::hash<deg_t>>> bdeg_hist;
// unordered_map<deg_t, size_t>>> bdeg_hist;
// for (auto& bv_h : _deg_hist)
// {
......@@ -1220,7 +1210,7 @@ struct entropy_parallel_edges_overlap
auto& he = overlap_stats.get_half_edges(i);
typedef std::tuple<size_t, size_t, size_t> key_t; // u, r, s
unordered_map<key_t, int, boost::hash<key_t>> out_us;
unordered_map<key_t, int> out_us;
for (auto u : he)
{
if (visited[u])
......
......@@ -164,8 +164,7 @@ public:
private:
// Generic graph_action functor. See graph_filtering.hh for details.
template <class Action, class GraphViews, class Wrap, class TR1, class TR2,
class TR3, class TR4>
template <class Action, class GraphViews, class Wrap, class... TRS>
friend struct detail::graph_action;
// python interface
......
......@@ -562,12 +562,12 @@ public:
return get(k);
}
const reference operator[](const key_type& k) const
reference operator[](const key_type& k) const
{
return get(k);
}
const reference get(const key_type& k) const
reference get(const key_type& k) const
{
typename Container::iterator val;
val = _base_map->find(k);
......
......@@ -88,7 +88,7 @@ struct inner_loop
template <class T>
void operator()(T) const
{
nested_for_each_imp<TRS...>(_a.join<T>());
nested_for_each_imp<TRS...>(_a.template join<T>());
}
Action _a;
......
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