PDMats.jl icon indicating copy to clipboard operation
PDMats.jl copied to clipboard

Add `AbstractPDMat` constructor

Open devmotion opened this issue 3 years ago • 1 comments

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).

devmotion avatar Sep 18 '22 21:09 devmotion

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
@@            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 Coverage Δ
src/generics.jl 86.48% <100.00%> (+0.77%) :arrow_up:
src/pdiagmat.jl 97.27% <100.00%> (+0.07%) :arrow_up:
src/pdmat.jl 97.91% <100.00%> (+0.04%) :arrow_up:
src/pdsparsemat.jl 95.00% <100.00%> (+0.17%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

codecov-commenter avatar Sep 18 '22 21:09 codecov-commenter