Gromacs  2024.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions
gmx::UniformIntDistribution< IntType > Class Template Reference

#include <gromacs/random/uniformintdistribution.h>

Description

template<class IntType = int>
class gmx::UniformIntDistribution< IntType >

Uniform integer distribution.

The C++ standard library does provide this distribution, but even though they all sample from the correct distribution different standard library implementations appear to return different sequences of numbers for the same random number generator. To make it easier to use GROMACS unit tests that depend on random numbers we have our own implementation.

Template Parameters
IntTypeInteger type, int by default.

Classes

class  param_type
 Uniform int distribution parameters. More...
 

Public Types

typedef IntType result_type
 Type of values returned.
 

Public Member Functions

 UniformIntDistribution (result_type a=0, result_type b=std::numeric_limits< result_type >::max())
 Construct new distribution with given integer parameters. More...
 
 UniformIntDistribution (const param_type &param)
 Construct new distribution from parameter class. More...
 
void reset ()
 Flush all internal saved values.
 
template<class Rng >
result_type operator() (Rng &g)
 Return values from uniform int distribution with internal parameters. More...
 
template<class Rng >
result_type operator() (Rng &g, const param_type &param)
 Return value from uniform int distribution with given parameters. More...
 
result_type a () const
 Return the lower range uniform int distribution.
 
result_type b () const
 Return the upper range of the uniform int distribution.
 
param_type param () const
 Return the full parameter class of the uniform int distribution.
 
result_type min () const
 Smallest value that can be returned from uniform int distribution.
 
result_type max () const
 Largest value that can be returned from uniform int distribution.
 
bool operator== (const UniformIntDistribution &x) const
 True if two uniform int distributions will produce the same values. More...
 
bool operator!= (const UniformIntDistribution &x) const
 True if two uniform int distributions will produce different values. More...
 

Constructor & Destructor Documentation

template<class IntType = int>
gmx::UniformIntDistribution< IntType >::UniformIntDistribution ( result_type  a = 0,
result_type  b = std::numeric_limits<result_type>::max() 
)
inlineexplicit

Construct new distribution with given integer parameters.

Parameters
aLower end of range (inclusive)
bUpper end of range (inclusive)
template<class IntType = int>
gmx::UniformIntDistribution< IntType >::UniformIntDistribution ( const param_type param)
inlineexplicit

Construct new distribution from parameter class.

Parameters
paramParameter class as defined inside gmx::UniformIntDistribution.

Member Function Documentation

template<class IntType = int>
bool gmx::UniformIntDistribution< IntType >::operator!= ( const UniformIntDistribution< IntType > &  x) const
inline

True if two uniform int distributions will produce different values.

Parameters
xInstance to compare with.
template<class IntType = int>
template<class Rng >
result_type gmx::UniformIntDistribution< IntType >::operator() ( Rng &  g)
inline

Return values from uniform int distribution with internal parameters.

Template Parameters
RngUniform random engine class
Parameters
gRandom engine
template<class IntType = int>
template<class Rng >
result_type gmx::UniformIntDistribution< IntType >::operator() ( Rng &  g,
const param_type param 
)
inline

Return value from uniform int distribution with given parameters.

Template Parameters
RngUniform random engine class
Parameters
gRandom engine
paramParameters to use
template<class IntType = int>
bool gmx::UniformIntDistribution< IntType >::operator== ( const UniformIntDistribution< IntType > &  x) const
inline

True if two uniform int distributions will produce the same values.

Parameters
xInstance to compare with.

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