Ignore:
Timestamp:
Jul 29, 2012, 12:13:39 PM (11 years ago)
Author:
Peter
Message:

adding documentation and tests. Remove private member count_ (not needed). closes #568

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/random/random.cc

    r2800 r2802  
    4343      throw utility::GSL_error("RNG::RNG unknown generator");
    4444    seed_ = gsl_rng_default_seed;
    45     count_ = 0;
     45    // let's allocate already here, just to behave as yat 0.8
     46    rng_alloc();
    4647  }
    4748
     
    9293    if (!rng)
    9394      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_;
    10298    // rng_ owns rng and takes care of deallocation
    10399    rng_.reset(rng);
     
    107103  void RNG::seed(unsigned long s) const
    108104  {
    109     seed_ = s;
    110     count_ = 0;
    111105    gsl_rng_set(rng(),s);
     106    seed_ = s+1;
    112107  }
    113108
Note: See TracChangeset for help on using the changeset viewer.