Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void random_permute (arma::uvec& p, int n)
- {
- //n = last - first;
- srand(time(0));
- default_random_engine generator;
- uniform_int_distribution<int> distribution(0, n-1);
- for (size_t i = n - 1; i > 0; --i)
- {
- //generate random number between [0, n - 1].
- int t = distribution(generator);
- int temp = p(i);
- p(i) = p(t);
- p(t) = temp;
- }
- }
Add Comment
Please, Sign In to add comment