From 36da117dd3fee22fa240722efde359651b9711c7 Mon Sep 17 00:00:00 2001 From: Riley Murray Date: Sun, 29 Sep 2024 16:09:31 -0400 Subject: [PATCH] change how we resolve the fencepost problem in sample_indices_iid and sample_indices_iid_uniform (this implementation avoids unncessary increments) --- RandBLAS/util.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RandBLAS/util.hh b/RandBLAS/util.hh index 0f6f8b5..bd55736 100644 --- a/RandBLAS/util.hh +++ b/RandBLAS/util.hh @@ -469,7 +469,7 @@ state_t sample_indices_iid(int64_t n, const T* cdf, int64_t k, sint_t* samples, rv_index = 0; } } - if (rv_index < len_c) ctr.incr(1); + if (0 < rv_index) ctr.incr(1); return state_t(ctr, key); } @@ -501,7 +501,7 @@ state_t sample_indices_iid_uniform(int64_t n, int64_t k, sint_t* samples, T* rad rv_index = 0; } } - if (rv_index < len_c) ctr.incr(1); + if (0 < rv_index) ctr.incr(1); return state_t(ctr, key); }