2 unstable releases

Uses old Rust 2015

0.2.0 Mar 13, 2018
0.1.0 Mar 11, 2018

#94 in #ndarray

MIT license

16KB
402 lines

stencil

docs.rs CircleCI

License

MIT-License, see LICENSE file.


lib.rs:

Stencil calculations

One-dimensional case

Example to calculate the central-difference of sin(x) function using N1D1 stencil and Torus

let mut a = torus::Torus::<f64, Ix1>::zeros(n);
let mut b = a.clone();
a.coordinate_fill(|x| x.sin());
let dx = a.dx();
a.stencil_map(&mut b, |n: N1D1<f64>| (n.r - n.l) / (2.0 * dx));

Two-dimensional case

Example to calculate the central-difference of sin(x)cos(y) function using N1D2 stencil and Torus

let mut a = torus::Torus::<f64, Ix2>::zeros((n, m));
a.coordinate_fill(|(x, y)| x.sin() * y.cos());
let (dx, dy) = a.dx();
let mut ax = a.clone();
let mut ay = a.clone();
a.stencil_map(&mut ax, |n: N1D2<f64>| (n.r - n.l) / (2.0 * dx));
a.stencil_map(&mut ay, |n: N1D2<f64>| (n.t - n.b) / (2.0 * dy));

Dependencies

~2MB
~35K SLoC