-
Notifications
You must be signed in to change notification settings - Fork 22
Fix overflow errors in division by Normed
/Fixed
#168
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #168 +/- ##
==========================================
+ Coverage 84.68% 84.97% +0.28%
==========================================
Files 2 2
Lines 209 213 +4
==========================================
+ Hits 177 181 +4
Misses 32 32
Continue to review full report at Codecov.
|
BenchmarksScriptusing ColorVectorSpace, ColorTypes, FixedPointNumbers, BenchmarkTools
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 10
N = 1000
g_n0f8 = rand(Gray{N0f8}, N, N);
g_n0f16 = rand(Gray{N0f16}, N, N);
g_f32 = rand(Gray{Float32}, N, N);
g_f64 = rand(Gray{Float64}, N, N);
r_n0f8 = fill(1N0f8, N, N);
r_f64 = fill(1.0, N, N);
r_int = fill(1, N, N);
rgb_n0f8 = rand(RGB{N0f8}, N, N);
rgb_n0f16 = rand(RGB{N0f16}, N, N);
rgb_f32 = rand(RGB{Float32}, N, N);
rgb_f64 = rand(RGB{Float64}, N, N);
for r in (1N0f8, 1.0, 1)
@show r
@btime $g_n0f8 ./ $r;
@btime $g_n0f16 ./ $r;
@btime $g_f32 ./ $r;
@btime $g_f64 ./ $r;
end
for r in (r_n0f8, r_f64, r_int)
@show typeof(r)
@btime $g_n0f8 ./ $r;
@btime $g_n0f16 ./ $r;
@btime $g_f32 ./ $r;
@btime $g_f64 ./ $r;
end
for r in (1N0f8, 1.0, 1)
@show r
@btime $rgb_n0f8 ./ $r;
@btime $rgb_n0f16 ./ $r;
@btime $rgb_f32 ./ $r;
@btime $rgb_f64 ./ $r;
end
for r in (r_n0f8, r_f64, r_int)
@show typeof(r)
@btime $rgb_n0f8 ./ $r;
@btime $rgb_n0f16 ./ $r;
@btime $rgb_f32 ./ $r;
@btime $rgb_f64 ./ $r;
end julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
|
As shown above, this will result in slowdowns in some cases, but if the speed performance is really critical, I don't think you should use the "checked" division. |
This also removes some of the optimization using the reciprocals.
If we find no issues other than slowdowns in the edge cases, I will merge this in this weekend. Then, I'll update PR #153 and release v0.9.5 in the next week. |
Since this is intended to fix a bug, I'll merge this. |
This also removes some of the optimization using the reciprocals.
In the case of
RGB{N0f8}
, the absolute error does not change, but the round-to-even is applied in this PR.Fixes #154