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

document tools

parent e381be6d
......@@ -27,6 +27,8 @@ namespace limbo {
template <typename X>
using vector = tbb::concurrent_vector<X>; // Template alias (for GCC 4.7 and later)
#endif
/// @ingroup 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)
{
......@@ -60,12 +62,15 @@ namespace limbo {
static tbb::task_scheduler_init init;
}
#else
///@ingroup tools
/// init TBB (if activated) for multi-core computing
void init()
{
}
#endif
// parallel for
///@ingroup tools
/// parallel for
template <typename F>
inline void loop(size_t begin, size_t end, const F& f)
{
......@@ -81,6 +86,8 @@ namespace limbo {
#endif
}
///@ingroup tools
/// parallel max
template <typename T, typename F, typename C>
T max(const T& init, int num_steps, const F& f, const C& comp)
{
......@@ -115,7 +122,8 @@ namespace limbo {
return current_max;
#endif
}
/// @ingroup tools
/// parallel sort
template <typename T1, typename T2, typename T3>
inline void sort(T1 i1, T2 i2, T3 comp)
{
......@@ -126,7 +134,8 @@ namespace limbo {
#endif
}
// replicate a function nb times
/// @ingroup tools
/// replicate a function nb times
template <typename F>
inline void replicate(size_t nb, const F& f)
{
......
......@@ -45,16 +45,20 @@
namespace limbo {
namespace tools {
// random vector in [0, 1]
///@ingroup tools
/// random vector in [0, 1]
Eigen::VectorXd random_vector(int size)
{
// Eigen returns in [-1:1] (??)
return ((Eigen::VectorXd::Random(size)).array() + 1.0) / 2.0;
}
// usage :
// rgen_double_t(0.0, 1.0);
// double r = rgen.rand();
/// @ingroup tools
/// a mt19937-based random generator (mutex-protected)
///
/// usage :
/// - rgen_double_t(0.0, 1.0);
/// - double r = rgen.rand();
template <typename D>
class RandomGenerator {
public:
......
......@@ -41,6 +41,8 @@
namespace limbo {
namespace tools {
/// @ingroup tools
/// easy way to get the current date
inline std::string date()
{
char date[30];
......@@ -50,6 +52,8 @@ namespace limbo {
return std::string(date);
}
/// @ingroup tools
/// easy way to get the hostame
inline std::string hostname()
{
char hostname[30];
......@@ -59,6 +63,8 @@ namespace limbo {
return std::string(hostname);
}
/// @ingroup tools
/// easy way to get the PID
inline std::string getpid()
{
return std::to_string(::getpid());
......
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