queso-0.53.0
Protected Attributes | Private Member Functions | List of all members
QUESO::RngBase Class Referenceabstract

Class for random number generation (base class for either GSL or Boost RNG). More...

#include <RngBase.h>

Inheritance diagram for QUESO::RngBase:
Inheritance graph
[legend]

Public Member Functions

Constructor/Destructor methods
 RngBase (int seed, int worldRank)
 Constructor with seed. More...
 
virtual ~RngBase ()
 Virtual destructor. More...
 
Sampling methods
int seed () const
 Sets the seed. More...
 
virtual void resetSeed (int newSeed)
 Resets the seed with value newSeed. More...
 
virtual double uniformSample () const =0
 Samples a value from a uniform distribution. More...
 
virtual double gaussianSample (double stdDev) const =0
 Samples a value from a Gaussian distribution with standard deviation given by stdDev. More...
 
virtual double betaSample (double alpha, double beta) const =0
 Samples a value from a Beta distribution. More...
 
virtual double gammaSample (double a, double b) const =0
 Samples a value from a Gamma distribution. More...
 

Protected Attributes

int m_seed
 Seed. More...
 
int m_worldRank
 Rank of processor. More...
 

Private Member Functions

 RngBase ()
 Default Constructor: it should not be used. More...
 
void privateResetSeed ()
 Reset seed. More...
 

Detailed Description

Class for random number generation (base class for either GSL or Boost RNG).

This class is a “virtual” class of generic random number generator, in order to accommodate either GSL or Boost RNG.

Definition at line 45 of file RngBase.h.

Constructor & Destructor Documentation

QUESO::RngBase::RngBase ( int  seed,
int  worldRank 
)

Constructor with seed.

Definition at line 30 of file RngBase.C.

References privateResetSeed().

31  :
32  m_seed (seed),
33  m_worldRank(worldRank)
34 {
36 }
void privateResetSeed()
Reset seed.
Definition: RngBase.C:57
int seed() const
Sets the seed.
Definition: RngBase.C:43
int m_seed
Seed.
Definition: RngBase.h:82
int m_worldRank
Rank of processor.
Definition: RngBase.h:85
QUESO::RngBase::~RngBase ( )
virtual

Virtual destructor.

Definition at line 38 of file RngBase.C.

39 {
40 }
QUESO::RngBase::RngBase ( )
private

Default Constructor: it should not be used.

Member Function Documentation

virtual double QUESO::RngBase::betaSample ( double  alpha,
double  beta 
) const
pure virtual

Samples a value from a Beta distribution.

Implemented in QUESO::RngGsl, and QUESO::RngBoost.

Referenced by QUESO::GslVector::cwSetBeta().

virtual double QUESO::RngBase::gammaSample ( double  a,
double  b 
) const
pure virtual

Samples a value from a Gamma distribution.

Implemented in QUESO::RngGsl, and QUESO::RngBoost.

Referenced by QUESO::GslVector::cwSetGamma(), and QUESO::GslVector::cwSetInverseGamma().

virtual double QUESO::RngBase::gaussianSample ( double  stdDev) const
pure virtual

Samples a value from a Gaussian distribution with standard deviation given by stdDev.

Implemented in QUESO::RngGsl, and QUESO::RngBoost.

Referenced by QUESO::GslVector::cwSetGaussian(), QUESO::InfiniteDimensionalGaussian::draw(), and QUESO::MiscGammar().

void QUESO::RngBase::privateResetSeed ( )
private

Reset seed.

Definition at line 57 of file RngBase.C.

References m_seed, and m_worldRank.

Referenced by resetSeed(), and RngBase().

58 {
59  if (m_seed >= 0) {
60  // Do nothing
61  }
62  else if (m_seed < 0) {
64  }
65  //else {
66  // struct timeval timevalNow;
67  // /*iRC = */gettimeofday(&timevalNow, NULL);
68  // m_seed = (int) timevalNow.tv_usec;
69  //}
70 
71  return;
72 }
int m_seed
Seed.
Definition: RngBase.h:82
int m_worldRank
Rank of processor.
Definition: RngBase.h:85
void QUESO::RngBase::resetSeed ( int  newSeed)
virtual

Resets the seed with value newSeed.

Reimplemented in QUESO::RngGsl, and QUESO::RngBoost.

Definition at line 49 of file RngBase.C.

References m_seed, and privateResetSeed().

Referenced by QUESO::RngGsl::resetSeed(), and QUESO::BaseEnvironment::resetSeed().

50 {
51  m_seed = newSeed;
53  return;
54 }
void privateResetSeed()
Reset seed.
Definition: RngBase.C:57
int m_seed
Seed.
Definition: RngBase.h:82
int QUESO::RngBase::seed ( ) const

Sets the seed.

Definition at line 43 of file RngBase.C.

References m_seed.

Referenced by QUESO::BaseEnvironment::seed().

44 {
45  return m_seed;
46 }
int m_seed
Seed.
Definition: RngBase.h:82
virtual double QUESO::RngBase::uniformSample ( ) const
pure virtual

Samples a value from a uniform distribution.

Implemented in QUESO::RngGsl, and QUESO::RngBoost.

Referenced by QUESO::GslVector::cwSetUniform(), QUESO::MiscGammar(), and QUESO::FiniteDistribution::sample().

Member Data Documentation

int QUESO::RngBase::m_seed
protected

Seed.

Definition at line 82 of file RngBase.h.

Referenced by privateResetSeed(), resetSeed(), QUESO::RngGsl::resetSeed(), QUESO::RngGsl::RngGsl(), and seed().

int QUESO::RngBase::m_worldRank
protected

Rank of processor.

Definition at line 85 of file RngBase.h.

Referenced by privateResetSeed(), and QUESO::RngGsl::RngGsl().


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

Generated on Thu Jun 11 2015 13:52:34 for queso-0.53.0 by  doxygen 1.8.5