1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Stencil calculations
//!
//! One-dimensional case
//! --------------------
//!
//! Example to calculate the central-difference of `sin(x)` function
//! using [N1D1](struct.N1D1.html) stencil and [Torus](torus/struct.Torus.html)
//!
//! ```
//! # extern crate ndarray;
//! # extern crate stencil;
//! # use stencil::*;
//! # use ndarray::*;
//! # fn main() {
//! # let n = 128;
//! 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](struct.N1D2.html) stencil and [Torus](torus/struct.Torus.html)
//!
//! ```
//! # extern crate ndarray;
//! # extern crate stencil;
//! # use stencil::*;
//! # use ndarray::*;
//! # fn main() {
//! # let n = 128;
//! # let m = 64;
//! 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));
//! # }
//! ```

#[macro_use]
extern crate ndarray;
extern crate num_traits;

pub mod padding;
pub mod region;
pub mod torus;
mod stencil;
mod array;

pub use stencil::*;
pub use array::*;