Improve BaseDomain for plist-of-list matrices#4805
Improve BaseDomain for plist-of-list matrices#4805fingolfin merged 1 commit intogap-system:masterfrom
Conversation
ThomasBreuer
left a comment
There was a problem hiding this comment.
This looks good.
The change in the BaseDomain method is clearly a bugfix.
The added BaseDomain methods define new defaults, which is fine.
The new BaseDomain method for IsMatrix and IsPlistRep and IsCyclotomicCollColl is consistent with what DefaultScalarDomainOfMatrixList does, but also the BaseDomain method for row vectors should be changed, for the sake of consistency:
gap> m:= [ [ 1 ] ];;
gap> BaseDomain( m );
Rationals
gap> BaseDomain( m[1] );
Integers
gap> DefaultScalarDomainOfMatrixList( [ m ] );
Rationals
I have added comments concerning the tests that are commented out because of the bugs that are present. Shall we merge this pull request, and I prepare a follow-up that deals with the tests that are commented out, and the above inconsistency?
|
|
||
| # FIXME: BUG: | ||
| #gap> BaseDomain(Matrix(GF(2), m)); | ||
| #Rationals |
There was a problem hiding this comment.
Currently Matrix(GF(2), m) returns a copy of m.
The NewMatrix method in question calls ConvertToMatrixRep and ignores the fail result.
I think this method should signal an error.
(Well, we should first agree that we want an error message here.
The documentation states that the matrix entries need not lie in the base ring of the matrix but may also "naturally embed in the sense that addition and multiplication automatically work with elements of the base domain".
The condition about arithmetic operations is satisfied for integers and elements of GF(2) but we are not in the situation of an embedding; perhaps the documentation should be made more precise here.)
There was a problem hiding this comment.
I think that wording was specifically there based on discussion with @frankluebeck, to allow having entries equal to immediate integer objects like 0 and 1, which are much more efficient than general ring elements. I.e. this was strictly intended for optimization purposes.
However, I always felt this is "iffy", and I would reject it for this constructor. Of course a matrix type may use integer objects internally, to fill entries (as, indeed, the new matrix type over Z/nZ defined by @hulpke does); and the implementor may also provide special constructors which accept as input such immediate integers (and anything else that they see fit), but IMHO the default methods should not be required to do so...
Of course checking whether elements are inside a given domain can be expensive. So perhaps we'd want a (set of) MatrixNC methods which don't perform these checks (and/or a "nocheck" option, or whatever). But arguably the default ways to construct MatrixObj instances should IMHO reject "obvious" nonsense.
hulpke
left a comment
There was a problem hiding this comment.
What is the allowed relation between BaseDomain and `DefaultFieldOfMatrix'? What should a function use if only a ring of coefficients is needed?
|
@hulpke If the question is about creating matrix objects, one is on the safe side if one sets the |
|
Also, |
|
The test failure is caused by the semigroups package. Without it: gap> Matrix(Integers, [[1,2],[3,4]]);
<2x2-matrix over Integers>
gap> BaseDomain(last);
IntegersWith semigroups loaded: |
The added tests also reveal various long standing bugs in the underlying code.
5221f31 to
ec498db
Compare
The added tests also reveal various long standing bugs in the underlying code.
Motivated by PR #4773