From 761ac7f2da2fd5fd96c5eac8199f55150b0d6350 Mon Sep 17 00:00:00 2001 From: Jacob Gilbert <mrjacobagilbert@gmail.com> Date: Wed, 7 Feb 2018 18:44:43 -0800 Subject: pmt: fix for error in pmt::equal() when comparing uniform vectors --- gnuradio-runtime/lib/pmt/pmt.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnuradio-runtime/lib') diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc index 3b92481549..6c37fa9fd2 100644 --- a/gnuradio-runtime/lib/pmt/pmt.cc +++ b/gnuradio-runtime/lib/pmt/pmt.cc @@ -1163,7 +1163,7 @@ equal(const pmt_t& x, const pmt_t& y) len_x) == 0) return true; - return true; + return false; } // FIXME add other cases here... -- cgit v1.2.3 From bdc28a843125a8cab4638c0f19ea136845ff9c74 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Thu, 8 Feb 2018 11:53:17 +0100 Subject: pmt: extract lengths before memcmp #1598 --- gnuradio-runtime/lib/pmt/pmt.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnuradio-runtime/lib') diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc index 6c37fa9fd2..0fe4dbde8e 100644 --- a/gnuradio-runtime/lib/pmt/pmt.cc +++ b/gnuradio-runtime/lib/pmt/pmt.cc @@ -1158,9 +1158,9 @@ equal(const pmt_t& x, const pmt_t& y) return false; size_t len_x, len_y; - if (memcmp(xv->uniform_elements(len_x), - yv->uniform_elements(len_y), - len_x) == 0) + const void *x_m = xv->uniform_elements(len_x); + const void *y_m = yv->uniform_elements(len_y); + if (memcmp(x_m, y_m, len_x) == 0) return true; return false; -- cgit v1.2.3 From 5f455396abe7da2ec96300c7b1ee31748f138752 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Mon, 19 Mar 2018 23:19:02 +0100 Subject: analog: remove std::time(0) seed from gr::random if 0 is selected Instead the default seed implemented in boost::random is used by calling seed() without arguments --- gnuradio-runtime/lib/math/random.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gnuradio-runtime/lib') diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc index 401ba89735..af90a33429 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 -- cgit v1.2.3 From 26ca54a29ad74ca3612db7433a855f4fd41f7d61 Mon Sep 17 00:00:00 2001 From: Andrej Rode <mail@andrejro.de> Date: Mon, 19 Mar 2018 23:33:03 +0100 Subject: analog: improve readability of laplacian distribution --- gnuradio-runtime/lib/math/random.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gnuradio-runtime/lib') diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc index af90a33429..cedaf4b97f 100644 --- a/gnuradio-runtime/lib/math/random.cc +++ b/gnuradio-runtime/lib/math/random.cc @@ -141,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 -- cgit v1.2.3