Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/stencil.jl @ 1055:df498ce0cf52 feature/nested_stencils
Add methods for CenteredNestedStencil with tuple input
(grafted from 011d3ff65e9f9751507863ec9879c4789f8409dc)
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Jan 2022 14:03:16 +0100 |
parents | cb0a5f41be02 |
children | f74189c954d6 |
comparison
equal
deleted
inserted
replaced
1054:ce16519aa7ff | 1055:df498ce0cf52 |
---|---|
83 | 83 |
84 struct NestedStencil{T,N} | 84 struct NestedStencil{T,N} |
85 s::Stencil{Stencil{T,N},N} | 85 s::Stencil{Stencil{T,N},N} |
86 end | 86 end |
87 | 87 |
88 # Stencil input | |
88 NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center)) | 89 NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center)) |
90 CenteredNestedStencil(s::Vararg{Stencil}) = NestedStencil(CenteredStencil(s...)) | |
89 | 91 |
92 # Tuple input | |
90 function NestedStencil(weights::Vararg{Tuple}; center) | 93 function NestedStencil(weights::Vararg{Tuple}; center) |
91 inner_stencils = map(w -> Stencil(w...; center), weights) | 94 inner_stencils = map(w -> Stencil(w...; center), weights) |
92 return NestedStencil(Stencil(inner_stencils... ; center)) | 95 return NestedStencil(Stencil(inner_stencils... ; center)) |
93 end | 96 end |
94 | 97 function CenteredNestedStencil(weights::Vararg{Tuple}) |
95 CenteredNestedStencil(s...) = NestedStencil(CenteredStencil(s...)) | 98 inner_stencils = map(w->CenteredStencil(w...), weights) |
99 return CenteredNestedStencil(inner_stencils...) | |
100 end | |
96 | 101 |
97 Base.eltype(::NestedStencil{T}) where T = T | 102 Base.eltype(::NestedStencil{T}) where T = T |
98 | 103 |
99 function flip(ns::NestedStencil) | 104 function flip(ns::NestedStencil) |
100 s_flip = flip(ns.s) | 105 s_flip = flip(ns.s) |