Skip to content

Commit 1f438ed

Browse files
committed
added: same improvements in KalmanCovariances
1 parent d9f1359 commit 1f438ed

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎src/estimator/construct.jl‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,15 @@ function KalmanCovariances(
141141
model::SimModel{NT}, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0=nothing, He=1
142142
) where {NT<:Real}
143143
validate_kfcov(model, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0)
144-
Q̂, R̂ = NT.(Q̂), NT.(R̂)
145-
!isnothing(P̂_0) && (P̂_0 = NT.(P̂_0))
144+
Q̂ = eltype(Q̂) == NT ? Q̂ : NT.(Q̂)
145+
R̂ = eltype(R̂) == NT ? R̂ : NT.(R̂)
146+
# Hermitian wrappers are added in the inner constructor, remove it to avoid duplicates:
147+
Q̂ = Q̂ isa Hermitian ? parent(Q̂) : Q̂
148+
R̂ = R̂ isa Hermitian ? parent(R̂) : R̂
149+
if !isnothing(P̂_0)
150+
P̂_0 = eltype(P̂_0) == NT ? P̂_0 : NT.(P̂_0)
151+
P̂_0 = P̂_0 isa Hermitian ? parent(P̂_0) : P̂_0
152+
end
146153
return KalmanCovariances{NT}(Q̂, R̂, P̂_0, He)
147154
end
148155

0 commit comments

Comments
 (0)