diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2019-10-05 17:38:08 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2020-01-02 18:06:50 -0800 |
commit | 1c4cdadb6522f25be5a0c84d1bbe0df51c40d78d (patch) | |
tree | 352a6b9cd2d5d391850ee0647c5b796b4a9a51c2 | |
parent | 6fb8fcd299c9522ce05f6682f4ea94b2c691835c (diff) |
channels: flat_fader random facilities use C++11 (minus boost)
-rw-r--r-- | gr-channels/lib/flat_fader_impl.cc | 19 | ||||
-rw-r--r-- | gr-channels/lib/flat_fader_impl.h | 23 |
2 files changed, 17 insertions, 25 deletions
diff --git a/gr-channels/lib/flat_fader_impl.cc b/gr-channels/lib/flat_fader_impl.cc index 13eb8ffe6c..2441788186 100644 --- a/gr-channels/lib/flat_fader_impl.cc +++ b/gr-channels/lib/flat_fader_impl.cc @@ -26,19 +26,16 @@ namespace gr { namespace channels { -flat_fader_impl::flat_fader_impl(unsigned int N, float fDTs, bool LOS, float K, int seed) - : seed_1((int)seed), +flat_fader_impl::flat_fader_impl(uint32_t N, float fDTs, bool LOS, float K, uint32_t seed) + : rng_1(seed), dist_1(-GR_M_PI, GR_M_PI), - rv_1(seed_1, dist_1), // U(-pi,pi) - - seed_2((int)seed + 1), + rng_2(seed + 1), dist_2(0, 1), - rv_2(seed_2, dist_2), // U(0,1) d_N(N), d_fDTs(fDTs), - d_theta(rv_1()), - d_theta_los(rv_1()), + d_theta(dist_1(rng_1)), + d_theta_los(dist_1(rng_1)), d_step(powf(0.00125 * fDTs, 1.1)), // max step size approximated from Table 2 d_m(0), d_K(K), @@ -55,8 +52,8 @@ flat_fader_impl::flat_fader_impl(unsigned int N, float fDTs, bool LOS, float K, { // generate initial phase values for (int i = 0; i < d_N + 1; i++) { - d_psi[i] = rv_1(); - d_phi[i] = rv_1(); + d_psi[i] = dist_1(rng_1); + d_phi[i] = dist_1(rng_1); } } @@ -109,7 +106,7 @@ gr_complex flat_fader_impl::next_sample() void flat_fader_impl::update_theta() { - d_theta += (d_step * rv_2()); + d_theta += (d_step * dist_2(rng_2)); if (d_theta > GR_M_PI) { d_theta = GR_M_PI; d_step = -d_step; diff --git a/gr-channels/lib/flat_fader_impl.h b/gr-channels/lib/flat_fader_impl.h index 1b6d957d59..44f64e397f 100644 --- a/gr-channels/lib/flat_fader_impl.h +++ b/gr-channels/lib/flat_fader_impl.h @@ -23,15 +23,12 @@ #ifndef FLAT_FADER_IMPL_H #define FLAT_FADER_IMPL_H -#include <gnuradio/io_signature.h> -#include <stdint.h> -#include <iostream> - -#include <boost/format.hpp> -#include <boost/random.hpp> - #include "sincostable.h" #include <gnuradio/fxpt.h> +#include <gnuradio/io_signature.h> + +#include <stdint.h> +#include <random> // FASTSINCOS: 0 = slow native, 1 = gr::fxpt impl, 2 = sincostable.h #define FASTSINCOS 2 @@ -43,14 +40,12 @@ class flat_fader_impl { private: // initial theta variate generator - boost::mt19937 seed_1; - boost::uniform_real<> dist_1; // U(-pi,pi) - boost::variate_generator<boost::mt19937&, boost::uniform_real<>> rv_1; + std::mt19937 rng_1; + std::uniform_real_distribution<double> dist_1; // U(-pi,pi) // random walk variate - boost::mt19937 seed_2; - boost::uniform_real<> dist_2; // U(0,1) - boost::variate_generator<boost::mt19937&, boost::uniform_real<>> rv_2; + std::mt19937 rng_2; + std::uniform_real_distribution<double> dist_2; // U(0,1) public: int d_N; // number of sinusoids @@ -74,7 +69,7 @@ public: void update_theta(); - flat_fader_impl(unsigned int N, float fDTs, bool LOS, float K, int seed); + flat_fader_impl(uint32_t N, float fDTs, bool LOS, float K, uint32_t seed); gr_complex next_sample(); void next_samples(std::vector<gr_complex>& HVec, int n_samples); |