queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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:
QUESO::RngBoost QUESO::RngCXX11 QUESO::RngGsl

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 29 of file RngBase.C.

References privateResetSeed().

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

Virtual destructor.

Definition at line 37 of file RngBase.C.

38 {
39 }
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::RngCXX11, QUESO::RngGsl, and QUESO::RngBoost.

Referenced by QUESO::GslVector::cwSetBeta(), and QUESO::TeuchosVector::cwSetBeta().

virtual double QUESO::RngBase::gammaSample ( double  a,
double  b 
) const
pure virtual
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::RngCXX11, QUESO::RngGsl, and QUESO::RngBoost.

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

void QUESO::RngBase::privateResetSeed ( )
private

Reset seed.

Definition at line 56 of file RngBase.C.

References m_seed, and m_worldRank.

Referenced by resetSeed(), and RngBase().

57 {
58  if (m_seed >= 0) {
59  // Do nothing
60  }
61  else if (m_seed < 0) {
63  }
64  //else {
65  // struct timeval timevalNow;
66  // /*iRC = */gettimeofday(&timevalNow, NULL);
67  // m_seed = (int) timevalNow.tv_usec;
68  //}
69 
70  return;
71 }
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, QUESO::RngCXX11, and QUESO::RngBoost.

Definition at line 48 of file RngBase.C.

References m_seed, and privateResetSeed().

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

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

Sets the seed.

Definition at line 42 of file RngBase.C.

References m_seed.

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

Member Data Documentation

int QUESO::RngBase::m_seed
protected
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 Tue Jun 5 2018 19:49:11 for queso-0.57.1 by  doxygen 1.8.5