Skip to content

Commit

Permalink
Bisschen code upgrade für die data likelihoods
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelbosch committed Feb 17, 2024
1 parent dd7d08d commit d74e3c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
22 changes: 10 additions & 12 deletions src/callbacks/dataupdate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ function DataUpdateCallback(

obs = Gaussian(obs_mean, obs_cov)

_cache = if o != d
if !(integ.alg isa EK1)
error("Partial observations only work with the EK1 right now")
end
make_obssized_cache(integ.cache; o)
else
integ.cache
if o != d && !(integ.alg isa EK1)
error("Partial observations only work with the EK1 right now")
end
_cache = make_obssized_cache(integ.cache; o)
@unpack K1, C_DxD, C_dxd, C_Dxd, C_d = _cache
_x = copy!(integ.cache.x_tmp, x)
_, ll = update!(x, _x, obs, H, K1, C_Dxd, C_DxD, C_dxd, C_d; R=R)
Expand All @@ -102,12 +98,14 @@ make_obscov_sqrt(PR::BlockDiag, H::BlockDiag, RR::BlockDiag) =
])

function make_obssized_cache(cache; o)
@unpack K1, C_DxD, C_dxd, C_Dxd, C_d, m_tmp, x_tmp = cache
return make_obssized_cache(K1, C_DxD, C_dxd, C_Dxd, C_d, m_tmp, x_tmp; o)
if o == cache.d
return cache
else
return make_obssized_cache(cache.covariance_factorization, cache; o)
end
end
function make_obssized_cache(
K1::M, C_DxD::M, C_dxd::M, C_Dxd::M, C_d::V, m_tmp::G, x_tmp; o,
) where {M<:Matrix,V<:Vector,G<:Gaussian}
function make_obssized_cache(::DenseCovariance, cache; o)
@unpack K1, C_DxD, C_dxd, C_Dxd, C_d, m_tmp, x_tmp = cache
return (
K1=view(K1, :, 1:o),
C_dxd=view(C_dxd, 1:o, 1:o),
Expand Down
6 changes: 1 addition & 5 deletions src/data_likelihoods/fenrir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ function fit_pnsolution_to_data!(
o = length(data.u[1])
d = cache.d
@unpack x_tmp, m_tmp = cache
_cache = if o != d
make_obssized_cache(cache; o)
else
cache
end
_cache = make_obssized_cache(cache; o)
@unpack K1, C_DxD, C_dxd, C_Dxd, C_d = _cache

x_posterior = copy(sol.x_filt) # the object to be filled
Expand Down
3 changes: 0 additions & 3 deletions src/diffusions/apply_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Apply the diffusion to the PSD transition noise covariance `Q`, return the result.
"""
apply_diffusion
apply_diffusion(
Q::PSDMatrix,
diffusion::Number,
Expand Down Expand Up @@ -31,7 +30,6 @@ end
Apply the diffusion to the PSD transition noise covariance `Q` in place and return the result.
"""
apply_diffusion!
apply_diffusion!(
Q::PSDMatrix,
diffusion::Diagonal{T,<:FillArrays.Fill},
Expand All @@ -54,7 +52,6 @@ end
Apply the diffusion to the PSD transition noise covariance `Q` and store the result in `out`.
"""
apply_diffusion!
apply_diffusion!(
out::PSDMatrix,
Q::PSDMatrix,
Expand Down

0 comments on commit d74e3c8

Please sign in to comment.