Pseudro-Random Number Generator based on xor_shift128++ generator. More...

#include <mn_ramdom_xorshift.hpp>

+ Inheritance diagram for mn::basic_ramdom_xorshift:
+ Collaboration diagram for mn::basic_ramdom_xorshift:

Public Member Functions

 basic_ramdom_xorshift (unsigned int startSeed)
 
virtual unsigned char rand8 () override
 Get a random unsigned char number. More...
 
virtual unsigned short rand16 () override
 Get a random unsigned short number. More...
 
virtual unsigned int rand32 () override
 Get a random unsigned int number. More...
 
virtual seed_t get_seed () override
 Get the current used Seed. More...
 
virtual void set_seed (seed_t seed) override
 Set the a new seed. More...
 
- Public Member Functions inherited from mn::IPseudoRandomUtil< unsigned int >
 IPseudoRandomUtil (seed_t startSeed)
 Construct a new IPseudoRandomUtil object. More...
 
result_type operator() (bool b=true) const noexcept
 
result_type min ()
 
result_type max ()
 

Private Types

using base_type = IPseudoRandomUtil< unsigned int >
 

Private Member Functions

void init (unsigned int seed)
 

Private Attributes

unsigned long m_xorandArray [4]
 

Additional Inherited Members

- Public Types inherited from mn::IPseudoRandomUtil< unsigned int >
using seed_t = unsigned int
 
using result_type = unsigned int
 
- Protected Attributes inherited from mn::IPseudoRandomUtil< unsigned int >
seed_t m_startSeed
 

Detailed Description

Pseudro-Random Number Generator based on xor_shift128++ generator.

Note
Based on https://codingforspeed.com/using-faster-psudo-random-generator-xorshift/
Author
Amber-Sophia Schröck

Member Typedef Documentation

◆ base_type

Constructor & Destructor Documentation

◆ basic_ramdom_xorshift()

mn::basic_ramdom_xorshift::basic_ramdom_xorshift ( unsigned int  startSeed)
inline

Member Function Documentation

◆ get_seed()

virtual seed_t mn::basic_ramdom_xorshift::get_seed ( )
inlineoverridevirtual

Get the current used Seed.

Returns
The current used Seed

Reimplemented from mn::IPseudoRandomUtil< unsigned int >.

◆ init()

void mn::basic_ramdom_xorshift::init ( unsigned int  seed)
private

◆ rand16()

unsigned short mn::basic_ramdom_xorshift::rand16 ( )
overridevirtual

Get a random unsigned short number.

Returns
A random unsigned short number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ rand32()

unsigned int mn::basic_ramdom_xorshift::rand32 ( )
overridevirtual

Get a random unsigned int number.

Returns
A random unsigned int number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ rand8()

unsigned char mn::basic_ramdom_xorshift::rand8 ( )
overridevirtual

Get a random unsigned char number.

Returns
A random unsigned char number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ set_seed()

virtual void mn::basic_ramdom_xorshift::set_seed ( seed_t  seed)
inlineoverridevirtual

Set the a new seed.

Parameters
seedTde new used seed

Reimplemented from mn::IPseudoRandomUtil< unsigned int >.

Member Data Documentation

◆ m_xorandArray

unsigned long mn::basic_ramdom_xorshift::m_xorandArray[4]
private

The documentation for this class was generated from the following files: