From 6245ab1c9a2a6908031296a1cc9fe3bdb46a2ce2 Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 28 Nov 2020 17:11:32 -0800 Subject: [PATCH] Fix over-allocation of memory for dense U section of matrix The previous code had an off by one error leading to an extra word being allocated for each row --- src/sparse_matrix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sparse_matrix.rs b/src/sparse_matrix.rs index 7078167..c380178 100644 --- a/src/sparse_matrix.rs +++ b/src/sparse_matrix.rs @@ -262,7 +262,7 @@ impl BinaryMatrix for SparseBinaryMatrix { ); assert_eq!(self.column_index_disabled, false); self.num_dense_columns += 1; - let (last_word, last_bit) = self.bit_position(self.height, self.num_dense_columns - 1); + let (last_word, last_bit) = self.bit_position(self.height - 1, self.num_dense_columns - 1); // If this is in a new word if last_bit == 0 && last_word >= self.dense_elements.len() { // Append a new set of words