Improvements and Fixes in rootsur.lib #1204
Merged
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.
Variable Reference Correction in Loop:
I modified a for loop to correct the variable reference. Previously, the loop iterated over p[i], but it has been changed to monic[i] to ensure we are accessing the correct element. This change is crucial, especially for handling polynomials with leading coefficients significantly less than 1, such as in cases like p = (x^3)/10-x-1. The previous code could lead to inaccuracies in such scenarios.
Proper Calculation of nroots in sturm Routine:
The nroots variable was not initialized, potentially leading to incorrect values in calculations. I have kept the same structure but ensured that the calculation now reflects the correct value.
Removal of Unused Static Routines:
I removed the static routines search and D, which were not used elsewhere in the code.
Removal of searchnot Routine Function:
Since the searchnot function was only used by the D routine, which has been removed, I also chose to remove searchnot to simplify the code.
Cleanup of Old Code Comments:
I deleted some comments of unused code in the sturmha routine. These comments appear to be remnants of older versions, and their removal makes the code cleaner and easier to understand.
I believe these changes contribute to the efficiency, clarity, and maintainability of the code in rootsur.lib. I am available to discuss these modifications further and to make adjustments as needed.