comparison src/SbpOperators/stencil.jl @ 1457:18cb103e499c bugfix/sbp_operators/stencil_return_type

Try to inline sum
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 26 Nov 2023 22:43:03 +0100
parents 4f79ab676ebc
children c8cca833862d
comparison
equal deleted inserted replaced
1452:4f79ab676ebc 1457:18cb103e499c
67 end 67 end
68 return s.weights[1 + i - s.range[1]] 68 return s.weights[1 + i - s.range[1]]
69 end 69 end
70 70
71 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int) 71 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int)
72 return sum(1:length(s)) do k 72 return @inline sum(1:length(s)) do k
73 s.weights[k]*v[i + s.range[k]] 73 s.weights[k]*v[i + s.range[k]]
74 end 74 end
75 end 75 end
76 76
77 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int) 77 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int)
78 return sum(length(s):-1:1) do k 78 return @inline sum(length(s):-1:1) do k
79 s.weights[k]*v[i - s.range[k]] 79 s.weights[k]*v[i - s.range[k]]
80 end 80 end
81 end 81 end
82 82
83 function left_pad(s::Stencil, N) 83 function left_pad(s::Stencil, N)