Skip to content
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

Implement a new matrix object using flat lists in row-major form #5121

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wucas
Copy link
Contributor

@wucas wucas commented Oct 16, 2022

This PR provides a work in progress of a a new matrix object representing matrices as flat lists in row-major form. It is intended to guide participants of the GAP Days in their work on other matrix objects.

Text for release notes

none

@wucas wucas added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes gapdays2022-summer Issues and PRs that arose at https://www.gapdays.de/gapdays2022-summer labels Oct 16, 2022
[ IsFlistMatrixRep ],
function( mat )
local n;
if m![FLISTREP_NCPOS] <> mat![FLISTREP_NRPOS] then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably mean mat![FLISTREP_NCPOS] <> mat![FLISTREP_NRPOS]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes thank you!

and HasBaseDomain and HasOneOfBaseDomain and HasZeroOfBaseDomain,
[] );

# If we implement our object a a positional object we often have to access its
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# If we implement our object a a positional object we often have to access its
# If we implement our object as a positional object we often have to access its

Comment on lines +68 to +74
BindGlobal( "FLISTREP_BDPOS", 1 );
# Position in the positional object of the number of rows
BindGlobal( "FLISTREP_NRPOS", 2 );
# Position in the positional object of the number of columns
BindGlobal( "FLISTREP_NCPOS", 3 );
# Position in the positional object of the list of entries
BindGlobal( "FLISTREP_ELSPOS", 4 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to end files with a newline. Also, we can use BindConstant here for a tiny further speed-up.

Suggested change
BindGlobal( "FLISTREP_BDPOS", 1 );
# Position in the positional object of the number of rows
BindGlobal( "FLISTREP_NRPOS", 2 );
# Position in the positional object of the number of columns
BindGlobal( "FLISTREP_NCPOS", 3 );
# Position in the positional object of the list of entries
BindGlobal( "FLISTREP_ELSPOS", 4 );
BindConstant( "FLISTREP_BDPOS", 1 );
# Position in the positional object of the number of rows
BindConstant( "FLISTREP_NRPOS", 2 );
# Position in the positional object of the number of columns
BindConstant( "FLISTREP_NCPOS", 3 );
# Position in the positional object of the list of entries
BindConstant( "FLISTREP_ELSPOS", 4 );

Error( "NewMatrix: Length of list must be a multiple of ncols." );
fi;
list := list_in;
fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of "this code is not covered by a test" comments by the Codecov bot here. I guess a nice task for this week would be to work on exactly such tests, in a way that makes them re-usable (we discussed this before, so I am guessing that was part of your intention anyway). Great :-)

local index_start, index_end;
index_start := (row-1)*mat![FLISTREP_NCPOS] + 1;
index_end := index_start + mat![FLISTREP_NCPOS];
return NewVector(IsPlistVectorRep,mat![FLISTREP_BDPOS],mat![FLISTREP_ELSPOS]{[index_start..index_end]});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this correct. In the sense that doing mat[i][j] := 0 won't work correctly. Will be discussed in my talk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: just return an immutable vector, then at least the above will raise an error.

Also see comments on PR #5130

[ IsFlistMatrixRep ],
function( mat )
local n;
if m![FLISTREP_NCPOS] <> mat![FLISTREP_NRPOS] then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if m![FLISTREP_NCPOS] <> mat![FLISTREP_NRPOS] then
if mat![FLISTREP_NCPOS] <> mat![FLISTREP_NRPOS] then

return m![FLISTREP_NCPOS];
end );

InstallMethod( DimensionsMat, "for a flist matrix",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to provide this, as the default method should be good enough

danielrademacher pushed a commit to danielrademacher/gap that referenced this pull request Oct 20, 2022
@fingolfin fingolfin changed the title Implement a new matrix object Implement a new matrix object using flat lists in row-major form Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2022-summer Issues and PRs that arose at https://www.gapdays.de/gapdays2022-summer kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants