Skip to content

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelbosch committed Feb 9, 2024
1 parent 4060652 commit d1bc786
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ProbNumDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cov2psdmatrix(cov::UniformScaling; d) = PSDMatrix(sqrt(cov.λ) * Eye(d))
cov2psdmatrix(cov::Diagonal; d) =
(@assert size(cov, 1) == size(cov, 2) == d; PSDMatrix(sqrt.(cov)))
cov2psdmatrix(cov::AbstractMatrix; d) =
(@assert size(cov, 1) == size(cov, 2) == d; PSDMatrix(cholesky(cov).U))
(@assert size(cov, 1) == size(cov, 2) == d; PSDMatrix(Matrix(cholesky(cov).U)))
cov2psdmatrix(cov::PSDMatrix; d) = (@assert size(cov, 1) == size(cov, 2) == d; cov)

include("fast_linalg.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ function ekargcheck(alg; diffusionmodel, pn_observation_noise, kwargs...)
),
)
end
if (diffusionmodel isa FixedMVDiffusion || diffusionmodel isa DynamicMVDiffusion) &&
alg == EK1
if ((diffusionmodel isa FixedMVDiffusion || diffusionmodel isa DynamicMVDiffusion) &&
diffusionmodel.calibrate) && alg == EK1
throw(
ArgumentError(
"The `EK1` algorithm does not support multivariate diffusion models. Use `EK0` instead, or use a scalar diffusion model.",
"The `EK1` algorithm does not support automatic calibration of multivariate diffusion models. Either use the `EK0` instead, or use a scalar diffusion model, or set `calibrate=false` and calibrate manually by optimizing `sol.pnstats.log_likelihood`.",
),
)
end
Expand Down
10 changes: 5 additions & 5 deletions src/data_likelihoods/fenrir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function fit_pnsolution_to_data!(
C_d=view(C_d, 1:o),
K1=view(K1, :, 1:o),
K2=view(C_Dxd, :, 1:o),
m_tmp=Gaussian(view(m_tmp.μ, 1:o), PSDMatrix(view(m_tmp.Σ.R, :, 1:o))),
m_tmp=Gaussian(view(m_tmp.μ, 1:o), view(m_tmp.Σ, 1:o, 1:o)),
)

x_posterior = copy(sol.x_filt) # the object to be filled
Expand Down Expand Up @@ -136,10 +136,10 @@ function measure_and_update!(x, u, H, R::PSDMatrix, cache)
z, S = cache.m_tmp
_matmul!(z, H, x.μ)
z .-= u
fast_X_A_Xt!(S, x.Σ, H)
# _S = PSDMatrix(S.R'S.R + R.R'R.R)
_S = PSDMatrix(triangularize!([S.R; R.R], cachemat=cache.C_DxD))
msmnt = Gaussian(z, _S)
_matmul!(cache.C_Dxd, x.Σ.R, H')
_matmul!(S, cache.C_Dxd', cache.C_Dxd)
S .+= _matmul!(cache.C_dxd, R.R', R.R)
msmnt = Gaussian(z, S)

return update!(x, copy!(cache.x_tmp, x), msmnt, H; R=R, cache)
end
1 change: 0 additions & 1 deletion src/filtering/update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ function update!(
if issuccess(chol)
copy!(x_out.Σ.R, chol.U)
else
@warn "Cholesky factorization failed. Using triangularize! instead."
x_out.Σ.R .= triangularize!([x_out.Σ.R; K1_cache']; cachemat=M_cache)
end
end
Expand Down

0 comments on commit d1bc786

Please sign in to comment.