Mercurial > repos > public > sbplib_julia
comparison stencil.jl @ 78:fbf7398f8154 cell_based_test
Inline and inbounds everything
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Thu, 24 Jan 2019 14:38:14 +0100 |
parents | 7fd4e7a1cd38 |
children | b795ec7f9ca0 |
comparison
equal
deleted
inserted
replaced
70:e4fa13137d12 | 78:fbf7398f8154 |
---|---|
23 else | 23 else |
24 return eltype(s.weights)(0) | 24 return eltype(s.weights)(0) |
25 end | 25 end |
26 end | 26 end |
27 | 27 |
28 function apply(s::Stencil, v::AbstractVector, i::Int) | 28 @inline function apply(s::Stencil, v::AbstractVector, i::Int) |
29 w = zero(eltype(v)) | 29 w = zero(eltype(v)) |
30 for j ∈ s.range[1]:s.range[2] | 30 for j ∈ s.range[1]:s.range[2] |
31 w += s[j]*v[i+j] | 31 @inbounds w += s[j]*v[i+j] |
32 end | 32 end |
33 return w | 33 return w |
34 end | 34 end |