Changeset 674
 Timestamp:
 Oct 10, 2006, 2:28:40 AM (16 years ago)
 Location:
 trunk/c++_tools/random
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/c++_tools/random/random.cc
r562 r674 53 53 54 54 55 55 56 56 u_long RNG::seed_from_devurandom(void) 57 57 { … … 68 68 seed(s); 69 69 return s; 70 } 71 72 73 74 int RNG::set_state(const RNG_state& state) 75 { 76 return gsl_rng_memcpy(rng_, state.rng()); 77 } 78 79 80 81 RNG_state::RNG_state(const RNG* rng) 82 { 83 rng_ = gsl_rng_clone(rng>rng()); 84 } 85 86 87 88 RNG_state::~RNG_state(void) 89 { 90 gsl_rng_free(rng_); 91 rng_=NULL; 70 92 } 71 93 
trunk/c++_tools/random/random.h
r648 r674 35 35 namespace theplu { 36 36 namespace random { 37 38 //forward declarion 39 class RNG_state; 37 40 38 41 /// … … 131 134 u_long seed_from_devurandom(void); 132 135 136 /// 137 /// @brief set the state 138 /// 139 /// @return see gsl_rng_memcpy 140 /// 141 int set_state(const RNG_state&); 142 133 143 private: 134 144 RNG(void); … … 137 147 gsl_rng* rng_; 138 148 }; 149 150 151 /// 152 /// @brief Class holding state of a random generator 153 /// 154 class RNG_state 155 { 156 public: 157 /// 158 /// @brief Constructor 159 /// 160 RNG_state(const RNG*); 161 162 /// 163 /// @brief Destructor 164 /// 165 ~RNG_state(void); 166 167 /// 168 /// @return const pointer to underlying GSL random generator. 169 /// 170 inline const gsl_rng* rng(void) const { return rng_; } 171 172 173 private: 174 gsl_rng* rng_; 175 176 }; 177 139 178 140 179 //  Discrete distribtuions 
Note: See TracChangeset
for help on using the changeset viewer.