Skip to content

Commit 0cb83f1

Browse files
committed
core: add setter for seed of the random generator
1 parent c2608e8 commit 0cb83f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/eigenpy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
*/
55

66
#include "eigenpy/eigenpy.hpp"
7+
#include <stdlib.h>
78

89
namespace eigenpy
910
{
1011

12+
void seed(unsigned int seed_value)
13+
{
14+
srand(seed_value);
15+
}
16+
1117
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */
1218
void enableEigenPy()
1319
{
@@ -27,6 +33,9 @@ namespace eigenpy
2733

2834
bp::def("switchToNumpyMatrix",&NumpyType::switchToNumpyMatrix,
2935
"Set the conversion from Eigen::Matrix to numpy.matrix.");
36+
37+
bp::def("seed",&seed,bp::arg("seed_value"),
38+
"Initialize the pseudo-random number generator with the argument seed_value.");
3039

3140
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2d);
3241
ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2f);

0 commit comments

Comments
 (0)