diff --git a/src/abstractarray.jl b/src/abstractarray.jl index b7806fd6..91ad7375 100644 --- a/src/abstractarray.jl +++ b/src/abstractarray.jl @@ -13,7 +13,8 @@ Base.axes(s::StaticArrayLike) = _axes(Size(s)) map(SOneTo, sizes) end -Base.eachindex(::IndexLinear, a::StaticArray) = SOneTo(length(a)) +const _StaticArrayRankGE2 = Union{(StaticArray{<:Tuple, T, N} where T for N in 2:32)...} +Base.eachindex(::IndexLinear, a::_StaticArrayRankGE2) = SOneTo(length(a)) # Base.strides is intentionally not defined for SArray, see PR #658 for discussion Base.strides(a::MArray) = Base.size_to_strides(1, size(a)...) diff --git a/src/mapreduce.jl b/src/mapreduce.jl index 899ec2ab..e264ada5 100644 --- a/src/mapreduce.jl +++ b/src/mapreduce.jl @@ -299,13 +299,10 @@ reduce(::typeof(hcat), A::StaticArray{<:Tuple,<:StaticVecOrMatLike}) = @inline prod(f::Union{Function, Type}, a::StaticArray{<:Tuple,T}; dims::D=:, init=_InitialValue()) where {D, T} = _mapreduce(f, *, dims, init, Size(a), a) @inline count(a::StaticArray{<:Tuple,Bool}; dims::D=:, init=0) where {D} = _reduce(+, a, dims, init) -@inline count(f, a::StaticArray; dims::D=:, init=0) where {D} = _mapreduce(x->f(x)::Bool, +, dims, init, Size(a), a) -@inline all(a::StaticArray{<:Tuple,Bool}; dims::D=:) where {D} = _reduce(&, a, dims, true) # non-branching versions -@inline all(f::Function, a::StaticArray; dims::D=:) where {D} = _mapreduce(x->f(x)::Bool, &, dims, true, Size(a), a) +@inline all(a::StaticArray{<:Tuple,Bool}; dims::D=:) where {D} = _reduce(&, a, dims, true) -@inline any(a::StaticArray{<:Tuple,Bool}; dims::D=:) where {D} = _reduce(|, a, dims, false) # (benchmarking needed) -@inline any(f::Function, a::StaticArray; dims::D=:) where {D} = _mapreduce(x->f(x)::Bool, |, dims, false, Size(a), a) # (benchmarking needed) +@inline any(a::StaticArray{<:Tuple,Bool}; dims::D=:) where {D} = _reduce(|, a, dims, false) @inline Base.in(x, a::StaticArray) = _mapreduce(==(x), |, :, false, Size(a), a) diff --git a/src/util.jl b/src/util.jl index 6079c36d..47145c99 100644 --- a/src/util.jl +++ b/src/util.jl @@ -49,7 +49,7 @@ end size(a::TrivialView) = size(a.a) getindex(a::TrivialView, inds...) = getindex(a.a, inds...) -setindex!(a::TrivialView, inds...) = (setindex!(a.a, inds...); a) +setindex!(a::TrivialView, v, inds...) = (setindex!(a.a, v, inds...); a) Base.IndexStyle(::Type{<:TrivialView{A}}) where {A} = IndexStyle(A) TrivialView(a::AbstractArray{T,N}) where {T,N} = TrivialView{typeof(a),T,N}(a)