SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Member Functions | Private Attributes | List of all members
qrtplib::RTPRandomRand48 Class Reference

#include <rtprandomrand48.h>

+ Inheritance diagram for qrtplib::RTPRandomRand48:
+ Collaboration diagram for qrtplib::RTPRandomRand48:

Public Member Functions

 RTPRandomRand48 ()
 
 RTPRandomRand48 (uint32_t seed)
 
 ~RTPRandomRand48 ()
 
uint8_t GetRandom8 ()
 
uint16_t GetRandom16 ()
 
uint32_t GetRandom32 ()
 
double GetRandomDouble ()
 
- Public Member Functions inherited from qrtplib::RTPRandom
 RTPRandom ()
 
virtual ~RTPRandom ()
 
uint32_t PickSeed ()
 

Private Member Functions

void SetSeed (uint32_t seed)
 

Private Attributes

uint64_t state
 

Additional Inherited Members

- Static Public Member Functions inherited from qrtplib::RTPRandom
static RTPRandomCreateDefaultRandomNumberGenerator ()
 

Detailed Description

A random number generator using the algorithm of the rand48 set of functions.

Definition at line 51 of file rtprandomrand48.h.

Constructor & Destructor Documentation

◆ RTPRandomRand48() [1/2]

qrtplib::RTPRandomRand48::RTPRandomRand48 ( )

Definition at line 39 of file rtprandomrand48.cpp.

References qrtplib::RTPRandom::PickSeed(), and SetSeed().

40 {
41  SetSeed(PickSeed());
42 }
void SetSeed(uint32_t seed)
uint32_t PickSeed()
Definition: rtprandom.cpp:54
+ Here is the call graph for this function:

◆ RTPRandomRand48() [2/2]

qrtplib::RTPRandomRand48::RTPRandomRand48 ( uint32_t  seed)

Definition at line 44 of file rtprandomrand48.cpp.

References SetSeed().

45 {
46  SetSeed(seed);
47 }
void SetSeed(uint32_t seed)
+ Here is the call graph for this function:

◆ ~RTPRandomRand48()

qrtplib::RTPRandomRand48::~RTPRandomRand48 ( )

Definition at line 49 of file rtprandomrand48.cpp.

50 {
51 }

Member Function Documentation

◆ GetRandom16()

uint16_t qrtplib::RTPRandomRand48::GetRandom16 ( )
virtual

Returns a random sixteen bit value.

Implements qrtplib::RTPRandom.

Definition at line 65 of file rtprandomrand48.cpp.

References GetRandom32().

66 {
67  uint32_t x = ((GetRandom32() >> 16) & 0xffff);
68 
69  return (uint16_t) x;
70 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned short uint16_t
Definition: rtptypes_win.h:44
+ Here is the call graph for this function:

◆ GetRandom32()

uint32_t qrtplib::RTPRandomRand48::GetRandom32 ( )
virtual

Returns a random thirty-two bit value.

Implements qrtplib::RTPRandom.

Definition at line 72 of file rtprandomrand48.cpp.

References state.

Referenced by GetRandom16(), and GetRandom8().

73 {
74  state = ((0x5DEECE66DULL * state) + 0xBULL) & 0x0000ffffffffffffULL;
75  uint32_t x = (uint32_t) ((state >> 16) & 0xffffffffULL);
76  qDebug("RTPRandomRand48::GetRandom32: %u", x);
77 
78  return x;
79 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
+ Here is the caller graph for this function:

◆ GetRandom8()

uint8_t qrtplib::RTPRandomRand48::GetRandom8 ( )
virtual

Returns a random eight bit value.

Implements qrtplib::RTPRandom.

Definition at line 58 of file rtprandomrand48.cpp.

References GetRandom32().

59 {
60  uint32_t x = ((GetRandom32() >> 24) & 0xff);
61 
62  return (uint8_t) x;
63 }
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned char uint8_t
Definition: rtptypes_win.h:42
+ Here is the call graph for this function:

◆ GetRandomDouble()

double qrtplib::RTPRandomRand48::GetRandomDouble ( )
virtual

Returns a random number between $0.0$ and $1.0$.

Implements qrtplib::RTPRandom.

Definition at line 81 of file rtprandomrand48.cpp.

References state.

82 {
83 
84  state = ((0x5DEECE66DULL * state) + 0xBULL) & 0x0000ffffffffffffULL;
85  int64_t x = (int64_t) state;
86 
87  double y = 3.552713678800500929355621337890625e-15 * (double) x;
88  return y;
89 }
__int64 int64_t
Definition: rtptypes_win.h:47

◆ SetSeed()

void qrtplib::RTPRandomRand48::SetSeed ( uint32_t  seed)
private

Definition at line 53 of file rtprandomrand48.cpp.

References state.

Referenced by RTPRandomRand48().

54 {
55  state = ((uint64_t) seed) << 16 | 0x330EULL;
56 }
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48
+ Here is the caller graph for this function:

Member Data Documentation

◆ state

uint64_t qrtplib::RTPRandomRand48::state
private

Definition at line 65 of file rtprandomrand48.h.

Referenced by GetRandom32(), GetRandomDouble(), and SetSeed().


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