Optimize exterior algebra basis #39879
Open
+287
−102
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.
Optimized Basis Computation for Exterior Algebras
This PR introduces an optimized implementation of the exterior_algebra_basis function using divide-and-conquer and memoization. It maintains mathematical correctness while offering significant speedups (1.2x–4.1x) across a variety of inputs.
Summary of Changes
Applied divide-and-conquer by recursively splitting the degree vector.
Returned results in a sorted, consistent format.
Preserved interface and compatibility with original code.
Performance Results
All results match the original implementation.
Benchmarking
A commented-out benchmarking script is included at the bottom of the implementation file. It compares performance and correctness against the original implementation across multiple test cases. This can be uncommented and run to verify the reported speedups and output consistency.
Checklist