From a3b5d4018999020a5562bc4a4a79075964b60be8 Mon Sep 17 00:00:00 2001 From: Lukas Krenz Date: Thu, 30 Nov 2023 15:04:39 +0100 Subject: [PATCH 1/2] Add isInRange to CSC matrix format --- include/yateto/TensorView.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/yateto/TensorView.h b/include/yateto/TensorView.h index 8df13b1..15740af 100644 --- a/include/yateto/TensorView.h +++ b/include/yateto/TensorView.h @@ -326,6 +326,20 @@ namespace yateto { return m_values[addr]; } + bool isInRange(uint_t row, uint_t col) { + assert(col >= 0 && col < this->shape(1)); + uint_t addr = m_colPtr[ col ]; + uint_t stop = m_colPtr[ col+1 ]; + while (addr < stop) { + if (m_rowInd[addr] == row) { + return true; + } + ++addr; + } + + return false; + } + real_t& operator[](uint_t entry[2]) { return operator()(entry[0], entry[1]); } From 631bab56963da54bdcceb3121dcdf9de5681eaf1 Mon Sep 17 00:00:00 2001 From: Lukas Krenz Date: Thu, 30 Nov 2023 15:44:04 +0100 Subject: [PATCH 2/2] Make function const --- include/yateto/TensorView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yateto/TensorView.h b/include/yateto/TensorView.h index 15740af..9e152f2 100644 --- a/include/yateto/TensorView.h +++ b/include/yateto/TensorView.h @@ -326,7 +326,7 @@ namespace yateto { return m_values[addr]; } - bool isInRange(uint_t row, uint_t col) { + bool isInRange(uint_t row, uint_t col) const { assert(col >= 0 && col < this->shape(1)); uint_t addr = m_colPtr[ col ]; uint_t stop = m_colPtr[ col+1 ];