We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
is_good_array
1 parent f1aad67 commit fa05fd0Copy full SHA for fa05fd0
src/Utils.jl
@@ -76,13 +76,14 @@ end
76
# Fastest way to check for NaN in an array.
77
# 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) = !is_good_array(x)
79
-function is_good_array(x::AbstractArray{T}) where {T}
+function is_good_array(x::AbstractArray{T}) where {T<:Union{Float32,Float64}}
80
cumulator = zero(T)
81
@turbo safe = false for i in eachindex(x)
82
cumulator += x[i] * 0
83
end
84
return cumulator == 0
85
86
+is_good_array(x) = sum(xi -> xi * zero(xi), x) == zero(eltype(x))
87
88
isgood(x::T) where {T<:Number} = !(isnan(x) || !isfinite(x))
89
isgood(x) = true
0 commit comments