From 56688efcdf6a9e2810c30bd682ea687224350157 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Thu, 7 Nov 2019 21:05:03 +0100 Subject: [PATCH] change iteration of diffx/diffy --- src/operators/upwind4.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/operators/upwind4.rs b/src/operators/upwind4.rs index a93451e..bf20625 100644 --- a/src/operators/upwind4.rs +++ b/src/operators/upwind4.rs @@ -119,15 +119,14 @@ fn upwind4_test() { impl SbpOperator for Upwind4 { fn diffx(prev: ArrayView2, mut fut: ArrayViewMut2) { - for j in 0..prev.shape()[0] { - Self::diff(prev.slice(s!(j, ..)), fut.slice_mut(s!(j, ..))); + for (r0, r1) in prev.outer_iter().zip(fut.outer_iter_mut()) { + Self::diff(r0, r1) } } - fn diffy(prev: ArrayView2, mut fut: ArrayViewMut2) { - for i in 0..prev.shape()[1] { - Self::diff(prev.slice(s!(.., i)), fut.slice_mut(s!(.., i))); - } + fn diffy(prev: ArrayView2, fut: ArrayViewMut2) { + // diffy = transpose then use diffx + Self::diffx(prev.reversed_axes(), fut.reversed_axes()); } fn h() -> &'static [f32] {