clippy lints

This commit is contained in:
Magnus Ulimoen 2019-11-07 20:41:49 +01:00
parent 6058eae076
commit dd38c55232
2 changed files with 13 additions and 19 deletions

View File

@ -43,19 +43,18 @@ impl System {
}
}
pub fn advance<SBP>(&self, fut: &mut System, dt: f32, work_buffers: Option<&mut WorkBuffers>)
pub fn advance<SBP>(&self, fut: &mut Self, dt: f32, work_buffers: Option<&mut WorkBuffers>)
where
SBP: SbpOperator,
{
assert_eq!(self.ex.shape(), fut.ex.shape());
let mut wb: WorkBuffers;
let (y, k) = match work_buffers {
Some(x) => (&mut x.y, &mut x.buf),
None => {
wb = WorkBuffers::new(self.ex.shape()[1], self.ex.shape()[0]);
(&mut wb.y, &mut wb.buf)
}
let (y, k) = if let Some(x) = work_buffers {
(&mut x.y, &mut x.buf)
} else {
wb = WorkBuffers::new(self.ex.shape()[1], self.ex.shape()[0]);
(&mut wb.y, &mut wb.buf)
};
for i in 0..4 {
@ -65,12 +64,7 @@ impl System {
y.2.assign(&self.ey);
match i {
0 => {}
1 => {
y.0.scaled_add(1.0 / 2.0 * dt, &k[i - 1].0);
y.1.scaled_add(1.0 / 2.0 * dt, &k[i - 1].1);
y.2.scaled_add(1.0 / 2.0 * dt, &k[i - 1].2);
}
2 => {
1 | 2 => {
y.0.scaled_add(1.0 / 2.0 * dt, &k[i - 1].0);
y.1.scaled_add(1.0 / 2.0 * dt, &k[i - 1].1);
y.2.scaled_add(1.0 / 2.0 * dt, &k[i - 1].2);

View File

@ -16,7 +16,7 @@ impl Upwind4 {
];
const BLOCK: &'static [[f32; 7]] = &[
[
-72.0 / 49.0f32,
-72.0 / 49.0_f32,
187.0 / 98.0,
-20.0 / 49.0,
-3.0 / 98.0,
@ -59,8 +59,8 @@ impl Upwind4 {
let dx = 1.0 / (nx - 1) as f32;
let diag = arr1(Upwind4::DIAG);
let block = arr2(Upwind4::BLOCK);
let diag = arr1(Self::DIAG);
let block = arr2(Self::BLOCK);
let first_elems = prev.slice(s!(..7));
for i in 0..4 {
@ -120,17 +120,17 @@ fn upwind4_test() {
impl SbpOperator for Upwind4 {
fn diffx(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
for j in 0..prev.shape()[0] {
Upwind4::diff(prev.slice(s!(j, ..)), fut.slice_mut(s!(j, ..)));
Self::diff(prev.slice(s!(j, ..)), fut.slice_mut(s!(j, ..)));
}
}
fn diffy(prev: ArrayView2<f32>, mut fut: ArrayViewMut2<f32>) {
for i in 0..prev.shape()[1] {
Upwind4::diff(prev.slice(s!(.., i)), fut.slice_mut(s!(.., i)));
Self::diff(prev.slice(s!(.., i)), fut.slice_mut(s!(.., i)));
}
}
fn h() -> &'static [f32] {
Upwind4::HBLOCK
Self::HBLOCK
}
}