Skip to content
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

Implement polar_to_cartesian #510

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Aug 9, 2021

This adds sincos360, the rough equivalent of sincosd.
The sincos360 is less accurate than sincosd, but in many cases more accurate than sincos(deg2rad(x)).
Also, while sincosd(Inf) throws a DomainError, sincos360(Inf) returns (NaN, NaN).

This is mainly intended to mitigate precompilation and inlining issues. (cf. issue #496)

This might have to be moved to ColorTypes.jl as well as atan360. (cf. PR #495) Fortunately, moving those methods to ColorTypes.jl seems to maintain the benefits. However, I'm not sure why the problem occurs with Base.

This adds `sincos360`, the rough equivalent of `sincosd`.
The `sincos360` is less accurate than `sincosd`,
but in many cases more accurate than `sincos(deg2rad(x))`.

This is mainly intended to mitigate precompilation and inlining issues.
@codecov
Copy link

codecov bot commented Aug 9, 2021

Codecov Report

Merging #510 (957b257) into master (12549a8) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #510      +/-   ##
==========================================
+ Coverage   95.38%   95.45%   +0.06%     
==========================================
  Files           9        9              
  Lines        1171     1188      +17     
==========================================
+ Hits         1117     1134      +17     
  Misses         54       54              
Impacted Files Coverage Δ
src/algorithms.jl 74.75% <100.00%> (-0.25%) ⬇️
src/conversions.jl 99.38% <100.00%> (ø)
src/utilities.jl 98.46% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12549a8...957b257. Read the comment docs.

@kimikage
Copy link
Collaborator Author

kimikage commented Aug 9, 2021

julia> lchab32 = [LCHab(100*rand(Float32), 100*rand(Float32), 360*rand(Float32)) for y = 1:1000, x = 1:1000];

julia> lchab64 = [LCHab(100*rand(Float64), 100*rand(Float64), 360*rand(Float64)) for y = 1:1000, x = 1:1000];

julia> @btime convert.(Lab{Float32}, $lchab32);
  30.570 ms (2000002 allocations: 41.96 MiB) # before
  12.473 ms (2 allocations: 11.44 MiB) # before (recompiled)
  8.589 ms (2 allocations: 11.44 MiB)  # after

julia> @btime convert.(Lab{Float64}, $lchab64);
  30.995 ms (2000002 allocations: 68.66 MiB) # before
  16.649 ms (2 allocations: 22.89 MiB) # before (recompiled)
  10.462 ms (2 allocations: 22.89 MiB) # after

@kimikage
Copy link
Collaborator Author

kimikage commented Aug 11, 2021

This has almost no impact on functionality (i.e. public APIs), so I will merge this in order to proceed with other tasks.

@kimikage kimikage merged commit 9c55e4a into JuliaGraphics:master Aug 11, 2021
@kimikage kimikage deleted the polar_to_cartesian branch August 11, 2021 06:03
@kimikage kimikage mentioned this pull request Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant