fpmas 1.6
Public Types | Public Member Functions | Static Public Member Functions | List of all members
fpmas::random::DistributedGenerator< Generator_t > Class Template Reference

#include <generator.h>

Inheritance diagram for fpmas::random::DistributedGenerator< Generator_t >:
Inheritance graph
[legend]
Collaboration diagram for fpmas::random::DistributedGenerator< Generator_t >:
Collaboration graph
[legend]

Public Types

typedef Generator_t::result_type result_type
 
- Public Types inherited from fpmas::api::random::Generator< Generator_t::result_type >
typedef Generator_t::result_type result_type
 

Public Member Functions

 DistributedGenerator ()
 
 DistributedGenerator (api::communication::MpiCommunicator &comm)
 
 DistributedGenerator (result_type seed)
 
 DistributedGenerator (api::communication::MpiCommunicator &comm, result_type seed)
 
result_type operator() () override
 
void seed (result_type seed) override
 
void discard (unsigned long long z) override
 
virtual Generator_t::result_type operator() ()=0
 
virtual void seed (Generator_t::result_type seed)=0
 
virtual void discard (unsigned long long z)=0
 

Static Public Member Functions

static constexpr result_type min ()
 
static constexpr result_type max ()
 

Detailed Description

template<typename Generator_t = mt19937_64>
class fpmas::random::DistributedGenerator< Generator_t >

Distributed api::random::Generator implementation.

The generator is assumed to produce pseudo-random and deterministic, that are still different on each process.

More particularly, the generator internally uses a Generator_t instance, that must satisfy UniformRandomBitGenerator, seeded differently according to the rank of the process on which the generator is used. Since MPI communications are required to do so, fpmas::init() must be called before the first use of the generator. However, it is safe to instantiate the generator before fpmas::init() is called. This allows to declare a DistributedGenerator as a static variable.

This class meets the requirements of UniformRandomBitGenerator.

Template Parameters
Generator_ttype of the local random number generator used on each process

Member Typedef Documentation

◆ result_type

template<typename Generator_t = mt19937_64>
typedef Generator_t::result_type fpmas::random::DistributedGenerator< Generator_t >::result_type

Integer type used by the generator.

Constructor & Destructor Documentation

◆ DistributedGenerator() [1/4]

template<typename Generator_t = mt19937_64>
fpmas::random::DistributedGenerator< Generator_t >::DistributedGenerator ( )
inline

Default DistributedGenerator constructor.

The DistributedGenerator is initialized with a default seed, within the fpmas::communication::WORLD communicator.

◆ DistributedGenerator() [2/4]

template<typename Generator_t = mt19937_64>
fpmas::random::DistributedGenerator< Generator_t >::DistributedGenerator ( api::communication::MpiCommunicator comm)
inline

DistributedGenerator constructor.

The DistributedGenerator is initialized with a default seed, within the specified communicator.

Parameters
commMPI communicator

◆ DistributedGenerator() [3/4]

template<typename Generator_t = mt19937_64>
fpmas::random::DistributedGenerator< Generator_t >::DistributedGenerator ( result_type  seed)
inline

DistributedGenerator constructor.

The DistributedGenerator is initialized using the provided seed, within the fpmas::communication::WORLD communicator.

Parameters
seedDistributedGenerator seed

◆ DistributedGenerator() [4/4]

template<typename Generator_t = mt19937_64>
fpmas::random::DistributedGenerator< Generator_t >::DistributedGenerator ( api::communication::MpiCommunicator comm,
result_type  seed 
)
inline

DistributedGenerator constructor.

The DistributedGenerator is initialized using the provided seed, within the specified communicator.

Parameters
seedDistributedGenerator seed
commMPI communicator

Member Function Documentation

◆ operator()()

template<typename Generator_t = mt19937_64>
result_type fpmas::random::DistributedGenerator< Generator_t >::operator() ( )
inlineoverridevirtual

Returns a randomly generated value in [min(), max()].

Returns
random integer

Implements fpmas::api::random::Generator< Generator_t::result_type >.

◆ seed()

template<typename Generator_t = mt19937_64>
void fpmas::random::DistributedGenerator< Generator_t >::seed ( result_type  seed)
inlineoverridevirtual

Seeds the random generator.

Parameters
seedseed value

Implements fpmas::api::random::Generator< Generator_t::result_type >.

◆ discard()

template<typename Generator_t = mt19937_64>
void fpmas::random::DistributedGenerator< Generator_t >::discard ( unsigned long long  z)
inlineoverridevirtual

Advances the generator internal state as if operator() was called z times.

Parameters
znumber of values to discard

Implements fpmas::api::random::Generator< Generator_t::result_type >.

◆ min()

template<typename Generator_t = mt19937_64>
static constexpr result_type fpmas::random::DistributedGenerator< Generator_t >::min ( )
inlinestaticconstexpr

Minimum value that can be generated.

Returns
min value

◆ max()

template<typename Generator_t = mt19937_64>
static constexpr result_type fpmas::random::DistributedGenerator< Generator_t >::max ( )
inlinestaticconstexpr

Maximum value that can be generated.

Returns
max value

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