mardi 28 mai 2019

Boost Random Number Not Change

I have some problem when generating random number with boost library in CPP. When I try printout random number, the value return same value. Here is my code.

for(int i = 0; i < TOTAL_PARTICLES; i++) {
            boost::random::mt19937 engine(static_cast<unsigned int>(std::time(0)));                    
            randn = boost::bind(boost::random::uniform_real_distribution<>(-2.5, 2.5), engine);                            
            cout << "Random : " << randn() << endl;
        }




Aucun commentaire:

Enregistrer un commentaire