remove bounds check with iterators
This commit is contained in:
parent
56688efcdf
commit
a6bf554c60
|
@ -68,10 +68,17 @@ impl Upwind4 {
|
||||||
fut[i] += diff / dx;
|
fut[i] += diff / dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 4..nx - 4 {
|
for (window, f) in prev
|
||||||
let diff = diag.dot(&prev.slice(s!(i - 3..=i + 3)));
|
.windows(diag.len())
|
||||||
fut[(i)] += diff / dx;
|
.into_iter()
|
||||||
|
.skip(1)
|
||||||
|
.zip(fut.iter_mut().skip(4))
|
||||||
|
.take(nx - 8)
|
||||||
|
{
|
||||||
|
let diff = diag.dot(&window);
|
||||||
|
*f += diff / dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_elems = prev.slice(s!(nx - 7..));
|
let last_elems = prev.slice(s!(nx - 7..));
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
let ii = nx - 4 + i;
|
let ii = nx - 4 + i;
|
||||||
|
|
Loading…
Reference in New Issue