Skip to content

Commit 6be3309

Browse files
committed
performance improvements
1 parent 33e838d commit 6be3309

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/common.jl

+8-10
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,21 @@ end
223223

224224
function _predictrBCM(node::GPSplitNode, x::AbstractMatrix)
225225
μ = zeros(size(x,1))
226-
t = zeros(size(x,1))
227-
β = zeros(size(x,1))
228226

229227
gp = leftGP(node)
230228
s = diag(kernelmatrix(gp.kernel, x, x)) .+ getnoise(gp)
231229

230+
C = deepcopy(1 ./ s)
231+
232232
for (k,c) in enumerate(children(node))
233233
μ_, t_ = _predictPoE(c, x)
234-
β_ = 0.5 * (log.(s) - log.(inv.(t_)))
235-
t[:] += β_.*t_
236-
μ[:] += β_ .* t_ .* μ_
237-
β[:] += β_
234+
s_ = 1 ./ t_
235+
β_ = 0.5 * (log.(s) - log.(s_))
236+
C += (β_ .* t_) - (β_ ./ s)
237+
μ += μ_ .* (β_ .* t_)
238238
end
239-
z = (1 .- β) ./ s
240-
t += z
241-
t[t .<= 0] .= 1e-8
242-
return μ ./ t, t
239+
240+
return μ ./ C, C
243241
end
244242

245243
function predict(node::GPSplitNode, x::AbstractMatrix)

0 commit comments

Comments
 (0)