Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void lcg(vector<unsigned int>& r, int seed, int size, unsigned long a, unsigned long c, unsigned long m){
- if (size == 1){
- r.push_back((a*seed+c)%m);
- return;
- }
- for(int i = 0; i < size; ++i){
- r.push_back(0);
- }
- r[0] = seed;
- for(int i = 1; i < size; ++i){
- r[i] = uint32_t((a*r[i-1]+c)%m);
- }
- r.erase(r.begin());
- }
- void generate(int seed, long size, double a2b, double i2u, vector<unsigned int> & a, vector<unsigned int>& b){
- //hardcoded consts for lcg generator
- //a = 50001
- //c = 49999
- //m = 2500000000
- int inter = int(size*i2u);
- int a_size = int(a2b*size*(1-i2u)/(a2b+1))+inter;
- int b_size = int(size*(1-i2u)/(a2b+1))+inter;
- lcg(a, seed, a_size, 50001, 49999, 2500000000);
- lcg(b, a[a_size - inter],b_size, 50001, 49999, 2500000000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement