ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 00014 #ifndef ESYS_LSMRNG_H 00015 #define ESYS_LSMRNG_H 00016 00017 #include <boost/random.hpp> 00018 00019 namespace esys 00020 { 00021 namespace lsm 00022 { 00026 template <typename TmplRng=boost::mt19937> 00027 class UniformRng 00028 { 00029 public: 00030 typedef TmplRng Rng; 00031 typedef boost::uniform_real<> UniformReal; 00032 typedef boost::variate_generator<Rng &, UniformReal> Generator; 00033 00039 UniformRng(double minRn, double maxRn); 00040 00045 double operator()(); 00046 00050 void seed(); 00051 00056 template <typename Tmpl> 00057 void seed(Tmpl &s); 00058 00064 template <typename TmplIt> 00065 void seed(TmplIt begin, TmplIt end); 00066 00067 private: 00068 Rng m_rng; 00069 UniformReal m_uniform; 00070 Generator m_generator; 00071 }; 00072 00073 typedef UniformRng<> DefaultUniformRng; 00074 00075 namespace rng 00076 { 00077 extern DefaultUniformRng s_zeroOneUniform; 00078 }; 00079 } 00080 } 00081 00082 #include "Foundation/Rng.hpp" 00083 00084 #endif