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
f3f8f42d
Commit
f3f8f42d
authored
May 30, 2016
by
Jean-Baptiste Mouret
Browse files
use a c++-11 rng instead of calling eigen3 for tools::random_vector()
parent
c5a8e7a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/limbo/tools/random_generator.hpp
View file @
f3f8f42d
...
...
@@ -45,14 +45,6 @@
namespace
limbo
{
namespace
tools
{
/// @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
;
}
/// @ingroup tools
/// a mt19937-based random generator (mutex-protected)
///
...
...
@@ -88,6 +80,20 @@ namespace limbo {
///@ingroup tools
///integer random number generator
using
rgen_int_t
=
RandomGenerator
<
rdist_int_t
>
;
/// @ingroup tools
/// random vector in [0, 1]
///
/// - this function is thread safe because the random number generator we use is thread-safe
/// - we use a C++11 random number generator
Eigen
::
VectorXd
random_vector
(
int
size
)
{
static
rgen_double_t
rgen
(
0.0
,
1.0
);
Eigen
::
VectorXd
res
(
size
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
res
[
i
]
=
rgen
.
rand
();
return
res
;
}
}
}
...
...
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