Skip to content

Commit

Permalink
FIxup
Browse files Browse the repository at this point in the history
  • Loading branch information
james-d-mitchell committed Jun 16, 2022
1 parent 3b56778 commit 559094c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 51 deletions.
2 changes: 1 addition & 1 deletion gap/elements/ffmat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ DeclareAttribute("RightInverse", IsMatrixOverFiniteField);
DeclareAttribute("LeftInverse", IsMatrixOverFiniteField);

DeclareAttribute("RowRank", IsMatrixOverFiniteField);
DeclareAttribute("BaseDomain", IsMatrixOverFiniteField);

#############################################################################
## Declarations specifically for finite field matrices collections
Expand Down Expand Up @@ -127,7 +128,6 @@ BindGlobal("PlistRowBasisOverFiniteFieldType",
DeclareRepresentation("IsPlistMatrixOverFiniteFieldRep",
IsMatrixOverFiniteField and IsComponentObjectRep and
IsAttributeStoringRep, ["mat"]);
# and IsRowListMatrix, ["mat"]);
BindGlobal("PlistMatrixOverFiniteFieldFamily",
NewFamily("PlistMatrixOverFiniteFieldFamily",
IsMatrixOverFiniteField, CanEasilyCompareElements));
Expand Down
52 changes: 10 additions & 42 deletions gap/elements/ffmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

# This file contains an implementation of matrices over finite fields.

# TODO(MatrixObj) this can be remove when ffmat -> MatrixObj
InstallOtherMethod(TraceMat, "for a plist matrix over finite field",
[IsPlistMatrixOverFiniteFieldRep],
mat -> TraceMat(mat!.mat));

InstallMethod(SEMIGROUPS_TypeViewStringOfMatrixOverSemiring,
"for a matrix over finite field",
[IsMatrixOverFiniteField], x -> "finite field");
Expand All @@ -31,7 +26,7 @@ InstallMethod(SEMIGROUPS_TypeOfMatrixOverSemiringCons,
# It is not currently possible to create any type of matrix except
# IsPlistMatrixOverFiniteFieldRep

InstallOtherMethod(\[\], "for a plist matrix over finite field and pos int",
InstallMethod(ELM_LIST, "for a plist matrix over finite field and pos int",
[IsPlistMatrixOverFiniteFieldRep, IsPosInt],
function(mat, pos)
if not IsBound(mat[pos]) then
Expand All @@ -44,7 +39,9 @@ end);
InstallMethod(IsBound\[\],
"for a plist matrix over finite field and pos int",
[IsPlistMatrixOverFiniteFieldRep, IsPosInt],
{mat, pos} -> IsBound(mat!.mat[pos]));
function(mat, pos)
return IsBound(mat!.mat[pos]);
end);

InstallMethod(MatElm,
"for a plist matrix over finite field positional rep, and two pos ints",
Expand All @@ -56,6 +53,12 @@ function(mat, row, col)
return mat!.mat[row][col];
end);

# This is here to silence some GAP tests when Semigroups is loaded
# and should become rendundant once the GAP MatrixObj code works
InstallOtherMethod(TraceMat, "for a plist matrix over finite field",
[IsPlistMatrixOverFiniteFieldRep],
mat -> TraceMat(mat!.mat));

# This should be used with caution, it can create corrupt objects

InstallMethod(MatrixNC, "for a matrix over finite field and list",
Expand Down Expand Up @@ -252,41 +255,6 @@ function(filter, field, list)
mat := Objectify(PlistMatrixOverFiniteFieldType,
rec(mat := ImmutableMatrix(field, List(list, ShallowCopy))));
SetBaseDomain(mat, field);
if CompareVersionNumbers(GAPInfo.Version, "4.12.0") then
SetConstructingFilter(mat, IsPlistMatrixOverFiniteFieldRep);
fi;
return mat;
end);

# TODO(MatrixObj) remove duplicate code between next and previous method

InstallMethod(NewMatrixOverFiniteField,
"for IsPlistMatrixOverFiniteFieldRep, a finite field, and a mutable list",
[IsPlistMatrixOverFiniteFieldRep, IsField and IsFinite, IsList and IsMutable],
function(filter, field, list)
local mat, filter2;

if not ForAll(list, v -> ForAll(v, x -> x in field)) then
ErrorNoReturn("the entries of the matrix are not all in ",
field);
fi;

filter2 := filter and IsMatrixOverFiniteField;

if HasCanEasilyCompareElements(Representative(field))
and CanEasilyCompareElements(Representative(field)) then
filter2 := filter2 and CanEasilyCompareElements;
fi;

# TODO(MatrixObj) is there a better way?? Seems bad to make an immuatble
# matrix then copy it
mat := Objectify(PlistMatrixOverFiniteFieldType,
rec(mat := MutableCopyMatrix(ImmutableMatrix(field,
List(list, ShallowCopy)))));
SetBaseDomain(mat, field);
if CompareVersionNumbers(GAPInfo.Version, "4.12.0") then
SetConstructingFilter(mat, IsPlistMatrixOverFiniteFieldRep);
fi;

return mat;
end);
Expand Down
4 changes: 3 additions & 1 deletion gap/elements/semiringmat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ DeclareOperation("RandomMatrixOp", [IsField and IsFinite, IsPosInt, IsPosInt]);

DeclareAttribute("AsList", IsMatrixOverSemiring);
DeclareOperation("AsMutableList", [IsMatrixOverSemiring]);
DeclareOperation("ELM_LIST", [IsMatrixOverSemiring, IsPosInt]);
DeclareOperation("IsBound[]", [IsMatrixOverSemiring, IsPosInt]);
DeclareOperation("Iterator", [IsMatrixOverSemiring]);
DeclareAttribute("DimensionOfMatrixOverSemiring", IsMatrixOverSemiring);
DeclareAttribute("DimensionOfMatrixOverSemiringCollection",
IsMatrixOverSemiringCollection);
DeclareAttribute("TransposedMatImmutable", IsMatrixOverSemiring);
DeclareProperty("IsTorsion", IsMatrixOverSemiring);

# Cannot use TypeObj since it can contain information about
Expand All @@ -127,7 +130,6 @@ DeclareConstructor("SEMIGROUPS_MatrixOverSemiringEntryCheckerCons",
[IsMatrixOverSemiring, IsInt, IsInt]);

DeclareOperation("MatElm", [IsMatrixOverSemiring, IsPosInt, IsPosInt]);
DeclareOperation("IsBound\[\]", [IsMatrixOverSemiring, IsPosInt]);
DeclareAttribute("TransposedMatImmutable", IsMatrixOverSemiring);
DeclareAttribute("NumberRows", IsMatrixOverSemiring);
DeclareAttribute("NumberColumns", IsMatrixOverSemiring);
Expand Down
7 changes: 0 additions & 7 deletions gap/elements/semiringmat.gi
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
# it is also square, any additional data (like the threshold for tropical
# matrices), is contained in the positions from Length(mat![1]) + 1 onwards.

# TEMPORARY (Wilf: I don't remember why I added this)
InstallMethod(IsOne, "for a matrix over finite field",
[IsMatrixOverFiniteField],
mat -> mat = One(mat));
# TODO Experiment with ListOp for our matrix objects
# TODO Experiment with Unpack for our matrix objects

#############################################################################
# Internal
#############################################################################
Expand Down

0 comments on commit 559094c

Please sign in to comment.