JuliaStats / PDMats.jl

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

Add `AbstractPDMat` constructor #172

Closed devmotion closed 1 year ago

devmotion commented 1 year ago

This PR adds AbstractPDMat(::AbstractMatrix), AbstractPDMat(::Cholesky) and AbstractPDMat(::CholTypeSparse).

The main motivation is that this allows to specialize on the matrix type, which allows downstream packages such as Distributions (e.g. in https://github.com/JuliaStats/Distributions.jl/blob/9f9c5caf6cd99c5205a11ca1c8d6b6471fc9ce29/src/multivariate/mvnormal.jl#L201-L203) to just use AbstractPDMat(A) instead of adding custom dispatches.

Unfortunately, we can't add something like AbstractPDMat(A::UniformScaling) (size unknown) or AbstractPDMat(A::Diagonal{<:Real,<:FillArrays.Fill{<:Real}}) (FillArrays dependency).

Fixes #136 (without lying about the return type).

codecov-commenter commented 1 year ago

Codecov Report

Base: 89.93% // Head: 90.11% // Increases project coverage by +0.18% :tada:

Coverage data is based on head (b4c05b6) compared to base (cc7c5c4). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #172 +/- ## ========================================== + Coverage 89.93% 90.11% +0.18% ========================================== Files 8 8 Lines 437 445 +8 ========================================== + Hits 393 401 +8 Misses 44 44 ``` | [Impacted Files](https://codecov.io/gh/JuliaStats/PDMats.jl/pull/172?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/generics.jl](https://codecov.io/gh/JuliaStats/PDMats.jl/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2dlbmVyaWNzLmps) | `86.48% <100.00%> (+0.77%)` | :arrow_up: | | [src/pdiagmat.jl](https://codecov.io/gh/JuliaStats/PDMats.jl/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3BkaWFnbWF0Lmps) | `97.27% <100.00%> (+0.07%)` | :arrow_up: | | [src/pdmat.jl](https://codecov.io/gh/JuliaStats/PDMats.jl/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3BkbWF0Lmps) | `97.91% <100.00%> (+0.04%)` | :arrow_up: | | [src/pdsparsemat.jl](https://codecov.io/gh/JuliaStats/PDMats.jl/pull/172/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL3Bkc3BhcnNlbWF0Lmps) | `95.00% <100.00%> (+0.17%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.