openGPMP
Open Source Mathematics Package
random.cpp
Go to the documentation of this file.
1 #include "../../include/nt/random.hpp"
2 #include <cstdint>
3 #include <iostream>
4 #include <random>
5 
6 int main() {
7  // generates a random 32 bit unsigned integer using a linear
8  // congruential generator (LCG)
10  6364136223846793005ULL,
11  1442695040888963407ULL);
12 
13  uint64_t res = gen();
14 
15  std::cout << "Random value: " << res << std::endl;
16 
17  static std::linear_congruential_engine<uint64_t,
18  6364136223846793005ULL,
19  1442695040888963407ULL,
20  std::numeric_limits<uint64_t>::max()>
21  engine;
22 
23  // Get the next random number from the engine
24  uint64_t std_lcg_res = static_cast<unsigned int>(engine());
25 
26  std::cout << "Random value: " << std_lcg_res << std::endl;
27 
28  return 0;
29 }
Linear Congruential Generator.
Definition: random.hpp:82
int main()
Definition: random.cpp:6