Mercurial > repos > public > sbplib_julia
diff stencil.jl @ 85:8d505e9bc715 cell_based_test
Merge with default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 25 Jan 2019 15:26:47 +0100 |
parents | b795ec7f9ca0 48079bd39969 |
children | 93df72e2b135 6c6979ff17f4 66c239678a21 |
line wrap: on
line diff
--- a/stencil.jl Thu Jan 24 17:46:57 2019 +0100 +++ b/stencil.jl Fri Jan 25 15:26:47 2019 +0100 @@ -1,19 +1,11 @@ -struct Stencil{T<:Real} - range::NTuple{2,Int} - weights::Vector{T} # Should this be a tuple?? (Check type stability) - - function Stencil(range, weights) - width = range[2]-range[1]+1 - if width != length(weights) - error("The width and the number of weights must be the same") - end - new{eltype(weights)}(range, weights) - end +struct Stencil{T<:Real,N} + range::Tuple{Int,Int} + weights::NTuple{N,T} end function flip(s::Stencil) range = (-s.range[2], -s.range[1]) - s = Stencil(range, s.weights[end:-1:1]) + return Stencil(range, reverse(s.weights)) end # Provides index into the Stencil based on offset for the root element