change iteration of diffx/diffy

This commit is contained in:
Magnus Ulimoen 2019-11-07 21:05:03 +01:00
parent dd38c55232
commit 56688efcdf
1 changed files with 5 additions and 6 deletions

View File

@ -119,15 +119,14 @@ fn upwind4_test() {
impl SbpOperator for Upwind4 { impl SbpOperator for Upwind4 {
fn diffx(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) { fn diffx(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
for j in 0..prev.shape()[0] { for (r0, r1) in prev.outer_iter().zip(fut.outer_iter_mut()) {
Self::diff(prev.slice(s!(j, ..)), fut.slice_mut(s!(j, ..))); Self::diff(r0, r1)
} }
} }
fn diffy(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) { fn diffy(prev: ArrayView2<f32>, fut: ArrayViewMut2<f32>) {
for i in 0..prev.shape()[1] { // diffy = transpose then use diffx
Self::diff(prev.slice(s!(.., i)), fut.slice_mut(s!(.., i))); Self::diffx(prev.reversed_axes(), fut.reversed_axes());
}
} }
fn h() -> &'static [f32] { fn h() -> &'static [f32] {