Performance improvements for trig functions with @fastmath
#750
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.
#745 improved the accuracy of
cis
for quantities in°
(degrees), but this unfortunately comes with a performance hit.Since the
@fastmath
implementation forcis
(and other trig functions) falls back to the normal implementation for some types, this also impacted the performance of@fastmath cis(…)
. Since users of@fastmath
most likely care more about performance and are willing to sacrifice a little numerical accuracy, this PR improves@fastmath
performance forsin
,cos
,tan
,sincos
, andcis
.Performance with
@fastmath
is now at least as good as before #745 (in some cases better), except when usingBigFloat
with°
: Before this PR, the conversion from degrees happened withuconvert
, which for°
→rad
only hasFloat64
precision. It now usesdeg2rad
for that, which is a bit slower but hasBigFloat
precision. I think that this is fine, since you probably wantBigFloat
precision if you are usingBigFloat
.