-
Notifications
You must be signed in to change notification settings - Fork 170
Provide a generic test suite for MatrixObjects #5162
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
Draft
wucas
wants to merge
19
commits into
gap-system:master
Choose a base branch
from
wucas:lw-as/MatObjTests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f3d16e8
initial commit
wucas 8686255
wip
wucas 33be739
wip
wucas f7f8261
add some helper functions
wucas 7643729
Add functions
afdb943
wip
wucas 713fcdd
main functionalities tested
74116ba
More tests
f151a2b
More tests
fe1e1af
fixup some errors
wucas 13f1c12
del unnecessary file
wucas 18d02e7
wip
wucas f45e338
wip
wucas 003182f
add a preliminary broken matObj implementation
wucas 2d50864
wip
wucas 1f89b05
add explanation of options for MatObjTest_GenerateExample
wucas 4292514
Add options
wucas 7826050
wip
wucas 43c4c50
wip
wucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
############################################################################# | ||
## | ||
## This file is part of GAP, a system for computational discrete algebra. | ||
## | ||
## SPDX-License-Identifier: GPL-2.0-or-later | ||
## | ||
## Copyright of GAP belongs to its developers, whose names are too numerous | ||
## to list here. Please refer to the COPYRIGHT file for details. | ||
## | ||
|
||
############################################################################ | ||
# | ||
# This is a minimal implementation for nxm matrices | ||
# stored as a flat n*m element list. In this | ||
# file the representation, types and global | ||
# functions are declared. | ||
# This implementation should not be used for actual computations. It serves | ||
# as an example for a minimal MatrixObj implementation and can be used to test | ||
# various things. | ||
|
||
|
||
############################################################################# | ||
## | ||
## <#GAPDoc Label="IsMinimalBROKENMatrixRep"> | ||
## <ManSection> | ||
## <Filt Name="IsMinimalBROKENMatrixRep" Arg='obj' Type="representation"/> | ||
## | ||
## <Description> | ||
## An object <A>obj</A> in <Ref Filt="IsMinimalBROKENMatrixRep"/> describes | ||
## a matrix object that stores the matrix entries as a flat list. It is | ||
## internally represented as a positional object | ||
## (see <Ref Filt="IsPositionalObjectRep"/> that stores 4 entries: | ||
## <Enum> | ||
## <Item> | ||
## its base domain | ||
## (see <Ref Attr="BaseDomain" Label="for a matrix object"/>), | ||
## </Item> | ||
## <Item> | ||
## the number of rows (see <Ref Attr="NumberRows" Label="for a matrix object"/>), | ||
## </Item> | ||
## <Item> | ||
## the number of columns | ||
## (see <Ref Attr="NumberColumns" Label="for a matrix object"/>), and | ||
## </Item> | ||
## <Item> | ||
## a plain list (see <Ref Filt="IsPlistRep"/> of its entries. | ||
## </Item> | ||
## </Enum> | ||
## It implements the MatrixObj specification in a minimal way, that is it | ||
## implements exactly the required methods. This is intended for testing and | ||
## development and should not be used for actual calculations! | ||
## </Description> | ||
## </ManSection> | ||
## <#/GAPDoc> | ||
## | ||
# Here we declare the new representation and tell GAP which properties it | ||
# implies. This minimal example is implemented as a positional object | ||
# like IsFlistMatrixRep and IsPlistMatrixRep. | ||
DeclareRepresentation( "IsMinimalBROKENMatrixRep", | ||
IsMatrixObj and IsMatrixOrMatrixObj and IsPositionalObjectRep | ||
and IsNoImmediateMethodsObject | ||
and HasNumberRows and HasNumberColumns | ||
and HasBaseDomain and HasOneOfBaseDomain and HasZeroOfBaseDomain, | ||
[] ); | ||
|
||
# If we implement our object as a positional object we often have to access its | ||
# properties in the code. To make that more readable we declare global | ||
# variables. If you do this too make sure you use variables that are unique and | ||
# unlikely to be used someplace else, even though that might mean using longer | ||
# names. Here we prefixed the names with the name of the representation. See | ||
# also Reference Manual Chapter 79 for more information about Objects. | ||
|
||
# Some constants for matrix access: | ||
# Position in the positional object of the base domain | ||
BindConstant( "MINREP_BDPOS", 1 ); | ||
# Position in the positional object of the number of rows | ||
BindConstant( "MINREP_NRPOS", 2 ); | ||
# Position in the positional object of the number of columns | ||
BindConstant( "MINREP_NCPOS", 3 ); | ||
# Position in the positional object of the list of entries | ||
BindConstant( "MINREP_ELSPOS", 4 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
############################################################################# | ||
## | ||
## This file is part of GAP, a system for computational discrete algebra. | ||
## | ||
## SPDX-License-Identifier: GPL-2.0-or-later | ||
## | ||
## Copyright of GAP belongs to its developers, whose names are too numerous | ||
## to list here. Please refer to the COPYRIGHT file for details. | ||
## | ||
|
||
############################################################################ | ||
# | ||
# This file is a minimal implementation for new style vectors and matrices. | ||
# It stores matrices as a dense flat list. | ||
# This implementation implements only the methods required by the specification | ||
# for matrix objects. This is intended for testing. | ||
|
||
InstallMethod( NewMatrix, | ||
"for IsMinimalBROKENMatrixRep, a ring, an int, and a list", | ||
[ IsMinimalBROKENMatrixRep, IsRing, IsInt, IsList ], | ||
function( filter, basedomain, nrcols, list_in ) | ||
local obj, filter2, list, rowindex, colindex; | ||
|
||
# If applicable then replace a nested list 'list_in' by a flat list 'list'. | ||
if Length(list_in) > 0 and (IsVectorObj(list_in[1]) or IsList(list_in[1])) then | ||
list := []; | ||
for rowindex in [1..Length(list_in)] do | ||
if Length(list_in[rowindex]) <> nrcols then | ||
Error( "NewMatrix: Each row must have nrcols entries." ); | ||
fi; | ||
for colindex in [1..nrcols] do | ||
list[(rowindex-1)*nrcols + colindex] := list_in[rowindex][colindex]; | ||
od; | ||
od; | ||
else | ||
if Length(list_in) mod nrcols <> 0 then | ||
Error( "NewMatrix: Length of list must be a multiple of ncols." ); | ||
fi; | ||
list := list_in; | ||
fi; | ||
|
||
obj := [basedomain,Length(list)/nrcols,nrcols,list]; | ||
filter2 := IsMinimalBROKENMatrixRep and IsMutable; | ||
if HasCanEasilyCompareElements(Representative(basedomain)) and | ||
CanEasilyCompareElements(Representative(basedomain)) then | ||
filter2 := filter2 and CanEasilyCompareElements; | ||
fi; | ||
Objectify( NewType(CollectionsFamily(FamilyObj(basedomain)), | ||
filter2), obj); | ||
return obj; | ||
end ); | ||
|
||
InstallMethod( BaseDomain, "for a minimal example matrix rep", | ||
[ IsMinimalBROKENMatrixRep ], | ||
function( m ) | ||
return GF(3);#m![MINREP_BDPOS]; | ||
end ); | ||
|
||
InstallMethod( NumberRows, "for a minimal example matrix rep", | ||
[ IsMinimalBROKENMatrixRep ], | ||
function( m ) | ||
return m![MINREP_NRPOS]-1; | ||
end ); | ||
|
||
InstallMethod( NumberColumns, "for a minimal example matrix rep", | ||
[ IsMinimalBROKENMatrixRep ], | ||
function( m ) | ||
return m![MINREP_NCPOS]+1; | ||
end ); | ||
|
||
InstallMethod( MatElm, "for an minimal example matrix rep and two positions", | ||
[ IsMinimalBROKENMatrixRep, IsPosInt, IsPosInt ], | ||
function( mat, row, col ) | ||
return mat![MINREP_ELSPOS][(row-1)*mat![MINREP_NCPOS]+col-1]; | ||
end ); | ||
|
||
InstallMethod( SetMatElm, "for an minimal example matrix rep, two positions, and an object", | ||
[ IsMinimalBROKENMatrixRep and IsMutable, IsPosInt, IsPosInt, IsObject ], | ||
function( mat, row, col, obj ) | ||
mat![MINREP_ELSPOS][(row-1)*mat![MINREP_NCPOS]+col] := Zero(mat![MINREP_BDPOS]); | ||
end ); | ||
|
||
InstallMethod( \<, "for two minimal example matrices", | ||
[ IsMinimalBROKENMatrixRep, IsMinimalBROKENMatrixRep ], | ||
function( a, b ) | ||
return LT_LIST_LIST_DEFAULT(a![MINREP_ELSPOS],b![MINREP_ELSPOS]); | ||
end ); | ||
|
||
InstallMethod( ConstructingFilter, "for a minimal example matrix rep", | ||
[ IsMinimalBROKENMatrixRep ], | ||
function( mat ) | ||
return IsMinimalExampleMatrixRep; | ||
wucas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end ); | ||
|
||
InstallMethod( CompatibleVectorFilter, [ IsMinimalBROKENMatrixRep ], | ||
M -> IsPlistVectorRep ); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.