From bf48e093a906559686d5a4ca2ead33f47fa652d5 Mon Sep 17 00:00:00 2001 From: Max Verevkin Date: Wed, 6 Oct 2021 18:02:02 +0300 Subject: [PATCH] fix linear indexing of matrix slices --- src/base/indexing.rs | 5 ++++- src/base/matrix_slice.rs | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/indexing.rs b/src/base/indexing.rs index de48a67c..c2bb48ff 100644 --- a/src/base/indexing.rs +++ b/src/base/indexing.rs @@ -567,7 +567,10 @@ where #[doc(hidden)] #[inline(always)] unsafe fn get_unchecked(self, matrix: &'a Matrix) -> Self::Output { - matrix.data.get_unchecked_linear(self) + let nrows = matrix.shape().0; + let row = self % nrows; + let col = self / nrows; + matrix.data.get_unchecked(row, col) } } diff --git a/src/base/matrix_slice.rs b/src/base/matrix_slice.rs index 261d41e2..5fbd4b01 100644 --- a/src/base/matrix_slice.rs +++ b/src/base/matrix_slice.rs @@ -73,7 +73,6 @@ macro_rules! slice_storage_impl( S: $Storage, RStride: Dim, CStride: Dim { - $T::from_raw_parts(storage.$get_addr(start.0, start.1), shape, strides) } }