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
4b0a40da
Commit
4b0a40da
authored
Mar 25, 2016
by
Jean-Baptiste Mouret
Browse files
document tools
parent
e381be6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/limbo/tools/parallel.hpp
View file @
4b0a40da
...
...
@@ -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
)
{
...
...
src/limbo/tools/random_generator.hpp
View file @
4b0a40da
...
...
@@ -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:
...
...
src/limbo/tools/sys.hpp
View file @
4b0a40da
...
...
@@ -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
());
...
...
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