comparison src/SbpOperators/stencil.jl @ 1453:e1222fbb7c4d bugfix/sbp_operators/stencil_return_type

Fix broken test using Core.Compiler.return_type. Needs to be evaluated for performance
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 24 Nov 2023 22:42:50 +0100
parents 14cb97284373
children
comparison
equal deleted inserted replaced
1446:d744b01be520 1453:e1222fbb7c4d
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 w = zero(promote_type(eltype(s),eltype(v))) 72 T = Core.Compiler.return_type(*, Tuple{eltype(s),eltype(v)})
73 w = zero(T)
73 @simd for k ∈ 1:length(s) 74 @simd for k ∈ 1:length(s)
74 w += s.weights[k]*v[i + s.range[k]] 75 w += s.weights[k]*v[i + s.range[k]]
75 end 76 end
76 77
77 return w 78 return w
78 end 79 end
79 80
80 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int) 81 Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int)
81 w = zero(promote_type(eltype(s),eltype(v))) 82 T = Core.Compiler.return_type(*, Tuple{eltype(s),eltype(v)})
83 w = zero(T)
82 @simd for k ∈ length(s):-1:1 84 @simd for k ∈ length(s):-1:1
83 w += s.weights[k]*v[i - s.range[k]] 85 w += s.weights[k]*v[i - s.range[k]]
84 end 86 end
85 return w 87 return w
86 end 88 end