From 4dd02dac2fcaf45f398c074735a7359330f78d77 Mon Sep 17 00:00:00 2001 From: Marcus Müller <mmueller@gnuradio.org> Date: Thu, 25 Mar 2021 18:13:35 +0100 Subject: analog/fastnoise: avoid modulo operation when picking indices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the pool is power-of-2-sized, index generation can be done using a simple bitmask. Document this, add logging info. - use unsigned and fixed-length int where due - avoid expensive integer modulo operation when possible - extract power-of-two constexpr - don't clutter the logs for small pool sizes Signed-off-by: Marcus Müller <marcus@hostalia.de> --- gr-analog/include/gnuradio/analog/fastnoise_source.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gr-analog/include/gnuradio/analog/fastnoise_source.h') diff --git a/gr-analog/include/gnuradio/analog/fastnoise_source.h b/gr-analog/include/gnuradio/analog/fastnoise_source.h index 8edc8d972d..e03bdff08e 100644 --- a/gr-analog/include/gnuradio/analog/fastnoise_source.h +++ b/gr-analog/include/gnuradio/analog/fastnoise_source.h @@ -46,10 +46,11 @@ public: * \param seed seed for random generators. Note that for uniform * and Gaussian distributions, this should be a negative * number. - * \param samples Number of samples to pre-generate + * \param samples Number of samples to pre-generate. For performance + * reasons, prefer a power of 2. */ static sptr - make(noise_type_t type, float ampl, long seed = 0, long samples = 1024 * 16); + make(noise_type_t type, float ampl, uint64_t seed = 0, size_t samples = 1024 * 16); virtual T sample() = 0; virtual T sample_unbiased() = 0; virtual const std::vector<T>& samples() const = 0; -- cgit v1.2.3