-
Notifications
You must be signed in to change notification settings - Fork 167
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
Start the process of making vector and matrix objects official #3643
Start the process of making vector and matrix objects official #3643
Conversation
This may be something that's already been discussed to death and resolved, in which case fine, but I'm a bit concerned about the idea that equality of matrix objects ignores the For these kinds of reasons, I would prefer to keep matrix objects with different recorded |
@stevelinton thanks for the comment.
|
@stevelinton in general, no matter what we do, I believe firmly in the following: if one wants to use hashing, and e.g. a hashtable of matrices or vectors, then the only way to do this efficiently is by forcing all inputs objects to be in the same representation, period. That's what I do in my own orbit code, for example. I guess this correspond to forcing the |
@fingolfin I agree. But assuming we want some generic way to get at a hash function, we either have to define our hash functions (and data structures that use them) as not respecting equality (which is an option, but a departure from our usual approach, and not really an option for @ThomasBreuer I think your interpretation is correct. |
What is missing in the documentation of |
a87b8da
to
c1fcd23
Compare
(as mentioned in the description of commit c1fcd23) |
@ThomasBreuer I took the liberty of adding a few commits to this PR. Of course they can be changed and squashed, but they made the tests pass for me locally (let's see how this fares on GitHub). This PR also needs to be rebased. Several points cropped up: IsRowListMatrix versus IsList
I prefer the second variant, as that gives us more flexibility in the future, and imposes less of a burden on implementors. Also, it goes hand in hand with my next point ... Do we really want to "require" resp. support
|
Also: |
9496db9
to
13baccb
Compare
It would be good to not let this bitrot further. I just rebased this PR, as there were several conflicts already. I also added a few more tweaks to it. Perhaps we can at least merge parts of it already now, and focus on the remaining issues afterwards? |
13baccb
to
f8b30a7
Compare
@fingolfin How do you want to proceed, in order to merge parts of the changes? (I must admit that I got lost after your intervention in September.) |
@ThomasBreuer I am sorry I lost you with my "intervention" (?) in September. I didn't think that the commits I added (which I mostly added to resolve many of the remaining test suite failures) would cause confusion. Please next time I loose you like that, don't hesitate to speak up immediately. I actually only added those commits back then because there hadn't been activity for 2-3 weeks and I didn't want this to bitrot; and similar I finally rebased yesterday because I didn't get a reply for two months. Anyway, to proceed, I see two ways (not mutually exclusive):
|
For now, I'll move some of my changes in here to separate PRs, then we (and others) can discuss them there and merge/revise/reject them there. |
d62557d
to
157288f
Compare
With
|
ELM_MAT ); | ||
DeclareSynonym( "MatElm", ELM_MAT ); | ||
DeclareOperationKernel( "MatElm", [ IsMatrixObj, IS_INT, IS_INT ], ELM_MAT ); | ||
DeclareSynonym( "[,]", ELM_MAT ); |
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 change swaps the name of the kernel operation and its synonym. What is the motivation for this? (I don't see it mentioned in the commit message).
This changes e.g. backtraces that involve [,]
(see the third commit in this PR, where I adjust testspecial
for that, among other things). Also note that we for []
, we do this (and that was my main motivation for doing DeclareOperationKernel("[,]", ...)
):
DeclareOperationKernel( "[]",
[ IsList, IS_INT ],
ELM_LIST );
a2278d7
to
cbe2d87
Compare
cbe2d87
to
faea3dc
Compare
@ThomasBreuer I revised my changes a couple more times now, and hope they are now simple enough. All Travis tests pass now. But I suspect we need to downrank more methods in order to make package test suites pass. I was also wondering again if making Makes me wonder: Did we ever consider the possibility of adding a filter |
I don't think I have any objections to |
I've been trying to use this PR to make the matrix obj wrappers for meataxe64 matrices work. I've implemented all the methods mentioned in section 26.13, but there seems to be quite a bit more needed. I've added multiplication methods and it seems I also need Unpack before any default methods will work. Another problem -- |
@stevelinton I really would like to see this merged rather sooner than later. As it is, it once again needs to be rebased. In retrospect, I am not sure it was a good idea to make such a big change in one go. At the very least not when it takes so long to get merged... @ThomasBreuer I am kind of waiting for you to react to my last comment(s). It would be great (also for OSCAR) if we could make progress on MatrixObj in general, and this PR in particular. |
@fingolfin I'd be happy to see this merged as is. My observations from trying to use it an sensibly be dealt with in a follow-up. |
@fingolfin @stevelinton I think we can proceed by "merging as is", and afterwards try to get rid of the explicit downrankings by
|
- turned the raw documentation for vector and matrix objects into GAPDoc format, which is included in the GAP Reference Manual; this concerns also row list matrices (`lib/matobjplist.gd`); the manual chapter "Matrix Objects" now contains the relevant information, still some material will have to be moved between the chapters "Matrices" and "Matrix Objects" - added a preliminary version of missing default methods; due to that, many tests from GAP's test suite now fail; apparently the 'IsMatrixObj' methods get higher rank than the methods for `IsPlistRep` matrices, note that some of the latter ones do not require `IsMatrix` but just `IsListDefault`; and note that some `IsMatrixObj` methods do not only override methods for `IsPlistRep` matrices but also methods for other wrapped objects which claim to be in `IsMatrix`, such as some basis objects and Lie objects - default methods using 'Unpack' must make sure that they are not called with `IsPlistRep` arguments, in order to avoid recursion depth traps or segmentation faults; this is due to the decision that `IsMatrix` implies `IsMatrixObj` --it would be technically easier to separate the worlds of `IsMatrix` and `IsMatrixObj`, but I still think that the implication is logically better. - renamed some operations in matrix.gd, kept the old names; renamed also `AddRowVector` to `AddVector`, kept the old name - removed the `TraceMat` method installed for `IsList`, which is taken over by the method for `IsMatrixObj`; perhaps more methods can eventually disappear this way - some open items are listed at the end of the files `matobj2.gd` (one TODO, Backwards compatibility, Open items) and `matobj.gi` (Backwards compatibility) - next steps before this stuff can be merged: - make the tests pass again; for that, I have to make more experiments with the default methods for `IsMatrixObj` - deal with the open items; some decisions are still to be made - add manual examples, perhaps with a type of matrix objects for which not more than the compulsory methods are installed - add generic tests for implementations of vector/matrix objects, similar to the ones in 'tst/teststandard/arithlst.g' - revisit the available implementations of vector/matrix objects in the GAP library and in packages
- changed the definition of equality for `IsVectorObj` and `IsMatrixObj`, see the comments by @stevelinton; we have to distinguish the cases where the object in question is in `IsList` (such that equality is already defined) or not; note that this has nothing to do with the question whether objects are in `IsPlistRep`, for example, the function `ConjugacyClassesOfNaturalGroup` creates class representatives in `IsPlistRep` but compares them to the identity element of the group, which is likely to be in `Is8BitMatrixRep` (eventually, such situations should be improved). - removed unnecessary default methods for `AdditiveInverseImmutable`, `ZeroImmutable`, `OneImmutable`, `InverseImmutable` because they are already available more generally. - adjusted more default methods using `Unpack` to be not applicable to plain lists - fixed the `Unpack` method for `IsMatrix` (do not use `ShallowCopy`) - added `CompatibleVectorFilter` methods for `Is8BitMatrixRep` and `IsGF2MatrixRep`
... and at the same time make it more robust against future changes of lib/matobj.gi
- add Unpack method to IsRowListMatrix - add Unpack method for IsRowVector and IsPlistRep - add MutableCopyMatrix method for empty lists - rank down generic MutableCopyMatrix methods (the rank of IsMatrix is very high, e.g. higher than the rank of Is8BitMatrixRep; yet the generic IsMatrix method still should be ranked higher than the generic IsMatrixObj method, so that e.g. LieObjects wrapping plain list matrices are handled right)
We want these fallback method only to be triggered as a last resort, if an implementation provides no better methods. But e.g. IsRowVector is already a filter with rank higher than some IsVectorObj implementations might have.
faea3dc
to
79155a3
Compare
@ThomasBreuer @stevelinton I've now rebased this. From my point of view, it'd be fine to go along with @ThomasBreuer proposal: merge this now, then do as he suggested and replace the down ranking by doubling certain method installations |
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.
Approved -- @stevelinton if you are happy with it, please also consider approving.
We should of course wait for CI tests to complete before merging this.
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.
As discussed at length. This is a step forward and breaks nothing we know about.
turned the raw documentation for vector and matrix objects into
GAPDoc format, which is included in the GAP Reference Manual;
this concerns also row list matrices (
lib/matobjplist.gd
);the manual chapter "Matrix Objects" now contains the relevant information,
still some material will have to be moved between the chapters
"Matrices" and "Matrix Objects"
added a preliminary version of missing default methods;
due to that, many tests from GAP's test suite now fail;
apparently the 'IsMatrixObj' methods get higher rank than the
methods for
IsPlistRep
matrices, note that some of the latter onesdo not require
IsMatrix
but justIsListDefault
;and note that some
IsMatrixObj
methods do not only overridemethods for
IsPlistRep
matrices but also methods for otherwrapped objects which claim to be in
IsMatrix
, such as some basis objectsand Lie objects
default methods using 'Unpack' must make sure that they are not
called with
IsPlistRep
arguments,in order to avoid recursion depth traps or segmentation faults;
this is due to the decision that
IsMatrix
impliesIsMatrixObj
--it would be technically easier to separate the worlds of
IsMatrix
and
IsMatrixObj
, but I still think that having the implication is logicallybetter.
renamed some operations in matrix.gd, kept the old names;
renamed also
AddRowVector
toAddVector
, kept the old nameremoved the
TraceMat
method installed forIsList
,which is taken over by the method for
IsMatrixObj
;perhaps more methods can eventually disappear this way
some open items are listed at the end of the files
matobj2.gd
(one TODO, Backwards compatibility, Open items) andmatobj.gi
(Backwards compatibility)next steps before this stuff can be merged:
make the tests pass again; for that, I have to make more experiments
with the default methods for
IsMatrixObj
deal with the open items; some decisions are still to be made
add manual examples, perhaps with a type of matrix objects for which
not more than the compulsory methods are installed
add generic tests for implementations of vector/matrix objects,
similar to the ones in 'tst/teststandard/arithlst.g'
revisit the available implementations of vector/matrix objects
in the GAP library and in packages