-
Notifications
You must be signed in to change notification settings - Fork 269
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
Update CHANGELOG: Fix handling of duplicate terms in SparsePolynomial #915
base: master
Are you sure you want to change the base?
Conversation
Hi, thank you for raising this PR
At the least, approach 2 will force callers to become aware of situation 1, which seems to be the focus of the PR. To do this safely, I think it would be more prudent to open a function call with a strongly defined "valid input" and then later deprecate this one so that callers can at their own pace address the potential unexpected results in polynomial operations mentioned. What are thoughts? |
That's a good point. We need to examine how frequently duplicate terms naturally occur. Additionally, we should also consider the issue of "consistency" in the function's behavior. For example, comparing the two polynomial cases below:
In the first case, it seems the function does not handle duplicate terms explicitly, while in the second case, the input is considered valid and behaves as expected. While we would expect both polynomials to behave consistently, the first function appears to lack clear input validation, resulting in inconsistency. To address this issue, do you think introducing a new function call that enforces valid input, followed by a gradual deprecation of the current function, would be sufficient as you suggested? I’d appreciate your thoughts on this. |
I was thinking maybe a function |
Description
In the current implementation of
univariate::SparsePolynomial::from_coefficients_vec
, duplicate terms with the same degree are not explicitly handled. As a result, if multiple terms with the same degree are provided, they remain as separate entries in the resulting sparse polynomial. This can lead to inconsistencies in polynomial operations and unnecessary redundancy.Current Behavior:
Given an input like:
The resulting polynomial contains duplicate terms without merging them.
Proposed Improvement:
Proposed Implementation Example:
Expected Behavior:
For the same input:
The resulting polynomial will now be consistent and free from redundant terms.
Why is this change beneficial?
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the GitHub PR explorer