-
Notifications
You must be signed in to change notification settings - Fork 6
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
Polynomial performance improvements #142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One of the benefits of this is that it allows construction of fixed size polynomials without having to allocate a vector. It does however break backwards compatability because previously ArbPoly((1, 2)) would give the same polynomial as ArbPoly(Arb((1, 2))) but now it instead gives ArbPoly([1, 2]).
This is a common case, in particular when computing Taylor series since you then often want to construct series on the form ArbSeries((x, 1)). This specialised constructor removes the drawback of having a tuple with elements of different types. In the case ArbSeries((x::Arb, 1)) it reduces the number of allocations from 5 to 2 compared to the generic implementation.
This is already taken care of by the underlying constructor so doesn't have to be done again.
kalmarek
approved these changes
Nov 22, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
Probably we should also support a vararg constructor as well, but this may wait for another time.
Joel-Dahne
force-pushed
the
enh/poly-improvements
branch
from
November 24, 2021 23:56
a9035d8
to
23695ca
Compare
I took the liberty of adding the bump of |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a number of minor improvements to polynomials, mostly related to construction.
The main goal is to improve the performance when constructing
ArbSeries
with of the formArbSeries([x, 1])
, mostly by reducing the number of allocations. It makes the following changes related to thisArbSeries((x, 1))
works. This change is breaking in the sense that previously passing a two-tuple(a, b)
would set the first coefficient toArb((a, b))
, i.e. the interval froma
tob
. This could now be done withArbSeries(((x, 1),))
.setindex!
work well withInt
usingarb_poly_set_coeff_si
. Previously this would convert the input toArb
before setting the coefficient.fit_length!
in one place in the construction for series, this is already done by the underlying constructor so doesn't have to be done again.Before the above changes the fastest way to construct an
ArbSeries
with coefficients[x, 1]
was withArbSeries([x, one(x)])
, now it isArbSeries((x, 1))
, comparing the performance we see that the later is much faster and (more importantly) allocates a lot less.In addition to the above I added
@inbounds
in one place where it was missing and better documentation forArblib.ref
for polynomials.Since supporting constructing polynomials from tuples is a breaking change I have pushed the version to
0.6.0
.