Reduce the allocations of gausslegendre for moderate n and add a flag for Aqua #137
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.
Hi,
Reducing allocations:
The Newton's iteration for
gausslegendre
uses only part of the information returned by the asymptotic formulaasy
. I moved the relevant code fromasy
to a new functionleg_initial_guess
to reduce allocations and improve performance. I have also reused the temporary vectorsPP1
andPP2
. This reduces allocations inrec(n)
from 22 to 9.Example 1
Current Master:
With this PR:
This performance improvement is less pronounced for higher values of
n
since the Newton iteration is O(n^2).Example 2
Current Master:
With this PR:
CI and Aqua
Currently the tests are not passing since
actions/cache@v1
is deprecated, andAqua.jl
is indicating that the packages inextras
do not have a compat entry. I have upgraded theactions/cache
version, and added a flag toAqua
to ignore packages in extra. All tests pass now.Best,
Haroun