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

Make Matrix cntr work for structured matrices for zero(T) !isa T #44707

Merged
merged 2 commits into from
Mar 24, 2022

Conversation

dkarrasch
Copy link
Member

@dkarrasch dkarrasch commented Mar 23, 2022

This fixes #44615 (comment). At the same time, it extends the Matrix constructors to other structured matrices whose eltype T has the property !isa(zero(T), T). Before #44615, Matrix(::Diagonal) was defined in terms of diagm, which handled the eltype promotion correctly. Matrix(::BiTriSym), however, was defined manually without correctly handling type promotion.

Fixes jump-dev/JuMP.jl#2930.

@dkarrasch
Copy link
Member Author

@nanosoldier runtests(["JuMP"], vs = ":master")

@dkarrasch dkarrasch added linear algebra Linear algebra embarrassing-bugfix Whoops! backport 1.8 Change should be backported to release-1.8 labels Mar 23, 2022
@blegat
Copy link
Contributor

blegat commented Mar 23, 2022

Thanks! You can find here a list of assumptions commonly made and types for which it doesn't hold: jump-dev/MutableArithmetics.jl#47

@dkarrasch
Copy link
Member Author

Aha, I realize you made a more complete proposal in #36256. Currently, none of the Matrix methods touched here works for eltypes T that don't have zero(T) defined. So this PR here fixes the issue, and puts BiTriSym to the same level as Diagonal. So shall we take this one and continue the discussion in #36256? Or should I cut down a bit and make the fix only for Diagonal?

@KristofferC KristofferC mentioned this pull request Mar 23, 2022
22 tasks
@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - no new issues were detected. A full report can be found here.

@blegat
Copy link
Contributor

blegat commented Mar 23, 2022

shall we take this one and continue the discussion in #36256? Or should I cut down a bit and make the fix only for Diagonal?

Please leave this one as it is. I'll happily rebase #36256 once this one is merged.

Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
@dkarrasch dkarrasch merged commit 2099987 into master Mar 24, 2022
@dkarrasch dkarrasch deleted the dk/bitrisymmatrix branch March 24, 2022 09:09
KristofferC pushed a commit that referenced this pull request Mar 25, 2022
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests are broken on nightly
6 participants