In my code I rely on PSDMatrices.jl to represent covariace parameters of Gaussian distributions. I would also like to use these as covariance parameters for MarkovKernels.Normal. When I try this it works, but the covariance parameter gets transformed into a Symmetric:
But by construction, PSDMatrix is already symmetric. I tried overloading Symmetric in PSDMatrices.jl with
Symmetric(M::PSDMatrix) = M
but then I get stack overflow issues as the Normal constructor repeatedly tries to call Symmetric. What do you think would be the best way to fix this and allow for PSDMatrices?
One proposal would be to write a new constructor for Normal that does not attempt to transform a PSDMatrix into Symmetric, e.g. with
function Normal(μ::AbstractVector, Σ::PSDMatrix)
T = promote_type(eltype(μ), eltype(Σ))
return Normal{T}(convert(AbstractVector{T}, μ), convert(PSDMatrix{T}, Σ))
end
This could then be a package extension. But maybe a different approach makes more sense so let me know what you think.
In my code I rely on PSDMatrices.jl to represent covariace parameters of Gaussian distributions. I would also like to use these as covariance parameters for
MarkovKernels.Normal
. When I try this it works, but the covariance parameter gets transformed into aSymmetric
:But by construction,
PSDMatrix
is already symmetric. I tried overloadingSymmetric
in PSDMatrices.jl withbut then I get stack overflow issues as the
Normal
constructor repeatedly tries to callSymmetric
. What do you think would be the best way to fix this and allow for PSDMatrices?One proposal would be to write a new constructor for
Normal
that does not attempt to transform aPSDMatrix
intoSymmetric
, e.g. withThis could then be a package extension. But maybe a different approach makes more sense so let me know what you think.