Mercurial > repos > public > sbplib_julia
diff stencil.jl @ 88:170e5447bc19 patch_based_test
Reduce allocations
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 25 Jan 2019 15:10:41 +0100 |
parents | 38733e84ef1a |
children | c0729ade65da |
line wrap: on
line diff
--- a/stencil.jl Fri Jan 25 13:40:15 2019 +0100 +++ b/stencil.jl Fri Jan 25 15:10:41 2019 +0100 @@ -31,3 +31,12 @@ end return w end + +Base.@propagate_inbounds function applybackwards(s::Stencil, v::AbstractVector, i::Int) + w = zero(eltype(v)) + for j ∈ s.range[1]:s.range[2] + @inbounds weight = s[j] + w += weight*v[i-j] + end + return w +end