Skip to content

Commit

Permalink
Overhaul IsPlistMatrixRep and IsPlistVectorRep
Browse files Browse the repository at this point in the history
- change `IsPlistMatrixRep` to *not* be a row list type; so instead
  of storing a list of `IsPlistVectorRep` instances, they now store an
  old-style matrix in `IsMatrix and IsPlistRep`. This in turn allows
  to simplify and optimize a lot of code, e.g. matrix arithmetic can
  now just dispatch to that for plain lists.
- use `BindConstant` on `BDPOS` etc. for best performance
- set `IsNoImmediateMethodsObject` filter for both for better performance
- rename `EMPOS` and `RLPOS` to `NUM_ROWS_POS` and `NUM_COLS_POS`
- allow semirings as basedomain
- fix various vector/matrix constructors to copy their inputs lists
  instead of reusing them inside (that can lead to bad bugs)
- removed a bunch of (now) redundant methods that didn't seem to
  provide any benefits (such as improved performance)
- ...
  • Loading branch information
fingolfin committed May 27, 2021
1 parent 5a1fe5f commit fe334ea
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 542 deletions.
33 changes: 13 additions & 20 deletions lib/matobjplist.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
## in a row list matrix
## (see Section <Ref Subsect="Operations for Row List Matrix Objects"/>).
## It is internally represented as a positional object
## (see <Ref Filt="IsPositionalObjectRep"/> that stores 2 entries:
## (see <Ref Filt="IsPositionalObjectRep"/> that stores two entries:
## <Enum>
## <Item>
## its base domain
Expand All @@ -45,7 +45,7 @@
## <#/GAPDoc>
##
DeclareRepresentation( "IsPlistVectorRep",
IsVectorObj and IsPositionalObjectRep, [] );
IsVectorObj and IsPositionalObjectRep and IsNoImmediateMethodsObject, [] );


#############################################################################
Expand All @@ -60,14 +60,15 @@ DeclareRepresentation( "IsPlistVectorRep",
## a list of its rows, in the sense defined in
## Section <Ref Sect="Operations for Row List Matrix Objects"/>.
## It is internally represented as a positional object
## (see <Ref Filt="IsPositionalObjectRep"/> that stores 4 entries:
## (see <Ref Filt="IsPositionalObjectRep"/> that stores four entries:
## <Enum>
## <Item>
## its base domain
## (see <Ref Attr="BaseDomain" Label="for a matrix object"/>),
## </Item>
## <Item>
## an empty vector in the representation of each row,,
## the number of rows
## (see <Ref Attr="NumberRows" Label="for a matrix object"/>), and
## </Item>
## <Item>
## the number of columns
Expand All @@ -83,28 +84,20 @@ DeclareRepresentation( "IsPlistVectorRep",
## <#/GAPDoc>
##
DeclareRepresentation( "IsPlistMatrixRep",
IsRowListMatrix and IsPositionalObjectRep, [] );
IsRowListMatrix and IsPositionalObjectRep and IsNoImmediateMethodsObject, [] );


# Some constants for matrix access:
BindGlobal( "BDPOS", 1 );
BindGlobal( "EMPOS", 2 );
BindGlobal( "RLPOS", 3 );
BindGlobal( "ROWSPOS", 4 );
# TODO rename these so that one can quickly see that they belong to IsPlist*Rep
BindConstant( "BDPOS", 1 );
BindConstant( "NUM_ROWS_POS", 2 );
BindConstant( "NUM_COLS_POS", 3 );
BindConstant( "ROWSPOS", 4 );

# For vector access:
#BindGlobal( "BDPOS", 1 ); # see above
BindGlobal( "ELSPOS", 2 );
#BindConstant( "BDPOS", 1 ); # see above
BindConstant( "ELSPOS", 2 );

# Two filters to speed up some methods:
DeclareFilter( "IsIntVector" );
DeclareFilter( "IsFFEVector" );

############################################################################
# Constructors:
############################################################################

#T Should this be documented?
#T It seems to be just an auxiliary function for the documented constructors.
DeclareGlobalFunction( "MakePlistVectorType" );

Loading

0 comments on commit fe334ea

Please sign in to comment.