Fix computation of norms of AbstractArray{<:Measurement}
#120
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Julia v1.9 we currently have
This is due to the fact that the Inf-norm has now zero value with non-zero
uncertainty, but some checks in the computation of the p-norms assume that if a
number is non-zero then dividing by it wouldn't result in an overflow (or NaN).
However this is not true for numbers of the type
0 ± u
withu != 0
, whicharen't the additive identity element but nevertheless would result in
overflow (or NaN) when dividing by them.
While a proper solution would be to have in the language two distinct traits for
"additive identity element" (which is already represented by
iszero
) and"non-overflowing denominator" (which we currently miss, but I also don't know
any language implementing this trait), Daniel Wennberg pointed out that the
Inf-norm of an array should always have zero-uncertainty if the value is also
zero, thus resulting in a proper "additive identity element" zero which would
satisfy the assumptions in the computations of the other p-norms. This change
defines the method
LinearAlgebra.normInf(::AbstractArray{<:Measurement})
toalways force zero uncertainty in the Inf-norm when the value is also zero.
Thanks a lot @danielwe for the help and the in-depth discussion about how to address the problem.