From eb3d787ed637e792e4aaae6d38bed01ad86158f6 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Thu, 19 Nov 2020 12:43:29 -0800 Subject: [PATCH] Fix inner_size computation --- src/base/iter.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/base/iter.rs b/src/base/iter.rs index 501ca459..bd6e8fc2 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -133,15 +133,16 @@ macro_rules! iterator { // element we want to return. self.size -= 1; + // Compute number of rows + let inner_size = self.inner_end.offset_from(self.inner_ptr) as usize; + + // Compute rows and cols remaining + let outer_remaining = self.size / inner_size; + let inner_remaining = self.size % inner_size; + // Fetch strides let inner_stride = self.strides.0.value(); let outer_stride = self.strides.1.value(); - debug_assert_eq!(outer_stride % inner_stride, 0); - let num_rows = outer_stride / inner_stride; - - // Compute rows and cols remaining - let outer_remaining = self.size / num_rows; - let inner_remaining = self.size % num_rows; // Compute pointer to last element let last = self.ptr.offset(