comparison src/SbpOperators/stencil.jl @ 1455:6e9ac7925f20 bugfix/sbp_operators/stencil_return_type

Make the op to be promoted more accurate
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 26 Nov 2023 21:14:44 +0100
parents c10c6c3e9247
children b411493597f3
comparison
equal deleted inserted replaced
1454:c10c6c3e9247 1455:6e9ac7925f20
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 T = Base.promote_op(*, eltype(s), eltype(v)) 72 T = Base.promote_op((a₁,v₁,a₂,v₂)->a₁*v₁ + a₂*v₂, eltype(s), eltype(v), eltype(s), eltype(v))
73 w = zero(T) 73 w = zero(T)
74 @simd for k ∈ 1:length(s) 74 @simd for k ∈ 1:length(s)
75 w += s.weights[k]*v[i + s.range[k]] 75 w += s.weights[k]*v[i + s.range[k]]
76 end 76 end
77 77