diff --git a/src/generic.jl b/src/generic.jl index 2b03b249..de37f081 100644 --- a/src/generic.jl +++ b/src/generic.jl @@ -1358,8 +1358,15 @@ ishermitian(x::Number) = (x == conj(x)) _iszero(V) = iszero(V) # A Base.FastContiguousSubArray view of a StridedArray FastContiguousSubArrayStrided{T,N,P<:StridedArray,I<:Tuple{AbstractUnitRange, Vararg{Any}}} = Base.SubArray{T,N,P,I,true} -# using mapreduce instead of all permits vectorization -_iszero(V::FastContiguousSubArrayStrided) = mapreduce(iszero, &, V, init=true) +# Reducing over the entire array instead of calling `all` within `iszero` permits vectorization +# The loop is equivalent to a mapreduce, but is faster to compile +function _iszero(V::FastContiguousSubArrayStrided) + ret = true + for i in eachindex(V) + ret &= iszero(@inbounds V[i]) + end + ret +end """ istriu(A::AbstractMatrix, k::Integer = 0) -> Bool