Commit bafe6006 authored by Jean-Baptiste Mouret's avatar Jean-Baptiste Mouret
Browse files

misc fixes

parent 4b0a40da
......@@ -2,7 +2,6 @@
#define LIMBO_TOOLS_HPP
///@defgroup tools
#include <limbo/tools/macros.hpp>
#include <limbo/tools/parallel.hpp>
#include <limbo/tools/math.hpp>
......
......@@ -13,6 +13,8 @@
#include <tbb/blocked_range.h>
#endif
///@defgroup par_tools
namespace limbo {
namespace tools {
namespace par {
......@@ -27,7 +29,7 @@ namespace limbo {
template <typename X>
using vector = tbb::concurrent_vector<X>; // Template alias (for GCC 4.7 and later)
#endif
/// @ingroup tools
/// @ingroup par_tools
/// convert a std::vector to something else (e.g. a std::list)
template <typename V>
std::vector<typename V::value_type> convert_vector(const V& v)
......@@ -62,14 +64,14 @@ namespace limbo {
static tbb::task_scheduler_init init;
}
#else
///@ingroup tools
///@ingroup par_tools
/// init TBB (if activated) for multi-core computing
void init()
{
}
#endif
///@ingroup tools
///@ingroup par_tools
/// parallel for
template <typename F>
inline void loop(size_t begin, size_t end, const F& f)
......@@ -86,7 +88,7 @@ namespace limbo {
#endif
}
///@ingroup tools
///@ingroup par_tools
/// parallel max
template <typename T, typename F, typename C>
T max(const T& init, int num_steps, const F& f, const C& comp)
......@@ -122,7 +124,7 @@ namespace limbo {
return current_max;
#endif
}
/// @ingroup tools
/// @ingroup par_tools
/// parallel sort
template <typename T1, typename T2, typename T3>
inline void sort(T1 i1, T2 i2, T3 comp)
......@@ -134,14 +136,14 @@ namespace limbo {
#endif
}
/// @ingroup tools
/// @ingroup par_tools
/// replicate a function nb times
template <typename F>
inline void replicate(size_t nb, const F& f)
{
#ifdef USE_TBB
tbb::parallel_for(size_t(0), nb, size_t(1), [&](size_t i) {
// clang-format off
// clang-format off
f();
// clang-format on
});
......
......@@ -45,7 +45,7 @@
namespace limbo {
namespace tools {
///@ingroup tools
/// @ingroup tools
/// random vector in [0, 1]
Eigen::VectorXd random_vector(int size)
{
......@@ -57,7 +57,7 @@ namespace limbo {
/// a mt19937-based random generator (mutex-protected)
///
/// usage :
/// - rgen_double_t(0.0, 1.0);
/// - RandomGenerator<double>(0.0, 1.0);
/// - double r = rgen.rand();
template <typename D>
class RandomGenerator {
......@@ -75,10 +75,18 @@ namespace limbo {
std::mt19937 _rgen;
std::mutex _mutex;
};
/// @ingroup tools
using rdist_double_t = std::uniform_real_distribution<double>;
/// @ingroup tools
using rdist_int_t = std::uniform_int_distribution<int>;
/// @ingroup tools
/// Double random number generator
using rgen_double_t = RandomGenerator<rdist_double_t>;
///@ingroup tools
///integer random number generator
using rgen_int_t = RandomGenerator<rdist_int_t>;
}
}
......
Supports Markdown
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