diff options
author | Marcus Müller <marcus.mueller@ettus.com> | 2018-03-30 20:50:04 +0200 |
---|---|---|
committer | Marcus Müller <marcus.mueller@ettus.com> | 2018-03-30 20:50:04 +0200 |
commit | 61c0382eb2935a6da6c81bd93c8b9c8ef2893df2 (patch) | |
tree | 5e67df4059f5522ccc62cd85f33100ee96bb7988 /gnuradio-runtime/lib/math/random.cc | |
parent | 9a6bf484394f5954483477856f6a6712331b9ee6 (diff) | |
parent | 20d463d138782fd56397f5324be6e34af156b239 (diff) |
Merge branch 'maint' through 'last_merge_to_master'
This is the last time we're merging 'maint' to 'master'. The 'maint'
branch will cease to exist shortly; we'll have a 'maint-3.7' branch.
For further information on the new development model:
http://lists.gnu.org/archive/html/discuss-gnuradio/2018-02/msg00133.html
Diffstat (limited to 'gnuradio-runtime/lib/math/random.cc')
-rw-r--r-- | gnuradio-runtime/lib/math/random.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc index 401ba89735..cedaf4b97f 100644 --- a/gnuradio-runtime/lib/math/random.cc +++ b/gnuradio-runtime/lib/math/random.cc @@ -73,9 +73,12 @@ namespace gr { void random::reseed(unsigned int seed) { - if(seed==0) d_seed = static_cast<unsigned int>(std::time(0)); - else d_seed = seed; - d_rng->seed(d_seed); + d_seed = seed; + if (d_seed == 0){ + d_rng->seed(); + } else { + d_rng->seed(d_seed); + } // reinstantiate generators. Otherwise reseed doesn't take effect. delete d_generator; d_generator = new boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > (*d_rng,*d_uniform); // create number generator in [0,1) from boost.random @@ -138,11 +141,12 @@ namespace gr { float random::laplacian() { - float z = ran1()-0.5; - if(z>0) return -logf(1-2*z); - else return logf(1+2*z); + float z = ran1(); + if (z > 0.5f){ + return -logf(2.0f * (1.0f - z) ); + } + return logf(2 * z); } - /* * Copied from The KC7WW / OH2BNS Channel Simulator * FIXME Need to check how good this is at some point |