File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 7575
7676# Fastest way to check for NaN in an array.
7777# Thanks @mikmore https://discourse.julialang.org/t/fastest-way-to-check-for-inf-or-nan-in-an-array/76954/33?u=milescranmer
78- is_bad_array (x, :: Val{unroll} = Val (16 )) where {unroll} = ! is_good_array (x, Val (unroll))
79- function is_good_array (x:: AbstractArray{T} , :: Val{unroll} = Val (16 )) where {unroll,T}
78+ is_bad_array (x) = ! is_good_array (x)
79+ function is_good_array_mix (x:: AbstractArray{T} ) where {T}
80+ n = length (x)
81+ n == 0 && return true
82+ n <= 256 && return isfinite (sum (xi -> xi * zero (typeof (xi)), x))
83+ return _is_good_array (x, Val (8 ))
84+ end
85+
86+ function _is_good_array (x:: AbstractArray{T} , :: Val{unroll} ) where {T,unroll}
8087 isempty (x) && return true
8188 _zero = zero (T)
8289
You can’t perform that action at this time.
0 commit comments