1 /**************************************************************************/ 2 /* Copyright 2009 Tim Day */ 3 /* */ 4 /* This file is part of Fracplanet */ 5 /* */ 6 /* Fracplanet is free software: you can redistribute it and/or modify */ 7 /* it under the terms of the GNU General Public License as published by */ 8 /* the Free Software Foundation, either version 3 of the License, or */ 9 /* (at your option) any later version. */ 10 /* */ 11 /* Fracplanet is distributed in the hope that it will be useful, */ 12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 14 /* GNU General Public License for more details. */ 15 /* */ 16 /* You should have received a copy of the GNU General Public License */ 17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */ 18 /**************************************************************************/ 19 20 /*! \file 21 \brief Interface for class Random and derived classes. 22 */ 23 24 #ifndef _random_h_ 25 #define _random_h_ 26 27 #include "common.h" 28 29 //! Generates random numbers in the range [0,1). 30 class Random01 31 { 32 public: 33 34 // Constructor. Argument is seed value. 35 Random01(uint s=0); 36 37 //! Destructor. 38 ~Random01(); 39 40 // Return random number in 0-1 (don't think we care whether open interval or not). operator()41 double operator()() 42 { 43 return _gen(); 44 } 45 46 private: 47 48 boost::mt19937 _rng; 49 50 boost::uniform_real<> _dist; 51 52 boost::variate_generator<boost::mt19937,boost::uniform_real<> > _gen; 53 }; 54 55 #endif 56 57 58 59 60 61 62