Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthias Mayr
limbo
Commits
bafe6006
Commit
bafe6006
authored
Mar 25, 2016
by
Jean-Baptiste Mouret
Browse files
misc fixes
parent
4b0a40da
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/limbo/tools.hpp
View file @
bafe6006
...
...
@@ -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>
...
...
src/limbo/tools/parallel.hpp
View file @
bafe6006
...
...
@@ -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
});
...
...
src/limbo/tools/random_generator.hpp
View file @
bafe6006
...
...
@@ -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
>
;
}
}
...
...
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