tesseract  4.00.00dev
tesseract::TRand Class Reference

#include <helpers.h>

Public Member Functions

 TRand ()
 
void set_seed (uinT64 seed)
 
void set_seed (const std::string &str)
 
inT32 IntRand ()
 
double SignedRand (double range)
 
double UnsignedRand (double range)
 

Detailed Description

Definition at line 41 of file helpers.h.

Constructor & Destructor Documentation

◆ TRand()

tesseract::TRand::TRand ( )
inline

Definition at line 43 of file helpers.h.

43 : seed_(1) {}

Member Function Documentation

◆ IntRand()

inT32 tesseract::TRand::IntRand ( )
inline

Definition at line 55 of file helpers.h.

55  {
56  Iterate();
57  return seed_ >> 33;
58  }

◆ set_seed() [1/2]

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

Definition at line 45 of file helpers.h.

45  {
46  seed_ = seed;
47  }

◆ set_seed() [2/2]

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

Definition at line 49 of file helpers.h.

49  {
50  std::hash<std::string> hasher;
51  set_seed(static_cast<uinT64>(hasher(str)));
52  }
void set_seed(uinT64 seed)
Definition: helpers.h:45

◆ SignedRand()

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

Definition at line 60 of file helpers.h.

60  {
61  return range * 2.0 * IntRand() / MAX_INT32 - range;
62  }
inT32 IntRand()
Definition: helpers.h:55
#define MAX_INT32
Definition: host.h:62

◆ UnsignedRand()

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

Definition at line 64 of file helpers.h.

64  {
65  return range * IntRand() / MAX_INT32;
66  }
inT32 IntRand()
Definition: helpers.h:55
#define MAX_INT32
Definition: host.h:62

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