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

Optimize SparsePolynomial arithmetic operations to reduce cloning #951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

This commit optimizes the implementation of arithmetic operations for SparsePolynomial
by eliminating unnecessary cloning in the following methods:

  • AddAssign<&'a Self>
  • AddAssign<(F, &'a Self)>
  • SubAssign<&'a Self>

Instead of using the inefficient approach of cloning the entire polynomials and then
performing operations on the clones, this implementation now uses a more efficient
single-pass algorithm similar to the one used in the Add implementation. This approach
avoids unnecessary memory allocations and copies, which should improve performance
especially for large polynomials.

Fixes TODOs in poly/src/polynomial/univariate/sparse.rs.

@VolodymyrBg VolodymyrBg requested review from a team as code owners March 10, 2025 18:01
@VolodymyrBg VolodymyrBg requested review from z-tech, Pratyush and mmagician and removed request for a team March 10, 2025 18:01
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.

1 participant