/home/marcle/src/R/microsimulation/src/rngstream-boost.hpp
Go to the documentation of this file.
/* boost random/rngstream-boost.hpp header file
*
* Copyright Mark Clements 2014
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
*
* Revision history
*/
/***********************************************************************\
*
* File: RngStream.cpp for multiple streams of Random Numbers
* Language: C++ (ISO 1998)
* Copyright: Pierre L'Ecuyer, University of Montreal
* Notice: This code can be used freely for personal, academic,
* or non-commercial purposes. For commercial purposes,
* please contact P. L'Ecuyer at: lecuyer@iro.umontreal.ca
* Date: 14 August 2001
*
\***********************************************************************/
#ifndef BOOST_RANDOM_RNGSTREAM_BOOST_HPP
#define BOOST_RANDOM_RNGSTREAM_BOOST_HPP
#include <iostream>
#include <stdexcept>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/integer/static_log2.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/const_mod.hpp>
#include <boost/random/detail/seed.hpp>
//#include <boost/random/detail/seed_impl.hpp>
#include <boost/detail/workaround.hpp>
#include <string>
#include <cstdlib>
#include <boost/random/detail/disable_warnings.hpp>
#include <RngStream.h>
#include <RngStream.cpp>
namespace boost {
namespace random {
using ssim::RngStream;
class rngstream : public RngStream
{
public:
typedef double result_type;
//BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
static double min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0.0; }
static double max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ return 1.0; } // or 2^24?
rngstream() : RngStream("") { }
// compiler-generated copy ctor and assignment operator are fine
void seed() {
unsigned long seed[6];
for (int i = 0; i<6; i++)
seed[i] = 12345ul;
SetSeed(seed);
}
double operator()() { return RandU01(); }
template<class Iter>
void generate(Iter first, Iter last)
{
for(; first != last; ++first) {
*first = (*this)();
}
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT,class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const rngstream& r)
{
unsigned long seed[6];
r.GetState (seed);
for (int i = 0; i<5; i++)
os << seed[i] << ' ';
os << seed[5];
return os;
}
template<class CharT,class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, rngstream& r)
{
unsigned long seed[6];
for (int i = 0; i<6; i++)
is >> seed[i];
r.SetSeed(seed);
return is;
}
#endif
friend bool operator==(const rngstream& x, const rngstream& y)
{
unsigned long seedx[6], seedy[6];
x.GetState (seedx);
y.GetState (seedy);
for (int i = 0; i<6; i++)
if (seedx[i] != seedy[i])
return false;
return true;
}
friend bool operator!=(const rngstream& x, const rngstream& y)
{ return !(x == y); }
};
} // namespace random
using random::rngstream;
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
#endif // BOOST_RANDOM_RNGSTREAM_BOOST_HPP
boost
Definition: rngstream-boost.hpp:52
RngStream.cpp
boost::random::rngstream::result_type
double result_type
Definition: rngstream-boost.hpp:60
RngStream.h
boost::random::rngstream
Definition: rngstream-boost.hpp:57
ssim::RngStream::SetSeed
bool SetSeed(const double seed[6])
Definition: RngStream.cpp:402
boost::random::rngstream::generate
void generate(Iter first, Iter last)
Definition: rngstream-boost.hpp:91
boost::random::rngstream::operator()
double operator()()
Definition: rngstream-boost.hpp:87
boost::random::rngstream::rngstream
rngstream()
Definition: rngstream-boost.hpp:74
boost::random::rngstream::BOOST_PREVENT_MACRO_SUBSTITUTION
static double min BOOST_PREVENT_MACRO_SUBSTITUTION()
Definition: rngstream-boost.hpp:66
boost::random::rngstream::operator!=
friend bool operator!=(const rngstream &x, const rngstream &y)
Definition: rngstream-boost.hpp:143
boost::random::rngstream::BOOST_PREVENT_MACRO_SUBSTITUTION
static double max BOOST_PREVENT_MACRO_SUBSTITUTION()
Definition: rngstream-boost.hpp:70
ssim::RngStream::GetState
void GetState(double seed[6]) const
Definition: RngStream.cpp:496
ssim::RngStream::RandU01
double RandU01()
Definition: RngStream.cpp:566
boost::random::rngstream::seed
void seed()
Definition: rngstream-boost.hpp:79
boost::random::rngstream::operator>>
friend std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, rngstream &r)
Definition: rngstream-boost.hpp:115
boost::random::rngstream::operator<<
friend std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const rngstream &r)
Definition: rngstream-boost.hpp:102
boost::random::rngstream::operator==
friend bool operator==(const rngstream &x, const rngstream &y)
Definition: rngstream-boost.hpp:129
ssim::RngStream
Definition: RngStream.h:30