Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve broadcasting of PDMat and PDiagMat #197

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Conversation

devmotion
Copy link
Member

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 #195 (comment)).

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
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@devmotion devmotion merged commit cd28425 into master Nov 22, 2023
12 checks passed
@devmotion devmotion deleted the dw/broadcastable branch November 22, 2023 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants