changeset 1459:c8cca833862d bugfix/sbp_operators/stencil_return_type

Try to sum over more static objects
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 27 Nov 2023 08:53:44 +0100
parents 18cb103e499c
children 20da24e7bc36
files src/SbpOperators/stencil.jl
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl	Sun Nov 26 22:43:03 2023 +0100
+++ b/src/SbpOperators/stencil.jl	Mon Nov 27 08:53:44 2023 +0100
@@ -69,14 +69,14 @@
 end
 
 Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int)
-    return @inline sum(1:length(s)) do k
-        s.weights[k]*v[i + s.range[k]]
+    return @inline sum(enumerate(s.weights)) do (k,w)
+        w*v[i + @inbounds s.range[k]]
     end
 end
 
 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int)
-    return @inline sum(length(s):-1:1) do k
-        s.weights[k]*v[i - s.range[k]]
+    return @inline sum(enumerate(s.weights)) do (k,w)
+        w*v[i - @inbounds s.range[k]]
     end
 end