I have been trying to use the c++ 11 mersenne_twister_engine class( http://www.cplusplus.com/reference/random/mersenne_twister_engine/) to generate numbers in the interval [0,1] however I am continually getting 0 on every number.
Here is my code snippet
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 generator(seed1);
for (int i=0; i < WIDTH * HEIGHT; i++) //GENERATES THE MATRIX OF CONNECTIVITY
{
double random = generator()/generator.max();
if ( random > VERT_CONNECTIVITY )
vert_con[i] = 0;
else vert_con[i] = 1;
}
generator() and generator.max() seem to be working... It is just random which gives me 0!
Thanks!
std::random_device
instead of a time seed.