You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When comparing a power gain Gain{L, :p} and a root-power gain Gain{L, :rp} with the same L, they get promoted to Gain{L, :?} without changing their numerical values. This breaks the transitivity of ==:
julia> a =Gain{Unitful.Decibel, :rp}(20) # 20 dB (root-power) == factor 1020 dB
julia> b =Gain{Unitful.Decibel, :p}(20) # 20 dB (power) == factor 10020 dB
julia> c =Gain{Unitful.Bel, :p}(2) # 2 B (power) == factor 1002 B
julia> a == b == c
true
julia> a == c
false
Comparison involving numbers is intransitive as well:
julia> a =Gain{Unitful.Decibel, :rp}(20) # 20 dB (root-power) == factor 1020 dB
julia> b =Gain{Unitful.Decibel, :p}(10) # 10 dB (power) == factor 1010 dB
julia> c =Gain{Unitful.Decibel, :p}(20) # 20 dB (power) == factor 10020 dB
julia> a ==10== b
true
julia> a == b
false
julia>10== a == c
true
julia>10== c
false
To obtain a consistent behavior for ==, the promotion rules for Gain would have to be changed. It might be difficult to figure out a set of rules that is both practical and consistent, unless one gets rid of Gain{L, :?} altogether.
The text was updated successfully, but these errors were encountered:
Can someone explain why Unitful stores :p or :rp?
Why is it we aren't just storing a logarithmic value along with linear units and logarithmic multiplier it was calculated with, and converting to power or root-power when requested?
When comparing a power gain
Gain{L, :p}
and a root-power gainGain{L, :rp}
with the sameL
, they get promoted toGain{L, :?}
without changing their numerical values. This breaks the transitivity of==
:Comparison involving numbers is intransitive as well:
To obtain a consistent behavior for
==
, the promotion rules forGain
would have to be changed. It might be difficult to figure out a set of rules that is both practical and consistent, unless one gets rid ofGain{L, :?}
altogether.The text was updated successfully, but these errors were encountered: