comparison stencil.jl @ 122:6c6979ff17f4 cell_based_test

Introduce and use apply_backwards for stencils
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 12 Feb 2019 15:18:18 +0100
parents 8d505e9bc715
children 7c0b9bb7ab4d
comparison
equal deleted inserted replaced
121:3560f54e3eb3 122:6c6979ff17f4
23 @inbounds weight = s[j] 23 @inbounds weight = s[j]
24 w += weight*v[i+j] 24 w += weight*v[i+j]
25 end 25 end
26 return w 26 return w
27 end 27 end
28
29 Base.@propagate_inbounds function apply_backwards(s::Stencil, v::AbstractVector, i::Int)
30 w = zero(eltype(v))
31 for j ∈ s.range[2]:-1:s.range[1]
32 @inbounds weight = s[j]
33 w += weight*v[i-j]
34 end
35 return w
36 end