comparison src/SbpOperators/stencil.jl @ 672:59a81254fefc feature/stencil_convenience

Formatting
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 07 Feb 2021 21:15:48 +0100
parents e14627e79a54
children 9fc6d38da03f
comparison
equal deleted inserted replaced
671:e14627e79a54 672:59a81254fefc
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 24
25
26 function CenteredStencil(weights::Vararg) 25 function CenteredStencil(weights::Vararg)
27 if iseven(length(weights)) 26 if iseven(length(weights))
28 throw(ArgumentError("a centered stencil must have an odd number of weights.")) 27 throw(ArgumentError("a centered stencil must have an odd number of weights."))
29 end 28 end
30 29
31 r = length(weights) ÷ 2 30 r = length(weights) ÷ 2
32 31
33 return Stencil((-r, r), weights) 32 return Stencil((-r, r), weights)
34 end 33 end
34
35 35
36 """ 36 """
37 scale(s::Stencil, a) 37 scale(s::Stencil, a)
38 38
39 Scale the weights of the stencil `s` with `a` and return a new stencil. 39 Scale the weights of the stencil `s` with `a` and return a new stencil.