gap
gap copied to clipboard
Improve BaseDomain for plist-of-list matrices
The added tests also reveal various long standing bugs in the underlying code.
Motivated by PR #4773
@hulpke If the question is about creating matrix objects, one is on the safe side if one sets the BaseDomain explicitly, like in Matrix( Integers, [ [ 1 ] ] ).
If one creates a matrix object without an argument that specifies the BaseDomain, like in Matrix( [ [ 1 ] ] ), one has to live with the default that is chosen; in this case, one gets a matrix over Rationals.
If the question is about what to do with a given matrix object, DefaultFieldOfMatrix gives just some default domain, whereas BaseDomain is stored in the object and should be assumed to be intentional.
Also, DefaultFieldOfMatrix must always be a ring by its name and its documentation. Of course one can cheat and let it return anything, but that's off-spec and I am sure it'll cause troubles down the road.
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);
Integers
With semigroups loaded:
gap> Matrix(Integers, [[1,2],[3,4]]);
Matrix(IsIntegerMatrix, [[1, 2], [3, 4]])
gap> BaseDomain(last);
Error, no method found!
See https://github.com/semigroups/Semigroups/issues/807