use super::*;
use ndarray::*;
use padding::*;
pub trait StencilArray<St>: NdArray
where
St: Stencil<Elem = Self::Elem, Dim = Self::Dim>,
{
fn stencil_map<Output, Func>(&self, out: &mut Output, Func)
where
Output: NdArray<Dim = Self::Dim>,
Func: Fn(St) -> Output::Elem;
}
pub trait Stencil {
type Elem: LinalgScalar;
type Dim: Dimension;
type Padding: Padding;
}
#[derive(Clone, Copy)]
pub struct N1D1<A: LinalgScalar> {
pub l: A,
pub r: A,
pub c: A,
}
impl<A: LinalgScalar> Stencil for N1D1<A> {
type Elem = A;
type Dim = Ix1;
type Padding = P1;
}
#[derive(Clone, Copy)]
pub struct N2D1<A: LinalgScalar> {
pub l: A,
pub r: A,
pub ll: A,
pub rr: A,
pub c: A,
}
impl<A: LinalgScalar> Stencil for N2D1<A> {
type Elem = A;
type Dim = Ix1;
type Padding = P2;
}
#[derive(Clone, Copy)]
pub struct N1D2<A: LinalgScalar> {
pub t: A,
pub b: A,
pub l: A,
pub r: A,
pub c: A,
}
impl<A: LinalgScalar> Stencil for N1D2<A> {
type Elem = A;
type Dim = Ix2;
type Padding = P1;
}