diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2021-03-25 18:13:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-25 13:13:35 -0400 |
commit | 4dd02dac2fcaf45f398c074735a7359330f78d77 (patch) | |
tree | b09529d96288fbdfb3ad703c3475fbb1154e2548 /gr-analog/include/gnuradio/analog/fastnoise_source.h | |
parent | 9a08594ae534c41d20e21187618de9ff3cc67336 (diff) |
analog/fastnoise: avoid modulo operation when picking indices
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>
Diffstat (limited to 'gr-analog/include/gnuradio/analog/fastnoise_source.h')
-rw-r--r-- | gr-analog/include/gnuradio/analog/fastnoise_source.h | 5 |
1 files changed, 3 insertions, 2 deletions
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; |