components_mut correctness

This commit is contained in:
Magnus Ulimoen 2019-12-14 14:51:19 +01:00
parent 066c7619f7
commit a0c5a80106
1 changed files with 6 additions and 9 deletions

View File

@ -56,17 +56,14 @@ impl Field {
pub fn components_mut( pub fn components_mut(
&mut self, &mut self,
) -> (ArrayViewMut2<f32>, ArrayViewMut2<f32>, ArrayViewMut2<f32>) { ) -> (ArrayViewMut2<f32>, ArrayViewMut2<f32>, ArrayViewMut2<f32>) {
let nx = self.nx(); let mut iter = self.0.outer_iter_mut();
let ny = self.ny();
let (ex, f) = self.0.view_mut().split_at(Axis(0), 1); let ex = iter.next().unwrap();
let (hz, ey) = f.split_at(Axis(0), 1); let hz = iter.next().unwrap();
let ey = iter.next().unwrap();
assert_eq!(iter.next(), None);
( (ex, hz, ey)
ex.into_shape((ny, nx)).unwrap(),
hz.into_shape((ny, nx)).unwrap(),
ey.into_shape((ny, nx)).unwrap(),
)
} }
} }