Merge pull request #1004 from MaxVerevkin/fix-750

fix linear indexing of matrix slices
This commit is contained in:
Sébastien Crozet 2021-10-31 14:24:10 +01:00 committed by GitHub
commit 20d8e953c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -567,7 +567,10 @@ where
#[doc(hidden)] #[doc(hidden)]
#[inline(always)] #[inline(always)]
unsafe fn get_unchecked(self, matrix: &'a Matrix<T, R, C, S>) -> Self::Output { unsafe fn get_unchecked(self, matrix: &'a Matrix<T, R, C, S>) -> 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)
} }
} }

View File

@ -73,7 +73,6 @@ macro_rules! slice_storage_impl(
S: $Storage<T, RStor, CStor>, S: $Storage<T, RStor, CStor>,
RStride: Dim, RStride: Dim,
CStride: Dim { CStride: Dim {
$T::from_raw_parts(storage.$get_addr(start.0, start.1), shape, strides) $T::from_raw_parts(storage.$get_addr(start.0, start.1), shape, strides)
} }
} }