Skip to content

Commit 6ec9710

Browse files
committed
small optimization
1 parent d52d321 commit 6ec9710

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bp_core.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function f_bp(A::Vector{M2}, wᵢ::Vector{U}, ϕᵢ::Vector{Vector{F}},
4242
xₙᵢᵗ = [xₙᵢ₋ⱼᵗ[1:j_index-1]..., xⱼᵗ, xₙᵢ₋ⱼᵗ[j_index:end]...]
4343
w *= wᵢ[t](xᵢᵗ⁺¹, xₙᵢᵗ, xᵢᵗ)
4444
end
45-
Bᵗ[:, :, xᵢᵗ, xⱼᵗ, xᵢᵗ⁺¹] .+= Aᵗ .* w
45+
if !iszero(w)
46+
Bᵗ[:, :, xᵢᵗ, xⱼᵗ, xᵢᵗ⁺¹] .+= Aᵗ .* w
47+
end
4648
end
4749
end
4850
end
@@ -76,7 +78,9 @@ function f_bp_dummy_neighbor(A::Vector{<:AbstractMPEM2},
7678
if t <= T || periodic
7779
w *= wᵢ[t](xᵢᵗ⁺¹, collect(xₙᵢᵗ), xᵢᵗ)
7880
end
79-
Bᵗ[:, :, xᵢᵗ, 1, xᵢᵗ⁺¹] .+= Aᵗ .* w
81+
if !iszero(w)
82+
Bᵗ[:, :, xᵢᵗ, 1, xᵢᵗ⁺¹] .+= Aᵗ .* w
83+
end
8084
end
8185
end
8286
end

0 commit comments

Comments
 (0)