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.
This PR changes
PermutationGroup.product_table
to make it more memory-friendly.The upstream version calculates the permutations corresponding to every g^-1 h in one numpy-array-indexing command. This generates a matrix of N_site * N_symm^2 integers, which quickly gets obscenely large, leading to memory errors. (As a modest example, a 16×16 square lattice has N_site=256 and N_symm=2048, leading to a size-1,073,741,824 array). It's even worse as the array is then recreated as a list of
HashableArray
s.Instead, I split this calculation by rows of the product table. This makes the code quite transparent, memory-friendly, and I don't expect it to introduce a large time overhead. (There is a new loop over the rows, but we've already had loops that cycle through every entry of the product table, so I'm not too worried. In fact, one of those is gone now.) It has already been a very slow method, but there doesn't seem to be a way to make it significantly more performant.
The output of the function doesn't change.