-
Notifications
You must be signed in to change notification settings - Fork 73
Rewrite MatRing to wrap a native matrix #2207
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
Conversation
|
Comment/Question about matrix multiplication (and probably other binary operators): the current proposal is for a function |
|
I think the mixed-type cases must be removed. So if we still need this, it should be |
Sorry, it was my misreading/misremembering of the code. Anyway, the only cases of interest are the two "homogeneous" cases. Thanks for the feedback! I'll deal with it tomorrow. Then the "real" function takes two |
|
Yes, sounds good. I think |
src/Matrix.jl
Outdated
| end | ||
|
|
||
| function *(x::MatElem{T}, y::MatElem{T}) where {T <: NCRingElement} | ||
| function *(x::T, y::T) where {T <: MatrixElem} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JohnAAbbott ... while this was restricted to the "both arguments have the same type.
But yeah it really should be
| function *(x::T, y::T) where {T <: MatrixElem} | |
| function *(x::T, y::T) where {T <: MatElem} |
and then there should be MatRingElem methods for *, +, - etc. which delegate to the the underlying "plain" matrix.
I.e., also the existing changes in this PR in lines 826 and 837 of this file need to be furhter modified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange: I thought I had already written that the suggested change triggers a StackOverflowError: namely
Views: Error During Test at /home/zez25zuh/OSCAR/TMP/AbstractAlgebra.jl/ext/TestExt/Rings-conformance-tests.jl:706
Test threw exception
Expression: N1 * N2 == matrix(R, 2, 2, BigInt[14, 20, 20, 29])
StackOverflowError:
Stacktrace:
[1] Array
@ ./boot.jl:479 [inlined]
[2] MatSpaceElem
@ ~/OSCAR/TMP/AbstractAlgebra.jl/src/generic/GenericTypes.jl:1114 [inlined]
[3] _change_base_ring
@ ~/OSCAR/TMP/AbstractAlgebra.jl/src/Matrix.jl:6546 [inlined]
[4] change_base_ring(R::AbstractAlgebra.Integers{BigInt}, M::AbstractAlgebra.Generic.MatSpaceElem{BigInt})
@ AbstractAlgebra ~/OSCAR/TMP/AbstractAlgebra.jl/src/Matrix.jl:6555
[5] promote
@ ~/OSCAR/TMP/AbstractAlgebra.jl/src/Matrix.jl:1170 [inlined]
[6] *(x::AbstractAlgebra.Generic.MatSpaceView{BigInt, Tuple{UnitRange{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, y::AbstractAlgebra.Generic.MatSpaceElem{BigInt}) (repeats 79980 times)
@ AbstractAlgebra ~/OSCAR/TMP/AbstractAlgebra.jl/src/Matrix.jl:1178
All tests pass with the code in its current state: 2025-12-10 16:38 CET
|
I'm making progress, and thanks to @fieker have fixed one "type instability" problem -- the code is/was type-stable but Julia was not able to recognise this, so needed an explicit helping hand. |
|
What matrix operations do we want to perform on which fails because So the types almost match... |
|
Here are some functions for Do we want an "Array interface" for These function would allow a mixture of There are very many more in The following will give an error if the matrix has 0 rows or 0 columns; intentional? |
|
It is a significant hindrance that the tests call several of the above "questionable" functions. I prefer not to "push" while I know that several tests do not pass... The current blocking case is |
|
Another oddity: we have the names |
|
What is the utility of the file The first comment states: Surely the OSCAR specific matrix types will handle matrices of OSCAR values better than Julia's native matrices, no? In In |
It does not for me.
No, not in all cases. It depends on what "handle" means. A few algorithms are much faster with plain julia matrices if one uses them as plain two-dimensional arrays without any "matrix functionality". (IMHO they should not have been called "Matrix" in the first place.)
Have you checked the git history? Someone must have added it and the reason might be given in the commit message. But also I am not sure how relevant this is for this PR here? P.S.: When you used |
|
Which of the questions you asked (concerning the PR here) are still open? It seems there were some offline discussions, which might have answered some (all?) of those questions? |
Sorry wrong file path: it should have been |
|
This has conflicts with master. To repeat what I said earlier but in writing: I strongly recommend to suppress the urge to complicate this with removal of functionality (which is a breaking change). At least minimize such changes |
|
I have just pushed some corrections: all AA tests passed on my computer. I'll wait to see what GitHub says... |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2207 +/- ##
=======================================
Coverage 88.00% 88.00%
=======================================
Files 127 127
Lines 31795 31758 -37
=======================================
- Hits 27980 27950 -30
+ Misses 3815 3808 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lgoettgens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going in the right direction, and I am happy about how much stuff you were just able to replace by a one-liner. A few comments below, that will help with type stability and future maintainability
Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
Co-authored-by: Lars Göttgens <[email protected]>
lgoettgens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed that I have some forgotten comments. If you already fixed them in the meantime, please just ignore
I had overlooked them. Now I have responded. |
…tAlgebra.jl into mh/MatRing-native-matrix
|
@JohnAAbbott I marked several of my comments as "resolved", so that those which remain are more visible :-) |
|
What next? As far as I can see the code is now working (except for 1 failing check -- anyone know what that is about?) |
JohnAAbbott
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth merging the current code, and outstanding matters can be handled in a new PR (to avoid making this PR still longer -- see also my last comment in Conversation).
thofma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, lets get this in.

This is code trying to address issue #1955 which I wrote last December but never finished.
@JohnAAbbott I am putting it here because it might be useful for you, e.g. you could use it as a basis and complete it (feel free to work on this PR, or copy it to a new one). Or perhaps you prefer to start from scratch, but then it might still be helpful to check what I've done here.
This is incomplete in that I am sure tests will fail and things are missing. A lot of code which is currently defined for
MatrixElemmay have to be changed (but it may also be possible to delay that for the time being -- e.g. changingdetto delegate todetof the wrapped matrix is strictly speaking an optimization?)