Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Mantid::Kernel::NDRandomNumberGenerator Class Referenceabstract

This class defines an interface for N dimensional random number generators. More...

#include <NDRandomNumberGenerator.h>

Inheritance diagram for Mantid::Kernel::NDRandomNumberGenerator:
Mantid::Kernel::NDPseudoRandomNumberGenerator< SingleValueGenerator > Mantid::Kernel::PseudoRandomNumberGenerator Mantid::Kernel::QuasiRandomNumberSequence Mantid::Kernel::MersenneTwister Mantid::Kernel::SobolSequence

Public Member Functions

 NDRandomNumberGenerator ()=delete
 Disable default constructor. More...
 
 NDRandomNumberGenerator (const NDRandomNumberGenerator &)=delete
 Disable copy operator. More...
 
 NDRandomNumberGenerator (const unsigned int ndims)
 Constructor. More...
 
const std::vector< double > & nextPoint ()
 Generate the next set of values that form a point in ND space. More...
 
unsigned int numberOfDimensions () const
 Returns the number of dimensions the point will be generated in, i.e. More...
 
NDRandomNumberGeneratoroperator= (const NDRandomNumberGenerator &)=delete
 Disable assignment operator. More...
 
virtual void restart ()=0
 Restarts the generator from the beginning of the sequence. More...
 
virtual void restore ()=0
 Restores the generator to the last saved point, or the beginning if nothing has been saved. More...
 
virtual void save ()=0
 Saves the current state of the generator. More...
 
virtual ~NDRandomNumberGenerator ()=default
 Virtual destructor to ensure that all inheriting classes have one. More...
 

Protected Member Functions

void cacheGeneratedValue (const size_t index, const double value)
 Cache a value for a given dimension index, i.e. 0->ND-1. More...
 
void cacheNextPoint (const std::vector< double > &nextPoint)
 Cache the while point in one go. More...
 
virtual void generateNextPoint ()=0
 Generate the next point. Override this in you concrete implementation. More...
 
std::vector< double > & getNextPointCache ()
 Some generators need direct access to the cache. More...
 

Private Attributes

const unsigned int m_ndims
 The number of dimensions. More...
 
std::vector< double > m_nextPoint
 Storage the next point to return. More...
 

Detailed Description

This class defines an interface for N dimensional random number generators.

A call to next produces N points in an ND space

Author
Martyn Gigg, Tessella plc
Date
19/05/2012

Definition at line 24 of file NDRandomNumberGenerator.h.

Constructor & Destructor Documentation

◆ NDRandomNumberGenerator() [1/3]

Mantid::Kernel::NDRandomNumberGenerator::NDRandomNumberGenerator ( const unsigned int  ndims)

Constructor.

Construct an object.

Definition at line 17 of file NDRandomNumberGenerator.cpp.

◆ ~NDRandomNumberGenerator()

virtual Mantid::Kernel::NDRandomNumberGenerator::~NDRandomNumberGenerator ( )
virtualdefault

Virtual destructor to ensure that all inheriting classes have one.

◆ NDRandomNumberGenerator() [2/3]

Mantid::Kernel::NDRandomNumberGenerator::NDRandomNumberGenerator ( )
delete

Disable default constructor.

◆ NDRandomNumberGenerator() [3/3]

Mantid::Kernel::NDRandomNumberGenerator::NDRandomNumberGenerator ( const NDRandomNumberGenerator )
delete

Disable copy operator.

Member Function Documentation

◆ cacheGeneratedValue()

void Mantid::Kernel::NDRandomNumberGenerator::cacheGeneratedValue ( const size_t  index,
const double  value 
)
protected

Cache a value for a given dimension index, i.e. 0->ND-1.

Cache a value for a given dimension index, i.e.

0->ND-1

Parameters
index:: An index for the dimension of the value generated
value:: value to be cached

Definition at line 34 of file NDRandomNumberGenerator.cpp.

References index, m_ndims, m_nextPoint, and value.

Referenced by Mantid::Kernel::PseudoRandomNumberGenerator::generateNextPoint().

◆ cacheNextPoint()

void Mantid::Kernel::NDRandomNumberGenerator::cacheNextPoint ( const std::vector< double > &  nextPoint)
protected

Cache the while point in one go.

Cache the next point.

Should be called by the concrete implementation at the end of generateNextPoint Avoids returning the vectors by value and copying.

Parameters
nextPoint:: A vector containing the new set of points

Definition at line 45 of file NDRandomNumberGenerator.cpp.

References m_ndims, m_nextPoint, and nextPoint().

◆ generateNextPoint()

virtual void Mantid::Kernel::NDRandomNumberGenerator::generateNextPoint ( )
protectedpure virtual

Generate the next point. Override this in you concrete implementation.

Implemented in Mantid::Kernel::NDPseudoRandomNumberGenerator< SingleValueGenerator >, Mantid::Kernel::PseudoRandomNumberGenerator, and Mantid::Kernel::SobolSequence.

Referenced by nextPoint().

◆ getNextPointCache()

std::vector< double > & Mantid::Kernel::NDRandomNumberGenerator::getNextPointCache ( )
inlineprotected

Some generators need direct access to the cache.

Definition at line 64 of file NDRandomNumberGenerator.h.

Referenced by Mantid::Kernel::SobolSequence::generateNextPoint().

◆ nextPoint()

const std::vector< double > & Mantid::Kernel::NDRandomNumberGenerator::nextPoint ( )

Generate the next set of values that form a point in ND space.

Returns
A vector containing the ND random numbers

Definition at line 23 of file NDRandomNumberGenerator.cpp.

References generateNextPoint(), and m_nextPoint.

Referenced by cacheNextPoint().

◆ numberOfDimensions()

unsigned int Mantid::Kernel::NDRandomNumberGenerator::numberOfDimensions ( ) const
inline

Returns the number of dimensions the point will be generated in, i.e.

the size of the vector returned from by nextPoint()

Definition at line 43 of file NDRandomNumberGenerator.h.

◆ operator=()

NDRandomNumberGenerator & Mantid::Kernel::NDRandomNumberGenerator::operator= ( const NDRandomNumberGenerator )
delete

Disable assignment operator.

◆ restart()

virtual void Mantid::Kernel::NDRandomNumberGenerator::restart ( )
pure virtual

◆ restore()

virtual void Mantid::Kernel::NDRandomNumberGenerator::restore ( )
pure virtual

Restores the generator to the last saved point, or the beginning if nothing has been saved.

Implemented in Mantid::Kernel::MersenneTwister, Mantid::Kernel::NDPseudoRandomNumberGenerator< SingleValueGenerator >, and Mantid::Kernel::SobolSequence.

◆ save()

virtual void Mantid::Kernel::NDRandomNumberGenerator::save ( )
pure virtual

Member Data Documentation

◆ m_ndims

const unsigned int Mantid::Kernel::NDRandomNumberGenerator::m_ndims
private

The number of dimensions.

Definition at line 68 of file NDRandomNumberGenerator.h.

Referenced by cacheGeneratedValue(), and cacheNextPoint().

◆ m_nextPoint

std::vector<double> Mantid::Kernel::NDRandomNumberGenerator::m_nextPoint
private

Storage the next point to return.

Definition at line 70 of file NDRandomNumberGenerator.h.

Referenced by cacheGeneratedValue(), cacheNextPoint(), and nextPoint().


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