Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/stencil.jl @ 595:03ef4d4740ab refactor/toml_operator_format
Add a constructor for Stencil where you can specify the center of the stencil
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 02 Dec 2020 17:10:18 +0100 |
parents | 4aa7fe13a984 |
children | e14627e79a54 |
comparison
equal
deleted
inserted
replaced
594:cc86b920531a | 595:03ef4d4740ab |
---|---|
4 | 4 |
5 function Stencil(range::Tuple{Int,Int},weights::NTuple{N,T}) where {T <: Real, N} | 5 function Stencil(range::Tuple{Int,Int},weights::NTuple{N,T}) where {T <: Real, N} |
6 @assert range[2]-range[1]+1 == N | 6 @assert range[2]-range[1]+1 == N |
7 new{T,N}(range,weights) | 7 new{T,N}(range,weights) |
8 end | 8 end |
9 end | |
10 | |
11 """ | |
12 Stencil(weights::NTuple; center::Int) | |
13 | |
14 Create a stencil with the given weights with element `center` as the center of the stencil. | |
15 """ | |
16 function Stencil(weights::NTuple; center::Int) | |
17 N = length(weights) | |
18 range = (1, N) .- center | |
19 | |
20 return Stencil(range, weights) | |
9 end | 21 end |
10 | 22 |
11 """ | 23 """ |
12 scale(s::Stencil, a) | 24 scale(s::Stencil, a) |
13 | 25 |