From 0cb83f1893bf0523e7519a95953167b8cf89f2fd Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Wed, 18 Dec 2019 18:28:31 +0100 Subject: [PATCH] core: add setter for seed of the random generator --- src/eigenpy.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/eigenpy.cpp b/src/eigenpy.cpp index aafe0ef..efdb997 100644 --- a/src/eigenpy.cpp +++ b/src/eigenpy.cpp @@ -4,10 +4,16 @@ */ #include "eigenpy/eigenpy.hpp" +#include <stdlib.h> namespace eigenpy { + void seed(unsigned int seed_value) + { + srand(seed_value); + } + /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */ void enableEigenPy() { @@ -27,6 +33,9 @@ namespace eigenpy bp::def("switchToNumpyMatrix",&NumpyType::switchToNumpyMatrix, "Set the conversion from Eigen::Matrix to numpy.matrix."); + + bp::def("seed",&seed,bp::arg("seed_value"), + "Initialize the pseudo-random number generator with the argument seed_value."); ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2d); ENABLE_SPECIFIC_MATRIX_TYPE(Matrix2f); -- GitLab