From f01edbc5c4d2393f5cf6ddc87d9e8cc14bb264bb Mon Sep 17 00:00:00 2001 From: Boris Gromov <0xff.root@gmail.com> Date: Wed, 31 Jul 2024 10:04:45 +0200 Subject: [PATCH] Fix histogram indexing when accessed via operator [] (#939) --- include/etl/histogram.h | 4 ++-- test/test_histogram.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/etl/histogram.h b/include/etl/histogram.h index 15d54222a..ada532322 100644 --- a/include/etl/histogram.h +++ b/include/etl/histogram.h @@ -249,7 +249,7 @@ namespace etl //********************************* value_type operator [](key_type key) const { - return this->accumulator[key]; + return this->accumulator[key - Start_Index]; } }; @@ -373,7 +373,7 @@ namespace etl //********************************* value_type operator [](key_type key) const { - return this->accumulator[key]; + return this->accumulator[key - start_index]; } private: diff --git a/test/test_histogram.cpp b/test/test_histogram.cpp index 16c6373da..c682c723e 100644 --- a/test/test_histogram.cpp +++ b/test/test_histogram.cpp @@ -247,7 +247,7 @@ namespace for (size_t i = 0UL; i < output1.size(); ++i) { - CHECK_EQUAL(int(output1[i]), int(histogram[i])); + CHECK_EQUAL(int(output1[i]), int(histogram[i - 4])); } }