Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/stencil.jl @ 806:9fc6d38da03f refactor/sbp_operators_method_signatures
Remove type requirement for stencil weights
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 15 Sep 2021 22:09:23 +0200 |
parents | 59a81254fefc |
children | 1fc6c4daec44 |
comparison
equal
deleted
inserted
replaced
779:fd84ba4f8742 | 806:9fc6d38da03f |
---|---|
1 export CenteredStencil | 1 export CenteredStencil |
2 | 2 |
3 struct Stencil{T<:Real,N} | 3 struct Stencil{T,N} |
4 range::Tuple{Int,Int} | 4 range::Tuple{Int,Int} |
5 weights::NTuple{N,T} | 5 weights::NTuple{N,T} |
6 | 6 |
7 function Stencil(range::Tuple{Int,Int},weights::NTuple{N,T}) where {T <: Real, N} | 7 function Stencil(range::Tuple{Int,Int},weights::NTuple{N,T}) where {T, N} |
8 @assert range[2]-range[1]+1 == N | 8 @assert range[2]-range[1]+1 == N |
9 new{T,N}(range,weights) | 9 new{T,N}(range,weights) |
10 end | 10 end |
11 end | 11 end |
12 | 12 |
13 """ | 13 """ |
14 Stencil(weights::NTuple; center::Int) | 14 Stencil(weights::NTuple; center::Int) |
15 | 15 |
16 Create a stencil with the given weights with element `center` as the center of the stencil. | 16 Create a stencil with the given weights with element `center` as the center of the stencil. |
17 """ | 17 """ |
18 function Stencil(weights::Vararg{Number}; center::Int) | 18 function Stencil(weights::Vararg; center::Int) |
19 N = length(weights) | 19 N = length(weights) |
20 range = (1, N) .- center | 20 range = (1, N) .- center |
21 | 21 |
22 return Stencil(range, weights) | 22 return Stencil(range, weights) |
23 end | 23 end |