JuliaStats / PDMats.jl

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

Improve broadcasting of `PDMat` and `PDiagMat` #197

Closed devmotion closed 10 months ago

devmotion commented 11 months ago

Implements Base.broadcastable for PDMat and PDiagMat by falling back to the wrapped matrix and a Diagonal object, respectively. Many generic fallbacks use broadcasting, and by falling back on the underlying better supported AbstractMatrix objects we reduce the number of surprising and undesired results in broadcasting operations but also e.g. subtraction (see https://github.com/JuliaStats/PDMats.jl/issues/195#issuecomment-1809816905).

One could similarly define Base.broadcastable(a::ScalMat) = Base.broadcastable(Diagonal(fill(a.value, a.dim))) but this leads to undesired results when working with e.g. static arrays (and causes undesired allocations which could maybe be fixed by working with FillArrays.Fill - but only recently we noticed that a dependency on FillArrays would increase loading time significantly: #192).

codecov-commenter commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (e0cad7c) 91.45% compared to head (0d7f2bd) 91.48%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #197 +/- ## ========================================== + Coverage 91.45% 91.48% +0.02% ========================================== Files 9 9 Lines 679 681 +2 ========================================== + Hits 621 623 +2 Misses 58 58 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.