comparison src/SbpOperators/stencil.jl @ 1546:8b9cdadb845a bugfix/sbp_operators/stencil_return_type

Add some comments
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 12 Apr 2024 12:26:30 +0200
parents 7cfa729e256d
children d8fabe814d06 dfb43fdac9fc
comparison
equal deleted inserted replaced
1544:7cfa729e256d 1546:8b9cdadb845a
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(enumerate(s.weights)) do (k,w) #TBD: Which optimizations are needed here? 78 return sum(enumerate(s.weights)) do (k,w) #TBD: Which optimizations are needed here?
79 w*v[i - @inbounds s.range[k]] 79 w*v[i - @inbounds s.range[k]]
80 end 80 end
81 end 81 end
82
83 # There are many options for the implementation of `apply_stencil` and
84 # `apply_stencil_backwards`. Some alternatives were tried on the branch
85 # bugfix/sbp_operators/stencil_return_type and can be found at the following
86 # revision:
87 #
88 # * 237b980ffb91 (baseline)
89 # * a72bab15228e (mapreduce)
90 # * ffd735354d54 (multiplication)
91 # * b5abd5191f2c (promote_op)
92 # * 8d56846185fc (return_type)
93 #
82 94
83 function left_pad(s::Stencil, N) 95 function left_pad(s::Stencil, N)
84 weights = LazyTensors.left_pad_tuple(s.weights, zero(eltype(s)), N) 96 weights = LazyTensors.left_pad_tuple(s.weights, zero(eltype(s)), N)
85 range = (first(s.range) - (N - length(s.weights))):last(s.range) 97 range = (first(s.range) - (N - length(s.weights))):last(s.range)
86 98