You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia>functionfindNaNmax(x::AbstractArray{T}) where T<:AbstractFloat
result =convert(eltype(x), NaN)
indmax =0for (i,v) inenumerate(x)
if!isnan(v)
if (isnan(result) || v > result)
result = v
indmax = i
endendendreturn (indmax,result)
end
findNaNmax (generic function with 1 method)
julia> Y1 =rand(10_000_000);
julia> Y3 =ifelse.(rand(length(Y1)) .<0.9, Y1, NaN);
julia>@btime NaNMath.maximum(Y3);
21.103 ms (1 allocation:16 bytes)
julia>@btimefindNaNmax(Y3);
23.513 ms (1 allocation:32 bytes)
?
or maybe even
functionfindNaNmax2(x::AbstractArray{T}) where T<:AbstractFloat
result =convert(eltype(x), NaN)
indmax =0@inbounds@simdfor i ineachindex(x)
v = x[i]
if!isnan(v)
if (isnan(result) || v > result)
result = v
indmax = i
endendendreturn (indmax,result)
end
julia>@btimefindNaNmax2(Y3);
22.294 ms (1 allocation:32 bytes)
The text was updated successfully, but these errors were encountered:
how do people feel about a PR with
?
or maybe even
The text was updated successfully, but these errors were encountered: