-
Notifications
You must be signed in to change notification settings - Fork 36
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
WIP: Make integer and finite field matrices be MatrixObjs #621
Conversation
I support this, will be interested to see how it works out! |
@wilfwilson is this finished? Or is there more work to do? If so, what is the work required? |
No, it's not finished. In this PR, I have successfully made all of our matrices have the filter I've had some discussions with @fingolfin about whether it is acceptable for matrices in For our Semigroups-related purposes this doesn't matter, because we know to always treat them as if they are in the correct semiring. But if our objects are My impression was that Max isn't keen. His suggestion was to implement dummy semiring objects and elements, so that Note that for our matrices over finite fields and our matrices over integers, there are no problems since these fields/rings are implemented in GAP. Therefore, I can and will make these types be These are the realistic options I see for the type-problem thing:
In reality, however, I don't see a user accidentally using our methods in a way that will produce these "weird" matrices. These matrices can only be created if you explicitly pass the first filter What do you think? None of this is going to require much code to change, the question is just being careful to make sure we don't surprise anyone or break anything. |
One thing that is not yet quite clear to me is: What would be the "IsMatrixObj benefit" for e.g. your tropical matrices? My impression is that virtually everything for it has to be coded from scratch, there seems to be zero possibility of "code reuse" there, or at least not for anything that ever touches entries, because the entries are integers but with different "addition" and "multiplication". I think making this clearer might help in arriving at a good plan |
Ideally we'd move to a situation where we have |
Not unreasonable, but I don't think it's worth doing simply for the sake of nicely fitting into the For now, I'll (eventually) update this PR to implement just |
b1066b6
to
155df95
Compare
d8a6f49
to
666b0eb
Compare
ffad911
to
9a7622b
Compare
I have split this PR into two commits, so you can see what are the 'important' changes and what are just the ones taking advantage of the There are two main thrusts to the work:
This PR is not complete in either sense but it goes some way to achieving this (it requires more testing of Semigroups and GAP to see what is lacking). @james-d-mitchell Please feel free to either take over this PR, or be inspired by what I have (partially) done in your own implementation. |
gap/elements/semiringmat.gi
Outdated
# TODO Or InfoStatement and TryNextMethod() in full case? | ||
# And an error if it's not rectangular, then a try next method if not sq? | ||
ErrorNoReturn("the 2nd argument must define a square matrix"); | ||
elif not filter in [IsBooleanMat, | ||
IsMaxPlusMatrix, | ||
IsMinPlusMatrix, | ||
IsProjectiveMaxPlusMatrix, | ||
IsIntegerMatrix] then | ||
# TODO Or TryNextMethod() to allow other packages to use this? | ||
ErrorNoReturn("cannot create a matrix from the given arguments"); |
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.
Switching to TryNextMethod
is precisely what PR #819 does :-)
The changes of me that were merged to stable-4.0 will likely conflict with this PR in parts, though I hope the conflicts will be easy enough to resolve. I wonder how to proceed with this, though. One idea would be to simply merge it (after resolving the conflicts mentioned above), and go with it: sure the MatrixObj implementation may not be complete, but I don't think there are serious downsides to a partial one at this point? Alternatively, this could wait until a proper "test suite" for MatrixObj is available... but of course we've been waiting for one for years :-/. Then again, there are currently GAP Days being organized for later this year where the idea is to work on MatrixObj, so perhaps such a test suite could be developed there, and perhaps even co-developed with this PR here... @james-d-mitchell if you are interested in principle, there is a Doodle on the GAP Slack in channel |
@fingolfin I'd like to attend the next GAP days if I can, I'm going to try to resurrect this PR just now, and see to what extent it resolves the issues in |
I've rebased, although I didn't properly verify that the result of the rebase made sense. I'm not sure what, if anything, is worth salvaging from here (hopefully something!). But please feel free to do what you like with it. |
I'm trying to see how painful it is, and whether it's even possible, to make Semigroups matrices fit into the GAP
MatrixObj
framework. This would let us benefit from the setup there, in particular some new notation, and default methods, and we would also be using the standard names for things, so that people familiar with how to manipulate other matrices in GAP will already know what the appropriate commands are for our matrices.(One thing that I like is that with matrix objects, you can do
mat[i,j]
to access the entry in rowi
and columnj
.)This is related to but still mostly independent of #512: we can create matrices with some other operation than
Matrix
, but still have them be matrix objects. However, if we can make our matrices fully fit into theMatrixObj
framework, then I think we would happily continue to useMatrix
.On the whole this seems to be going fairly smoothly, with no major interventions, except for the requirement of GAP 4.10.0 rather than GAP 4.9.0. However, I've definitely not done everything (I'm not sure exactly which methods
MatrixObj
s need to offer), but perhaps the stumbling block will be if it is required to implementBaseDomain
methods for our matrices.Basically, the
BaseDomain
is supposed to be something like the field/ring/whatever generated by the elements of the matrix, or at least the field/ring/whatever in which they live. However, I'm not sure if we can always do that. Consider anNTPMatrix
: the entries are integers, but we definitely wouldn't want theBaseDomain
to beIntegers
; but we also haven't implemented NTP semiring objects (and we have no intention to), so we couldn't return an appropriate NTP semiring either. Therefore we can't install aBaseDomain
method in this case. Hopefully that's not fatal.