iota comes from "not an iota", meaning getting nothing out.
oppsitely, means init with some increasing sequence.
std::shuffle with mt19937 would get random segquence.
mt19937 is a typedef of complicated hex input param for Meresene-Tiwster pseudo random generator
std::random_device{}() is a random seed
#include "stdafx.h"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
#include <numeric>
#include <random>
using namespace std;
int main()
{
vector<double> v(10);
iota(v.begin(), v.end(), -1.1);
for (auto n : v)
cout << n << endl;
cout << endl;
shuffle(v.begin(),v.end(), std::mt19937{ std::random_device{}() });
for (auto n : v)
cout << n << endl;
std::string s;
getline(cin, s);
return 0;
}
Sunday, November 6, 2016
iota and random shuffle
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment