mercredi 23 décembre 2015

Initializing a ublas::vector with random numbers

Is there any straightforward way of filling a ublas::vector with random numbers? I'm looking forward to something like:

ublas::vector<double> vec = ublas::random_vector<double>(10, <random_generator>);

To populate the vector with 10 random numbers samples from a uniform distribution.

So far the best way I found is either using a for loop with a uniform_real_distribution, or with a std::generate + std::fill. But seems pretty obvious that, similar to zero_vector<double>, a random_vector<double> could exist somewhere and I'm missing it.

Is there any better approach?




Aucun commentaire:

Enregistrer un commentaire