Skip to content

Commit 66771f1

Browse files
committed
debug: remove final allocation in UnscentedKalmanFilter
1 parent a1d3e67 commit 66771f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/estimator/kalman.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ function correct_estimate!(estim::UnscentedKalmanFilter, y0m, d0)
689689
γ_sqrtP̂ = lmul!(γ, sqrtP̂)
690690
X̂0, Ŷ0m = estim.X̂0, estim.Ŷ0m
691691
X̂0 .= x̂0
692-
X̂0[:, 2:nx̂+1] .+= γ_sqrtP̂
693-
X̂0[:, nx̂+2:end] .-= γ_sqrtP̂
692+
X̂0[:, 2:nx̂+1] .= @views X̂0[:, 2:nx̂+1] .+ γ_sqrtP̂
693+
X̂0[:, nx̂+2:end] .= @views X̂0[:, nx̂+2:end] .- γ_sqrtP̂
694694
ŷ0 = estim.buffer.
695695
for j in axes(Ŷ0m, 2)
696696
@views ĥ!(ŷ0, estim, estim.model, X̂0[:, j], d0)
@@ -784,8 +784,8 @@ function update_estimate!(estim::UnscentedKalmanFilter, y0m, d0, u0)
784784
sqrtP̂corr = P̂corr_chol.L
785785
γ_sqrtP̂corr = lmul!(γ, sqrtP̂corr)
786786
X̂0corr .= x̂0corr
787-
X̂0corr[:, 2:nx̂+1] .+= γ_sqrtP̂corr
788-
X̂0corr[:, nx̂+2:end] .-= γ_sqrtP̂corr
787+
X̂0corr[:, 2:nx̂+1] .= @views X̂0corr[:, 2:nx̂+1] .+ γ_sqrtP̂corr
788+
X̂0corr[:, nx̂+2:end] .= @views X̂0corr[:, nx̂+2:end] .- γ_sqrtP̂corr
789789
X̂0next = X̂0corr
790790
for j in axes(X̂0next, 2)
791791
@views x̂0corr .= X̂0corr[:, j]

0 commit comments

Comments
 (0)