Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/stencil.jl @ 1459:c8cca833862d bugfix/sbp_operators/stencil_return_type
Try to sum over more static objects
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 27 Nov 2023 08:53:44 +0100 |
parents | 18cb103e499c |
children | 20da24e7bc36 |
comparison
equal
deleted
inserted
replaced
1457:18cb103e499c | 1459:c8cca833862d |
---|---|
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 return @inline sum(1:length(s)) do k | 72 return @inline sum(enumerate(s.weights)) do (k,w) |
73 s.weights[k]*v[i + s.range[k]] | 73 w*v[i + @inbounds s.range[k]] |
74 end | 74 end |
75 end | 75 end |
76 | 76 |
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 @inline sum(length(s):-1:1) do k | 78 return @inline sum(enumerate(s.weights)) do (k,w) |
79 s.weights[k]*v[i - s.range[k]] | 79 w*v[i - @inbounds s.range[k]] |
80 end | 80 end |
81 end | 81 end |
82 | 82 |
83 function left_pad(s::Stencil, N) | 83 function left_pad(s::Stencil, N) |
84 weights = LazyTensors.left_pad_tuple(s.weights, zero(eltype(s)), N) | 84 weights = LazyTensors.left_pad_tuple(s.weights, zero(eltype(s)), N) |