4 #ifndef CPPQEDCORE_UTILS_RANDOMIZED_H_INCLUDED
5 #define CPPQEDCORE_UTILS_RANDOMIZED_H_INCLUDED
7 #include "RandomizedFwd.h"
13 #include "core_config.h"
15 #include <boost/range/algorithm/generate.hpp>
17 #include <boost/bind.hpp>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/utility.hpp>
21 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
22 #include <boost/serialization/string.hpp>
23 #include <boost/serialization/split_member.hpp>
24 #endif // DO_NOT_USE_BOOST_SERIALIZATION
46 typedef boost::shared_ptr<Randomized> Ptr;
55 virtual double doSample() = 0;
57 #ifndef DO_NOT_USE_BOOST_SERIALIZATION
59 friend class boost::serialization::access;
61 template<
class Archive>
62 void save(Archive& ar,
const unsigned int )
const
64 const std::string state(getState()), id(getImplID());
68 template<
class Archive>
69 void load(Archive& ar,
const unsigned int )
71 std::string state, id;
73 if (
id!=getImplID())
throw RNGStateParsingException(
"Wrong implementation ID, expected "+
id+
", found "+getImplID());
77 BOOST_SERIALIZATION_SPLIT_MEMBER()
79 #endif // DO_NOT_USE_BOOST_SERIALIZATION
81 virtual const std::string getState()
const = 0;
82 virtual void setState(
const std::string&) = 0;
84 virtual const std::string getImplID()
const = 0;
97 const double sample<double>(Randomized::Ptr ran)
99 return ran->operator()();
105 const dcomp sample<dcomp >(Randomized::Ptr ran)
107 return ran->dcompRan();
115 virtual const Randomized::Ptr operator()(
unsigned long seed)
const = 0;
126 const Randomized::Ptr operator()(
unsigned long seed)
const;
145 Randomized::Ptr ran(maker(seed));
152 #endif // CPPQEDCORE_UTILS_RANDOMIZED_H_INCLUDED
boost::shared_ptr< const Base > Ptr
Convenience typedef.
template metafunction returning (by convention, as a member typedef type) the type of elements of the...
Class reporting also the “what-ness” of the exception.
const dcomp dcompRan()
sampling of a uniform distribution over unit square on the complex plane
Declarations of traits functions for adapting array types to generic functions.
const Randomized::Ptr fillWithRandom(A &data, Randomized::Ptr ran)
Fills an array with random data taking a Randomized as parameter.
Factory class for Randomized types.
Additional helpers for dcomp.
std::complex< double > dcomp
Double-precision complex number.
A common interface for random-number generators.
Defines tentative base classes for the exception classes of the framework.
double operator()()
sampling of uniform distribution over the interval [0:1)
Implements Maker by returning a class implementing the Randomized interface by GSL ...