comparison src/SbpOperators/stencil.jl @ 826:4433be383840 operator_storage_array_of_table

Add stencil constructor to change the type of the weights along with a convert method
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 21 Dec 2021 16:30:16 +0100
parents 1fc6c4daec44
children 313648b01504 11767fbb29f4
comparison
equal deleted inserted replaced
825:69700b0b1452 826:4433be383840
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
24
25 function Stencil{T}(s::Stencil) where T
26 return Stencil(s.range, T.(s.weights))
27 end
28
29 Base.convert(::Type{Stencil{T}}, stencil) where T = Stencil{T}(stencil)
24 30
25 function CenteredStencil(weights::Vararg) 31 function CenteredStencil(weights::Vararg)
26 if iseven(length(weights)) 32 if iseven(length(weights))
27 throw(ArgumentError("a centered stencil must have an odd number of weights.")) 33 throw(ArgumentError("a centered stencil must have an odd number of weights."))
28 end 34 end