tesseract 5.2.0
Loading...
Searching...
No Matches
tesseract::TRand Class Reference

#include <helpers.h>

Public Member Functions

void set_seed (uint64_t seed)
 
void set_seed (const std::string &str)
 
int32_t IntRand ()
 
double SignedRand (double range)
 
double UnsignedRand (double range)
 

Detailed Description

Definition at line 59 of file helpers.h.

Member Function Documentation

◆ IntRand()

int32_t tesseract::TRand::IntRand ( )
inline

Definition at line 72 of file helpers.h.

72 {
73 return e();
74 }

◆ set_seed() [1/2]

void tesseract::TRand::set_seed ( const std::string &  str)
inline

Definition at line 66 of file helpers.h.

66 {
67 std::hash<std::string> hasher;
68 set_seed(static_cast<uint64_t>(hasher(str)));
69 }
void set_seed(uint64_t seed)
Definition: helpers.h:62

◆ set_seed() [2/2]

void tesseract::TRand::set_seed ( uint64_t  seed)
inline

Definition at line 62 of file helpers.h.

62 {
63 e.seed(seed);
64 }

◆ SignedRand()

double tesseract::TRand::SignedRand ( double  range)
inline

Definition at line 76 of file helpers.h.

76 {
77 return range * 2.0 * IntRand() / INT32_MAX - range;
78 }
int32_t IntRand()
Definition: helpers.h:72

◆ UnsignedRand()

double tesseract::TRand::UnsignedRand ( double  range)
inline

Definition at line 80 of file helpers.h.

80 {
81 return range * IntRand() / INT32_MAX;
82 }

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