Changeset 2802 for trunk/yat/random/random.cc
- Timestamp:
- Jul 29, 2012, 12:13:39 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/random/random.cc
r2800 r2802 43 43 throw utility::GSL_error("RNG::RNG unknown generator"); 44 44 seed_ = gsl_rng_default_seed; 45 count_ = 0; 45 // let's allocate already here, just to behave as yat 0.8 46 rng_alloc(); 46 47 } 47 48 … … 92 93 if (!rng) 93 94 throw utility::GSL_error("RNG failed to allocate memory"); 94 ++count_; 95 // we init/seed subsequent generators with seed_+count_ to achieve two 96 // things: 1) seed_ imlies that changing seed_ via seed(1), 97 // seed_from_devurandom(), or environment will effect all 98 // generators allocated subsequently. 2) Adding count_ implies 99 // different generators are different. 100 if (count_>1) 101 gsl_rng_set(rng, seed_+count_); 95 gsl_rng_set(rng, seed_); 96 // bump seed to avoid subsequent gsl_rng to be identical 97 ++seed_; 102 98 // rng_ owns rng and takes care of deallocation 103 99 rng_.reset(rng); … … 107 103 void RNG::seed(unsigned long s) const 108 104 { 109 seed_ = s;110 count_ = 0;111 105 gsl_rng_set(rng(),s); 106 seed_ = s+1; 112 107 } 113 108
Note: See TracChangeset
for help on using the changeset viewer.