Skip to content

Commit aa2f818

Browse files
committed
reduce allocation Luenberge
1 parent a0a37f8 commit aa2f818

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/estimator/luenberger.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ Same than [`update_estimate!(::SteadyKalmanFilter)`](@ref) but using [`Luenberge
108108
function update_estimate!(estim::Luenberger, u, ym, d=empty(estim.x̂))
109109
Â, B̂u, B̂d, Ĉm, D̂dm = estim.Â, estim.B̂u, estim.B̂d, estim.Ĉm, estim.D̂dm
110110
x̂, K̂ = estim.x̂, estim.
111-
x̂[:] =*+ B̂u*u + B̂d*d +*(ym - Ĉm*- D̂dm*d)
111+
v̂, ŷm, x̂LHS = similar(ym), similar(ym), similar(x̂)
112+
# in-place operations to recuce allocations:
113+
ŷm .= mul!(v̂, Ĉm, x̂)
114+
ŷm .+= mul!(v̂, D̂dm, d)
115+
v̂ .= ym .- ŷm
116+
x̂ .= mul!(x̂LHS, Â, x̂)
117+
.+= mul!(x̂LHS, B̂u, u)
118+
.+= mul!(x̂LHS, B̂d, d)
119+
.+= mul!(x̂LHS, K̂, v̂)
112120
return nothing
113121
end

0 commit comments

Comments
 (0)