From b098129bec1abaee9e4c656ed1ac29523a4a85ac Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan@ecshi.net> Date: Wed, 2 Dec 2020 23:30:23 +0100 Subject: [PATCH] fix discrete divergence We want to use the divergence with zero boundary only in the case of dd. It actually didn't matter for chambolle, since that boundary information is never propagated through the algorithm for initialization with 0, but this way is more appropriate. --- src/common.jl | 4 ++-- src/dualtvdd.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.jl b/src/common.jl index 4d5f6eb..9d0a1a0 100644 --- a/src/common.jl +++ b/src/common.jl @@ -83,7 +83,7 @@ end i0 = ntuple(_->0, N) i1(k) = ntuple(i->Int(k==i), N) - wi = (:((isnothing(w[$(i0...)]) ? zero(T) : w[$(i0...)][$k]) - + wi = (:((isnothing(w[$(i1(k)...)]) ? zero(T) : w[$(i0...)][$k]) - (isnothing(w[$((.-i1(k))...)]) ? zero(T) : w[$((.-i1(k))...)][$k])) for k in 1:N) return quote Base.@_inline_meta @@ -101,7 +101,7 @@ end slice(k) = (ntuple(_->:, ndims(S)-1)..., k) - wi = (:((isnothing(w[$(i0...)]) ? zero($T) : w[$(i0...)][$(slice(k)...)]) - + wi = (:((isnothing(w[$(i1(k)...)]) ? zero($T) : w[$(i0...)][$(slice(k)...)]) - (isnothing(w[$((.-i1(k))...)]) ? zero($T) : w[$((.-i1(k))...)][$(slice(k)...)])) for k in 1:N) return quote Base.@_inline_meta diff --git a/src/dualtvdd.jl b/src/dualtvdd.jl index 1bb325e..b8da778 100644 --- a/src/dualtvdd.jl +++ b/src/dualtvdd.jl @@ -153,7 +153,7 @@ function step!(ctx::DualTVDDState) # data: g - Λ(p_don + p_rem) sg = copy(view(alg.problem.g, sax...)) - sp = extend(similar(ctx.p, length.(sax)), StaticKernels.ExtensionNothing()) + sp = extend(similar(ctx.p, length.(sax)), StaticKernels.ExtensionConstant(zero(eltype(ctx.p)))) if alg.parallel sp .= (1. .- theta.(Ref(ax), Ref(sax), Ref(overlap), CartesianIndices(sax))) .* view(ctx.p, sax...) else -- GitLab