I have been following the documentation from the boost library to generate multiprecision random integers but In the documentation it is not mentioned how to set the seed.
I can't figure how to set the seed without getting compilation errors.
#include <boost/multiprecision/gmp.hpp>
#include <boost/multiprecision/random.hpp>
#include <fstream>
using namespace boost::multiprecision;
using namespace boost::random;
using namespace std;
//...
typedef independent_bits_engine<mt19937, N_BITS, mpz_int> generator_type;
int main()
{
// ...
generator_type gen;
seed_seq sed_seq = { 12064, 3867, 13555, 28676, 4599, 5031, 13040 };
gen.seed(sed_seq);
// ...
for(unsigned i = 0; i < SS; ++i) {
out
<< gen()
<< endl;
}
out.close();
return 0;
}
How do I compile:
$ g++ generateinputs.cpp -o generateinputs.o -L/gmp_install/lib -lgmp
And this are the compilation errors that I get:
generateinputs.cpp: In function ‘int main()’:
generateinputs.cpp:35:68: error: in C++98 ‘sed_seq’ must be initialized by constructor, not by ‘{...}’
seed_seq sed_seq = { 12064, 3867, 13555, 28676, 4599, 5031, 13040 };
^
generateinputs.cpp:35:68: error: could not convert ‘{12064, 3867, 13555, 28676, 4599, 5031, 13040}’ from ‘<brace-enclosed initializer list>’ to ‘boost::random::seed_seq’
I have also tried to compile with c++11 but I still have errors. ¿Can you show me how It's done?
Aucun commentaire:
Enregistrer un commentaire