Click here to Skip to main content
15,868,051 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
i wish to utilize the mersenne twister engine provided by C++ standard template library for each of the types it supports i.e. unsigned short, unsigned int, unsigned long long . however the template also requires setting a number of other values whose meanings i do not know and do not wish to study upon as will require considerable investment . my question is what should these template arguments be set to as a function of integral type . thank you kindly

What I have tried:

read cppreference briefly read Wikipedia article searched internet
Posted
Updated 7-Mar-23 5:35am

The documentation at std::mersenne_twister_engine - cppreference.com[^] explains what each parameter represents.
 
Share this answer
 
Comments
BernardIE5317 7-Mar-23 4:06am    
thank you for directing me to cppreference . i am afraid i am still ignorant of the meaning and use of each of the template arguments i.e. to wit to be specific namely in particular each below :

re/ n i have no idea the meaning or purpose of "degree of recurrence" or how to set it as a function of integral type
re/ m i have no idea the meaning or purpose of "middle word" or how to set it as a function of integral type
re/ r i have no idea its purpose or how to set it as a function of integral type
re/ a i have no idea its purpose or how to set it as a function of integral type
re/ u i have no idea its meaning purpose or how to set it as a function of integral type
re/ d i have no idea its meaning purpose or how to set it as a function of integral type
re/ s i have no idea its meaning purpose or how to set it as a function of integral type
re/ b i have no idea its meaning purpose or how to set it as a function of integral type
re/ t i have no idea its meaning purpose or how to set it as a function of integral type
re/ c i have no idea its meaning purpose or how to set it as a function of integral type
re/ l i have no idea its meaning purpose or how to set it as a function of integral type
re/ f i have no idea its meaning purpose or how to set it as a function of integral type

kindly advise . thank you
Richard MacCutchan 7-Mar-23 4:13am    
Sorry, this has nothing to do with programming, and I have no idea what a mersenne twister is.
Dave Kreskowiak 7-Mar-23 13:21pm    
It's a P-RNG algorithm.
Richard MacCutchan 7-Mar-23 14:18pm    
Thanks; I guess I could have read a bit more of the documentation this morning - maybe tomorrow.
Richard MacCutchan 7-Mar-23 4:19am    
In fact the documentation provides two ready made types with all those values already filled in for you, so you do not need to know them.
If I am not mistaken, the engine supports ONE type : UIntType. That is according to the documentation at mersenne_twister_engine/operator()/[^].

Here is more documentation : mt19937_64/[^].

If you need to learn what all those values do then it would be best to read the documentation.
 
Share this answer
 
Comments
CPallini 7-Mar-23 13:59pm    
UintType is a template argument, the OP is right on this.
mt19937_64 and mt19937 are convenient instantiations, see
https://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900