Search code examples
visual-studioboostrandommt19937

random number invocation from boost toolkit


Attempting to use the Boost toolkit on Windows 7, Vis Studio 2013.

I've successfully run their example here

There's a set of lines in the code:

// This is a typedef for a random number generator.
// Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand
typedef boost::minstd_rand base_generator_type;

I comment out the typedef and replace with

typedef  boost::mt19937

exactly as the instruction says, but the problem is that the rest of the program doesn't recognize this. I think they left off some instruction there. Does anyone know what I need to do?

Addendum, the complete fix is this: Step 1. Include the corresponding hpp:

#include <boost/random/mersenne_twister.hpp>

Step 2. Use the correct typedef statement: typedef boost::mt19937 base_generator_type;


Solution

  • You need to include <boost/random/mersenne_twister.hpp> to use boost::mt19937