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

Faster SwapMatrixRows and SwapMatrixColumns for GF2 matrices #5837

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

fingolfin
Copy link
Member

Before

gap> mat:=IdentityMat(10,GF(2));; ConvertToMatrixRep(mat);; mat;
<a 10x10 matrix over GF2>
gap> for i in [1..1000000] do SwapMatrixColumns(mat,1,2); od; time;
1020
gap> for i in [1..1000000] do SwapMatrixRows(mat,1,2); od; time;
167
gap> for i in [1..1000000] do tmp:=mat[1];mat[1]:=mat[2];mat[2]:=tmp; od; time;
85

After:

gap> mat:=IdentityMat(10,GF(2));; ConvertToMatrixRep(mat);; mat;
<a 10x10 matrix over GF2>
gap> for i in [1..1000000] do SwapMatrixColumns(mat,1,2); od; time;
135
gap> for i in [1..1000000] do SwapMatrixRows(mat,1,2); od; time;
77
gap> for i in [1..1000000] do tmp:=mat[1];mat[1]:=mat[2];mat[2]:=tmp; od; time;
87

@fingolfin fingolfin added topic: performance bugs or enhancements related to performance (improvements or regressions) topic: kernel release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Nov 11, 2024
@fingolfin fingolfin force-pushed the mh/swap-rows-cols-GF2 branch from 49d30a3 to c8476a7 Compare November 11, 2024 14:13
Before

    gap> mat:=IdentityMat(10,GF(2));; ConvertToMatrixRep(mat);; mat;
    <a 10x10 matrix over GF2>
    gap> for i in [1..1000000] do SwapMatrixColumns(mat,1,2); od; time;
    1020
    gap> for i in [1..1000000] do SwapMatrixRows(mat,1,2); od; time;
    167
    gap> for i in [1..1000000] do tmp:=mat[1];mat[1]:=mat[2];mat[2]:=tmp; od; time;
    85

After:

    gap> mat:=IdentityMat(10,GF(2));; ConvertToMatrixRep(mat);; mat;
    <a 10x10 matrix over GF2>
    gap> for i in [1..1000000] do SwapMatrixColumns(mat,1,2); od; time;
    135
    gap> for i in [1..1000000] do SwapMatrixRows(mat,1,2); od; time;
    77
    gap> for i in [1..1000000] do tmp:=mat[1];mat[1]:=mat[2];mat[2]:=tmp; od; time;
    87
@fingolfin fingolfin force-pushed the mh/swap-rows-cols-GF2 branch from c8476a7 to a9c85fd Compare November 11, 2024 14:16
Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

Looks good.

@fingolfin fingolfin merged commit 62bd8f0 into gap-system:master Nov 11, 2024
33 checks passed
@fingolfin fingolfin deleted the mh/swap-rows-cols-GF2 branch November 11, 2024 21:20
@fingolfin fingolfin changed the title Fast SwapMatrixRows/columns for GF matrices Fast SwapMatrixRows/columns for GF2 matrices Nov 11, 2024
@fingolfin fingolfin changed the title Fast SwapMatrixRows/columns for GF2 matrices Faster SwapMatrixRows and SwapMatrixColumns for GF2 matrices Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: kernel topic: performance bugs or enhancements related to performance (improvements or regressions)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants