|
103 | 103 | @inbounds return $expr
|
104 | 104 | end
|
105 | 105 | end
|
106 |
| - |
| 106 | + |
107 | 107 | @generated function _mapreduce(f, op, dims::Colon, nt::NamedTuple{(:init,)},
|
108 |
| - ::Size{S}, a::StaticArray...) where {S} |
| 108 | + ::Size{S}, a::StaticArray...) where {S} |
109 | 109 | expr = :(nt.init)
|
110 | 110 | for i ∈ 1:prod(S)
|
111 | 111 | tmp = [:(a[$j][$i]) for j ∈ 1:length(a)]
|
|
138 | 138 | ::Size{S}, a::StaticArray) where {S,D}
|
139 | 139 | N = length(S)
|
140 | 140 | Snew = ([n==D ? 1 : S[n] for n = 1:N]...,)
|
141 |
| - |
| 141 | + |
142 | 142 | exprs = Array{Expr}(undef, Snew)
|
143 | 143 | itr = [1:n for n ∈ Snew]
|
144 | 144 | for i ∈ Base.product(itr...)
|
|
190 | 190 |
|
191 | 191 | @inline reduce(op, a::StaticArray; dims=:, kw...) = _reduce(op, a, dims, kw.data)
|
192 | 192 |
|
| 193 | +# disambiguation |
| 194 | +reduce(::typeof(vcat), A::StaticArray{<:Tuple,<:AbstractVecOrMat}) = |
| 195 | + Base._typed_vcat(mapreduce(eltype, promote_type, A), A) |
| 196 | +reduce(::typeof(vcat), A::StaticArray{<:Tuple,<:StaticVecOrMatLike}) = |
| 197 | + _reduce(vcat, A, :, NamedTuple()) |
| 198 | + |
| 199 | +reduce(::typeof(hcat), A::StaticArray{<:Tuple,<:AbstractVecOrMat}) = |
| 200 | + Base._typed_hcat(mapreduce(eltype, promote_type, A), A) |
| 201 | +reduce(::typeof(hcat), A::StaticArray{<:Tuple,<:StaticVecOrMatLike}) = |
| 202 | + _reduce(hcat, A, :, NamedTuple()) |
| 203 | + |
193 | 204 | @inline _reduce(op, a::StaticArray, dims, kw::NamedTuple=NamedTuple()) = _mapreduce(identity, op, dims, kw, Size(a), a)
|
194 | 205 |
|
195 | 206 | #######################
|
|
0 commit comments