-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I am working on improving the accuracy of the conversions from Normed
to Float
(#129), and I am interested in scaledual
, which seems to be related with the conversions.
The scaledual
was introduced in d1087f7.
The introduction of
scaledual
is a bit speculative, but it can essentially double the speed of certain operations. It has the following property:bd, ad = scaledual(b, a) b*a == bd*adbut the RHS might be faster (particularly for floating-point
b
and an arraya
of fixed-point numbers).
Originally posted by @timholy in #2 (comment)
However, in the current codebase, I think scaledual
does not have the property above as its test specifies. (a[1] != af8[1]
)
FixedPointNumbers.jl/test/normed.jl
Lines 287 to 294 in da39318
a = rand(UInt8, 10) | |
rfloat = similar(a, Float32) | |
rfixed = similar(rfloat) | |
af8 = reinterpret(N0f8, a) | |
b = 0.5 | |
bd, eld = scaledual(b, af8[1]) | |
@assert b*a[1] == bd*eld |
I do my best for #129, but a slowdown is inevitable. If scaledual
is helpful as a workaround for people who prefer speed over accuracy, I feel relieved.
@timholy , did I not understand that correctly?