 Timestamp:
 Nov 5, 2008, 9:08:55 PM (13 years ago)
 Location:
 trunk/yat/random
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/random/random.cc
r1487 r1614 25 25 #include "yat/utility/Exception.h" 26 26 27 #include <cassert> 27 28 #include <fstream> 28 29 #include <sstream> … … 115 116 RNG_state::RNG_state(const RNG* rng) 116 117 { 117 if (!(rng_ = gsl_rng_clone(rng>rng()))) 118 throw utility::GSL_error("RNG_state::RNG_state failed to allocate memory"); 118 clone(*rng>rng()); 119 } 120 121 122 RNG_state::RNG_state(const RNG_state& state) 123 { 124 clone(*state.rng()); 119 125 } 120 126 … … 129 135 { 130 136 return rng_; 137 } 138 139 140 void RNG_state::clone(const gsl_rng& rng) 141 { 142 assert(rng_!=&rng); 143 if (!(rng_ = gsl_rng_clone(&rng))) 144 throw utility::GSL_error("RNG_state::RNG_state failed to allocate memory"); 145 } 146 147 RNG_state& RNG_state::operator=(const RNG_state& rhs) 148 { 149 if (this != &rhs) { 150 gsl_rng_free(rng_); 151 clone(*rhs.rng()); 152 } 153 return *this; 131 154 } 132 155 
trunk/yat/random/random.h
r1487 r1614 154 154 RNG(const RNG&); 155 155 156 /** 157 There can be only one RNG so assignment is always 158 selfassignment and we do not allow it 159 */ 160 RNG& operator=(const RNG&); 161 156 162 virtual ~RNG(void); 157 163 … … 172 178 RNG_state(const RNG*); 173 179 180 /** 181 Copy Constructor 182 183 \since Explicitely declared since yat 0.5 184 */ 185 RNG_state(const RNG_state&); 186 174 187 /// 175 188 /// @brief Destructor … … 182 195 const gsl_rng* rng(void) const; 183 196 197 /** 198 Assignment operator 199 200 \since Explicitely declared since yat 0.5 201 */ 202 RNG_state& operator=(const RNG_state&); 203 184 204 private: 185 205 gsl_rng* rng_; 186 206 207 void clone(const gsl_rng&); 187 208 }; 188 209
Note: See TracChangeset
for help on using the changeset viewer.