Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/stencil.jl @ 1063:f98893154e22 feature/nested_stencils
Fix type instability for stencil application when weights and vector didn't match
(grafted from a7f898b1ce1ea3adfe21201d3ccafdffb09c5be6)
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 14 Feb 2022 14:28:48 +0100 |
parents | a76830879c63 |
children | a3bc90c59e8e |
comparison
equal
deleted
inserted
replaced
1062:a76830879c63 | 1063:f98893154e22 |
---|---|
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(eltype(v)) | 72 w = zero(promote_type(eltype(s),eltype(v))) |
73 @simd for k ∈ 1:length(s) | 73 @simd for k ∈ 1:length(s) |
74 w += s.weights[k]*v[i + s.range[k]] | 74 w += s.weights[k]*v[i + s.range[k]] |
75 end | 75 end |
76 | 76 |
77 return w | 77 return w |