Mercurial > repos > public > sbplib_julia
diff src/SbpOperators/stencil.jl @ 1454:c10c6c3e9247 bugfix/sbp_operators/stencil_return_type
Fix broken test using Base.promote_op. Needs to be evaluated for performance
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 24 Nov 2023 22:58:37 +0100 |
parents | 14cb97284373 |
children | 6e9ac7925f20 |
line wrap: on
line diff
--- a/src/SbpOperators/stencil.jl Fri Nov 24 21:49:07 2023 +0100 +++ b/src/SbpOperators/stencil.jl Fri Nov 24 22:58:37 2023 +0100 @@ -69,7 +69,8 @@ end Base.@propagate_inbounds @inline function apply_stencil(s::Stencil, v::AbstractVector, i::Int) - w = zero(promote_type(eltype(s),eltype(v))) + T = Base.promote_op(*, eltype(s), eltype(v)) + w = zero(T) @simd for k ∈ 1:length(s) w += s.weights[k]*v[i + s.range[k]] end @@ -78,7 +79,8 @@ end Base.@propagate_inbounds @inline function apply_stencil_backwards(s::Stencil, v::AbstractVector, i::Int) - w = zero(promote_type(eltype(s),eltype(v))) + T = Base.promote_op(*, eltype(s), eltype(v)) + w = zero(T) @simd for k ∈ length(s):-1:1 w += s.weights[k]*v[i - s.range[k]] end