From 047ee12615b5f907a0de3ff1eda7c1c0d5a2556d Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Tue, 14 Nov 2023 10:24:19 +0000 Subject: [PATCH] make array3d column major --- tools/src/arrays.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/src/arrays.rs b/tools/src/arrays.rs index 9fdd6789..be110f6e 100644 --- a/tools/src/arrays.rs +++ b/tools/src/arrays.rs @@ -75,11 +75,11 @@ impl Array3DAccess for Array3D { } unsafe fn get_unchecked(&self, index0: usize, index1: usize, index2: usize) -> &T { self.data - .get_unchecked((index0 * self.shape.1 + index1) * self.shape.2 + index2) + .get_unchecked((index2 * self.shape.1 + index1) * self.shape.0 + index0) } unsafe fn get_unchecked_mut(&mut self, index0: usize, index1: usize, index2: usize) -> &mut T { self.data - .get_unchecked_mut((index0 * self.shape.1 + index1) * self.shape.2 + index2) + .get_unchecked_mut((index2 * self.shape.1 + index1) * self.shape.0 + index0) } fn shape(&self) -> &(usize, usize, usize) { &self.shape @@ -154,7 +154,7 @@ impl Array4DAccess for Array4D { index3: usize, ) -> &T { self.data.get_unchecked( - ((index0 * self.shape.1 + index1) * self.shape.2 + index2) * self.shape.3 + index3, + ((index3 * self.shape.2 + index2) * self.shape.1 + index1) * self.shape.0 + index0, ) } unsafe fn get_unchecked_mut( @@ -165,7 +165,7 @@ impl Array4DAccess for Array4D { index3: usize, ) -> &mut T { self.data.get_unchecked_mut( - ((index0 * self.shape.1 + index1) * self.shape.2 + index2) * self.shape.3 + index3, + ((index3 * self.shape.2 + index2) * self.shape.1 + index1) * self.shape.0 + index0, ) } fn shape(&self) -> &(usize, usize, usize, usize) {