-
Notifications
You must be signed in to change notification settings - Fork 161
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 (New)ZeroMatrix
, (New)IdentityMatrix
, (New)ZeroVector
to better reject invalid input
#4366
Conversation
One aim seems to be to get rid of (The same would make sense for Concerning the extended argument checks and error messages, |
71c1ce1
to
c1b21d1
Compare
This is now ready for review: I've added more tests, dropped some stuff, added missing variants of ZeroVector, and grouped everything into hopefully logical commits which should make the motivation for each change clearer. To further aid with that, I add the tests in an early commit, and then for later commits containing fixes, the effect of the fix is visible in how it changes the test file. |
These could become part of a future "conformance test suite" for MatrixObj implementations.
... using NewZeroMatrix & NewIdentityMatrix. One could now turn ZeroMatrix & IdentityMatrix into global functions, except that cvec installs methods for them, for an optimization: There, each vector/matrix over a certain field and row length stores an immutable "cvecclass" object; instead of reconstructing it each time, they copy it from the vector/matrix given as "template" to those variants of ZeroMatrix & IdentityMatrix which take an "example" object as input.
Even nicer would be to replace them by a single "default" version of NewIdentityMatrix. Unfortunately, this does not seem possible for constructors in GAP.
a0d16f0
to
1a17ffc
Compare
... for IsGF2MatrixRep and Is8Bit2MatrixRep. As a nice bonus, the changes also are tiny optimizations.
Since IsMatrix has a high rank and IsGF2VectorRep / Is8BitVectorRep objects are in the filter IsMatrix, the wrong BaseDomain method was selected for such objects. This reduces performance, and also caused an error with vectors of length 0.
Now that we have CopyToVectorRep in regular GAP, use it
1a17ffc
to
68c01d7
Compare
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 do not want to request changes (thus we can merge this pull request),
but the following thoughts about details should be discussed further.
-
Explicitly downranking the
BaseDomain
method forIsRowVector
is motivated by the fact that otherwise the (better) method forIsGF2VectorRep
has a lower rank.
I would argue that the methods forIsGF2VectorRep
should better be installed forIsRowVector and IsGF2VectorRep
since any object inIsGF2VectorRep
will be also inIsRowVector
.
One could defineIsGF2Vector:= IsRowVector and IsGF2VectorRep
, and use this in the method installations.
This "concurrence situation" will not occur for other VectorObj implementations, where the defining filter really determines the method that will be used. -
The removal of the "default method" for
NewZeroVector
is motivated by the fact that constructors cannot have default methods, see the discussion of issue MatrixObj: concerns regarding constructors like NewZeroMatrix, NewVector, etc. #4398. The documentation which methods are mandatory for a new VectorObj/MatrixObj implementation will depend on the result of this discussion.
The main reason I dealt with However, I wonder why DeclareRepresentation(
"IsGF2VectorRep",
IsDataObjectRep and IsVectorObj, [],
IsRowVector ); |
(New)ZeroMatrix
, (New)IdentityMatrix
, (New)ZeroVector
to validate their arguments
(New)ZeroMatrix
, (New)IdentityMatrix
, (New)ZeroVector
to validate their arguments(New)ZeroMatrix
, (New)IdentityMatrix
, (New)ZeroVector
to better reject invalid input
This is work in progress, but I wanted to have it already visible, so that e.g. @ThomasBreuer has a chance to comment if he wants to. Also, so that I can link to this PR from issues :-).
It should actually be mostly ready, but I need to go over everything once, and there are a few things that should be cleaned up, perhaps a few more tests can be added... We'll see.