mn::basic_random_lfsr Class Reference

Pseudro-Random Number Generator based on a 32-bit linear-feedback shift register.
More...

#include <mn_random_lfsr.hpp>

+ Inheritance diagram for mn::basic_random_lfsr:
+ Collaboration diagram for mn::basic_random_lfsr:

Public Member Functions

 basic_random_lfsr (unsigned int startSeed=0xFEABDC72, unsigned int polyMask=0xA1B3C6DF)
 
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...
 
unsigned int get_polymask ()
 Get the polymask. More...
 
void set_polymask (unsigned int mask)
 Set the a new polymask. More...
 
void set_seed (unsigned int seed, unsigned int mask)
 Set a new seed, with new polymask. More...
 
- Public Member Functions inherited from mn::IPseudoRandomUtil< unsigned int >
 IPseudoRandomUtil (seed_t startSeed)
 Construct a new IPseudoRandomUtil object. More...
 
virtual seed_t get_seed ()
 Get the current used Seed. More...
 
virtual void set_seed (seed_t seed)
 Set the a new seed. More...
 
result_type operator() (bool b=true) const noexcept
 
result_type min ()
 
result_type max ()
 

Private Attributes

unsigned int m_uiPolyMask
 

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 a 32-bit linear-feedback shift register.

Note
For reference, the implementation is based on the Maxim IC application note "AN4000" http://www.maximintegrated.com/app-notes/index.mvp/id/4400
Author
Amber-Sophia Schröck

Constructor & Destructor Documentation

◆ basic_random_lfsr()

mn::basic_random_lfsr::basic_random_lfsr ( unsigned int  startSeed = 0xFEABDC72,
unsigned int  polyMask = 0xA1B3C6DF 
)
inline

Member Function Documentation

◆ get_polymask()

unsigned int mn::basic_random_lfsr::get_polymask ( )
inline

Get the polymask.

Returns
The polymask

◆ rand16()

unsigned short basic_random_lfsr::rand16 ( )
overridevirtual

Get a random unsigned short number.

Returns
A random unsigned short number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ rand32()

unsigned int basic_random_lfsr::rand32 ( )
overridevirtual

Get a random unsigned int number.

Returns
A random unsigned int number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ rand8()

unsigned char basic_random_lfsr::rand8 ( )
overridevirtual

Get a random unsigned char number.

Returns
A random unsigned char number

Implements mn::IPseudoRandomUtil< unsigned int >.

◆ set_polymask()

void mn::basic_random_lfsr::set_polymask ( unsigned int  mask)
inline

Set the a new polymask.

Parameters
maskThe new polymask

◆ set_seed()

void mn::basic_random_lfsr::set_seed ( unsigned int  seed,
unsigned int  mask 
)
inline

Set a new seed, with new polymask.

Parameters
seedThe new seed
maskThe new polymask

Member Data Documentation

◆ m_uiPolyMask

unsigned int mn::basic_random_lfsr::m_uiPolyMask
private

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