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

Make BaseChangeHermitian faster for large matrices #55

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

fingolfin
Copy link
Member

... by performing row/column transformations directly instead of via matrix multiplication. This also reduces memory allocation and thus pressure on the garbage collector.

For comparison here are some timings using TestBaseChangeHermitian from tst/basechange.tst before and after this patch.

Before:

gap> TestBaseChangeHermitian(10, 7); [time,memory_allocated];
[ 1, 408841 ]
gap> TestBaseChangeHermitian(100, 7); [time,memory_allocated];
[ 736, 3232498670 ]
gap> TestBaseChangeHermitian(200, 7); [time,memory_allocated];
[ 8404, 51439492446 ]

After:

gap> TestBaseChangeHermitian(10, 7); [time,memory_allocated];
[ 2, 83971 ]
gap> TestBaseChangeHermitian(100, 7); [time,memory_allocated];
[ 78, 32690638 ]
gap> TestBaseChangeHermitian(200, 7); [time,memory_allocated];
[ 565, 244492918 ]

This is roughly on par with the orthogonal and symplectic cases:

gap> TestBaseChangeOrthogonalBilinear(10, 7); [time,memory_allocated];
[ 13, 1252868 ]
gap> TestBaseChangeOrthogonalBilinear(100, 7); [time,memory_allocated];
[ 96, 40882849 ]
gap> TestBaseChangeOrthogonalBilinear(200, 7); [time,memory_allocated];
[ 659, 305179561 ]

gap> TestBaseChangeSymplectic(10, 7); [time,memory_allocated];
[ 1, 50106 ]
gap> TestBaseChangeSymplectic(100, 7); [time,memory_allocated];
[ 49, 27109193 ]
gap> TestBaseChangeSymplectic(200, 7); [time,memory_allocated];
[ 212, 209951609 ]

Resolves #54 by @danielrademacher

... by performing row/column transformations directly instead of
via matrix multiplication. This also reduces memory allocation and
thus pressure on the garbage collector.

For comparison here are some timings using `TestBaseChangeHermitian`
from `tst/basechange.tst` before and after this patch.

Before:

    gap> TestBaseChangeHermitian(10, 7); [time,memory_allocated];
    [ 1, 408841 ]
    gap> TestBaseChangeHermitian(100, 7); [time,memory_allocated];
    [ 736, 3232498670 ]
    gap> TestBaseChangeHermitian(200, 7); [time,memory_allocated];
    [ 8404, 51439492446 ]

After:

    gap> TestBaseChangeHermitian(10, 7); [time,memory_allocated];
    [ 2, 83971 ]
    gap> TestBaseChangeHermitian(100, 7); [time,memory_allocated];
    [ 78, 32690638 ]
    gap> TestBaseChangeHermitian(200, 7); [time,memory_allocated];
    [ 565, 244492918 ]

This is roughly on par with the orthogonal and symplectic cases:

    gap> TestBaseChangeOrthogonalBilinear(10, 7); [time,memory_allocated];
    [ 13, 1252868 ]
    gap> TestBaseChangeOrthogonalBilinear(100, 7); [time,memory_allocated];
    [ 96, 40882849 ]
    gap> TestBaseChangeOrthogonalBilinear(200, 7); [time,memory_allocated];
    [ 659, 305179561 ]

    gap> TestBaseChangeSymplectic(10, 7); [time,memory_allocated];
    [ 1, 50106 ]
    gap> TestBaseChangeSymplectic(100, 7); [time,memory_allocated];
    [ 49, 27109193 ]
    gap> TestBaseChangeSymplectic(200, 7); [time,memory_allocated];
    [ 212, 209951609 ]
@fingolfin fingolfin merged commit b211911 into master Mar 26, 2024
7 checks passed
@fingolfin fingolfin deleted the mh/faster-BaseChangeHermitian branch March 26, 2024 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function BaseChangeHermitian is slow
1 participant