Mantid
Loading...
Searching...
No Matches
NDRandomNumberGenerator.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//------------------------------------------------------------------------------
10// Includes
11//------------------------------------------------------------------------------
12#include "MantidKernel/DllConfig.h"
13#include <vector>
14
15namespace Mantid {
16namespace Kernel {
24class MANTID_KERNEL_DLL NDRandomNumberGenerator {
25public:
27 NDRandomNumberGenerator(const unsigned int ndims);
29 virtual ~NDRandomNumberGenerator() = default;
30
33
36
39
43 inline unsigned int numberOfDimensions() const { return m_ndims; }
45 const std::vector<double> &nextPoint();
46
48 virtual void restart() = 0;
50 virtual void save() = 0;
53 virtual void restore() = 0;
54
55protected:
57 virtual void generateNextPoint() = 0;
58
60 void cacheGeneratedValue(const size_t index, const double value);
62 void cacheNextPoint(const std::vector<double> &nextPoint);
64 inline std::vector<double> &getNextPointCache() { return m_nextPoint; }
65
66private:
68 const unsigned int m_ndims;
70 std::vector<double> m_nextPoint;
71};
72} // namespace Kernel
73} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
This class defines an interface for N dimensional random number generators.
virtual void restart()=0
Restarts the generator from the beginning of the sequence.
NDRandomNumberGenerator(const NDRandomNumberGenerator &)=delete
Disable copy operator.
std::vector< double > & getNextPointCache()
Some generators need direct access to the cache.
const unsigned int m_ndims
The number of dimensions.
NDRandomNumberGenerator & operator=(const NDRandomNumberGenerator &)=delete
Disable assignment operator.
virtual void save()=0
Saves the current state of the generator.
NDRandomNumberGenerator()=delete
Disable default constructor.
virtual void generateNextPoint()=0
Generate the next point. Override this in you concrete implementation.
unsigned int numberOfDimensions() const
Returns the number of dimensions the point will be generated in, i.e.
virtual ~NDRandomNumberGenerator()=default
Virtual destructor to ensure that all inheriting classes have one.
std::vector< double > m_nextPoint
Storage the next point to return.
virtual void restore()=0
Restores the generator to the last saved point, or the beginning if nothing has been saved.
Helper class which provides the Collimation Length for SANS instruments.