Reputation: 667
does anyone know, which algorithm the Eigen library for C++ uses in the method Random():
?
If eigen passes this decision on to the compiler (using its standard method to create pseudo random numbers), than I would like to know which algorithm g++ (gcc49 4.9.2_2) uses as default.
Any helpful hint is much appreciated.
Upvotes: 0
Views: 176
Reputation: 10596
As Paul R pointed out, the default is to just call rand
. If you look in Eigen/src/Core/MathFunctions.h you'll find the default:
template<typename Scalar>
struct random_default_impl<Scalar, false, false>
{
static inline Scalar run(const Scalar& x, const Scalar& y)
{
return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX);
}
static inline Scalar run()
{
return run(Scalar(NumTraits<Scalar>::IsSigned ? -1 : 0), Scalar(1));
}
};
or variants on the theme (for different variable types).
Upvotes: 3