-
Couldn't load subscription status.
- Fork 122
Open
Labels
logarithmiclogarithmic scales (decibels, nepers, …)logarithmic scales (decibels, nepers, …)
Description
Multiplication between Gains is defined to be the same as addition:
julia> 2dB + 5dB
7 dB
julia> 2dB * 5dB
7 dB
I think this is somewhat problematic. Multiplication is supposed to be commutative/associative, which this is not:
julia> 2 * 5 * (dB * dB)
ERROR: ArgumentError: cannot multiply logarithmic units together.
Stacktrace:
[1] *(#unused#::Unitful.MixedUnits{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, T} where T<:Real, Unitful.FreeUnits{(), NoDims, nothing}}, #unused#::Unitful.MixedUnits{Gain{Unitful.LogInfo{:Decibel, 10, 10}, :?, T} where T<:Real, Unitful.FreeUnits{(), NoDims, nothing}})
@ Unitful ~/.julia/packages/Unitful/0oqX5/src/logarithm.jl:102
[2] top-level scope
@ REPL[25]:1
I can see why this is convenient, but the * generic function really is supposed to behave like multiplication. If you're using a logarithmic scale, use the addition functions. @sostock you seem to have been the last person to touch this code extensively, thoughts?
Metadata
Metadata
Assignees
Labels
logarithmiclogarithmic scales (decibels, nepers, …)logarithmic scales (decibels, nepers, …)