JuliaStats / PDMats.jl

Uniform Interface for positive definite matrices of various structures
Other
104 stars 43 forks source link

Ensure that the output of `X_A_Xt` etc. is symmetric #191

Closed devmotion closed 10 months ago

devmotion commented 10 months ago

The performance improvement in https://github.com/JuliaStats/PDMats.jl/commit/a97533d1b2c162d6354834be774beff769f7e8eb had an unforeseen side effect: It increases the probability that the output of the tri products (for PDiagMat matrices) is numerically not exactly symmetric. This causes downstream issues (e.g., in Distributions: https://github.com/JuliaStats/Distributions.jl/issues/1789#issuecomment-1765302266) in further computations (such as cholesky) that fail/error (more often) if the output is not symmetric.

This PR wraps the output of X_A_Xt etc. in a Symmetric to fix these issues. I also added tests.