@@ -73,7 +73,7 @@ function stoch_ym2y(model::SimModel, i_ym, Asm, Bsm, Csm, Dsm)
7373end
7474
7575@doc raw """
76- init_estimstoch(model::SimModel, i_ym, nint_ym::Vector{Int})
76+ init_estimstoch(i_ym, nint_ym::Vector{Int})
7777
7878Calc stochastic model matrices from output integrators specifications for state estimation.
7979
@@ -150,10 +150,10 @@ end
150150@doc raw """
151151 f̂(estim::StateEstimator, x̂, u, d)
152152
153- Update the augmented model state for estimation .
153+ State function `` \m athbf{f̂}`` of the augmented model .
154154
155- By introducing an augmented state vector ``\m athbf{x}`` like in [`augment_model`](@ref) doc,
156- the `` \m athbf{f̂}`` method updates it from the augmented model, defined as :
155+ By introducing an augmented state vector ``\m athbf{x}`` like in [`augment_model`](@ref), the
156+ function returns the next state of the augmented model, defined as:
157157```math
158158\b egin{aligned}
159159 \m athbf{x}(k+1) &= \m athbf{f̂}\B ig(\m athbf{x}(k), \m athbf{u}(k), \m athbf{d}(k)\B ig) \\
@@ -162,8 +162,9 @@ the ``\mathbf{f̂}`` method updates it from the augmented model, defined as :
162162```
163163"""
164164function f̂ (estim:: E , x̂, u, d) where {E<: StateEstimator }
165- # TODO : consider using views : https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-views
166- return [estim. model. f (x̂[1 : estim. model. nx], u, d); estim. As* x̂[estim. model. nx+ 1 : end ]]
165+ # `@views` macro avoid copies with matrix slice operator e.g. [a:b]
166+ nx = estim. model. nx
167+ @views return [estim. model. f (x̂[1 : nx], u, d); estim. As* x̂[nx+ 1 : end ]]
167168end
168169
169170@doc raw """
172173Output function ``\m athbf{ĥ}`` of the augmented model, see [`f̂`](@ref) for details.
173174"""
174175function ĥ (estim:: E , x̂, d) where {E<: StateEstimator }
175- return estim. model. h (x̂[1 : estim. model. nx], d) + estim. Cs* x̂[estim. model. nx+ 1 : end ]
176+ # `@views` macro avoid copies with matrix slice operator e.g. [a:b]
177+ nx = estim. model. nx
178+ @views return estim. model. h (x̂[1 : nx], d) + estim. Cs* x̂[nx+ 1 : end ]
176179end
177180
178181
0 commit comments