Fastest way to check for Inf or NaN in an array?

This does not work.

julia> x = randn(1000); x[50] = NaN;

julia> is_good_array_fastmath(x)
true

The @fastmath includes the “ninf”, “nnan”, and “nsz” fastmath flags, so x*0 can be replaced with 0.0 and most of the work can be elided. It only checks the tail of the array.

4 Likes