comparison sbpD2.jl @ 5:2737156fb884

Add flip method for stencils
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 17 Dec 2018 14:17:25 +0100
parents ef878a3df87d
children 433008d3b7d3
comparison
equal deleted inserted replaced
4:ef878a3df87d 5:2737156fb884
21 end 21 end
22 new(range, weights) 22 new(range, weights)
23 end 23 end
24 end 24 end
25 25
26 function flip(s::Stencil)
27 range = (-s.range[2], -s.range[1])
28 s = Stencil(range, s.weights(end:-1:1))
29 end
30
26 # Provides index into the Stencil based on offset for the root element 31 # Provides index into the Stencil based on offset for the root element
27 function Base.getindex(s::Stencil, i::Int) 32 function Base.getindex(s::Stencil, i::Int)
28 if s.range[1] <= i <= s.range[2] 33 if s.range[1] <= i <= s.range[2]
29 return s.weights[1 + i - s.range[1]] 34 return s.weights[1 + i - s.range[1]]
30 else 35 else