Faster `abs`-like function for rough magnitude comparisons.
`fastabs` is equivalent to `abs(x)` for most `x`,
but for complex `x` it computes `abs(real(x))+abs(imag(x))` rather
than requiring `hypot`.
fastabs(x::Number) = abs(x)
fastabs(z::Complex) = abs(real(z)) + abs(imag(z))
What is this function used for?
I thought this was a bug and opened an issue and was told that there is some “intended behaviour”… what is the used case? It’s confusing when it says
Faster abs-like function for rough magnitude comparisons.
while 5 and 7 seems to be a pretty big difference…
The use case here is for special functions where you want to do something different for big and small inputs. Specifically, fastabs will be off by a maximum factor of sqrt(2), so it’s very useful when a function needs to do something different for small inputs.