简体   繁体   中英

How to use MT (or similar) RNG algorithm in CPP implementation?

I want to implement MT alg in CPP (I just can't use C++11 sadly) I've found a lot of algorithms like SFMT, dSFMT, some versions of Tiny MT etc; but as I saw the documentation of those algs, I think they works for range like <0,2) (from doxygen documentation)

Need any ideas how to replace basic RNG algorithm

SRAND(TIME(NULL))

With something better

Boost.Random提供了很多线程安全的随机生成器,它们可以与C ++ 98一起使用。

If you dont want Boost dependency there are multiple standalone MT implementations

Mersenne Twister 1

Mersenne Twister 2

Mersenne Twister 3..n

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM