Skip to content

Commit

Permalink
Merge pull request #157 from baggepinnen/copy
Browse files Browse the repository at this point in the history
copy input arrays that are mutated as state
  • Loading branch information
baggepinnen authored Nov 18, 2024
2 parents 55aa7b3 + 262f510 commit cbbf57b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LowLevelParticleFilters"
uuid = "d9d29d28-c116-5dba-9239-57a5fe23875b"
authors = ["baggepinnen <[email protected]>"]
version = "3.9.0"
version = "3.9.1"

[deps]
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
Expand Down
5 changes: 2 additions & 3 deletions src/kalman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ abstract type AbstractKalmanFilter <: AbstractFilter end

function convert_cov_type(R1, R)
if R isa SMatrix || R isa Matrix
return R
return copy(R)
elseif R1 isa SMatrix && size(R) == size(R1)
return SMatrix{size(R1,1),size(R1,2)}(R)
elseif R1 isa Matrix
Expand All @@ -11,10 +11,9 @@ function convert_cov_type(R1, R)
return Matrix(R)
end
end

function convert_x0_type(μ)
if μ isa Vector || μ isa SVector
return μ
return copy(μ)
else
return Vector(μ)
end
Expand Down
4 changes: 3 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ struct SimpleMvNormal{M,S}
Σ::S
end

SimpleMvNormal::AbstractMatrix) = SimpleMvNormal(@SVector(zeros(size(Σ,1))), Σ)
SimpleMvNormal::Union{SMatrix, PDMats.PDMat{<:Any, <:SMatrix}, Diagonal{<:Any, <:SVector}}) = SimpleMvNormal(@SVector(zeros(size(Σ,1))), Σ)
SimpleMvNormal::AbstractMatrix) = SimpleMvNormal(zeros(size(Σ,1)), Σ)


# We define this new function extended_logpdf and overload that for Distributions.jl in the extension
extended_logpdf(d::SimpleMvNormal, x) = mvnormal_c0(d) - PDMats.invquad(d.Σ, x .- d.μ)/2
Expand Down

0 comments on commit cbbf57b

Please sign in to comment.