C++ TR1 Random Number Gen

closed account (4oL1hbRD)

Anyone know of any good documentation on the <random> header of TR1.
I can hardly find anything.

I did find the following example for picking a random# between 1 and 10
at http://www.johndcook.com/cpp_TR1_random.html#start

However, what is "eng". Visual Studio 10 does not recognize it.

And it give me a conversion error. I tried static_cast but that wouldn't work
either.

Anyway, how do I store this random# as an int. Thanks.


1
2
    std::tr1::uniform_int<int> unif(1, 10);
    int x = unif(eng);
eng is an instance of one of the engines mentioned earlier.
This might help. I'm not sure how different the TR1 implementation is from the original Boost though.

http://www.boost.org/doc/libs/1_49_0/doc/html/boost_random/tutorial.html
closed account (4oL1hbRD)
Thanks. I'll try the boost libraries sometime.

For the TR1,

So "eng" is the engine. So let's say I want linear_congruential.

 
int x = unif(linear_congruential)


That does not work - name not recognized.

Do I need another header in additon to <random>? If so, what?

"#include linear_congruential" does not work. Am I missing files?
Topic archived. No new replies allowed.