@@ -64,9 +64,33 @@ struct KalmanCovariances{
6464 R̂ = Hermitian (R̂, :L )
6565 # the following variables are only for the moving horizon estimator:
6666 invP̄, invQ̂, invR̂ = copy (P̂_0), copy (Q̂), copy (R̂)
67- inv! (invP̄)
68- inv! (invQ̂)
69- inv! (invR̂)
67+ try
68+ inv! (invP̄)
69+ catch err
70+ if err isa PosDefException
71+ error (" P̂_0 is not positive definite" )
72+ else
73+ rethrow ()
74+ end
75+ end
76+ try
77+ inv! (invQ̂)
78+ catch err
79+ if err isa PosDefException
80+ error (" Q̂ is not positive definite" )
81+ else
82+ rethrow ()
83+ end
84+ end
85+ try
86+ inv! (invR̂)
87+ catch err
88+ if err isa PosDefException
89+ error (" R̂ is not positive definite" )
90+ else
91+ rethrow ()
92+ end
93+ end
7094 invQ̂_He = repeatdiag (invQ̂, He)
7195 invR̂_He = repeatdiag (invR̂, He)
7296 invQ̂_He = Hermitian (invQ̂_He, :L )
@@ -80,7 +104,7 @@ function KalmanCovariances(
80104 model:: SimModel{NT} , i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0= nothing , He= 1
81105 ) where {NT<: Real }
82106 validate_kfcov (model, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0)
83- return KalmanCovariances {NT} (model, i_ym, nint_u, nint_ym, NT .(Q̂), NT .(R̂), P̂_0, He)
107+ return KalmanCovariances {NT} (model, i_ym, nint_u, nint_ym, NT .(Q̂), NT .(R̂), NT .( P̂_0) , He)
84108end
85109
86110"""
0 commit comments