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.
2 parents 261939b + 491c481 commit 06689d4Copy full SHA for 06689d4
src/mapreduce.jl
@@ -92,7 +92,7 @@ end
92
93
# These are all similar in Base but not @inline'd
94
@inline sum{T}(a::StaticArray{T}) = reduce(+, zero(T), a)
95
-@inline prod{T}(a::StaticArray{T}) = reduce(+, zero(T), a)
+@inline prod{T}(a::StaticArray{T}) = reduce(*, one(T), a)
96
@inline count(a::StaticArray{Bool}) = reduce(+, 0, a)
97
@inline all(a::StaticArray{Bool}) = reduce(&, true, a) # non-branching versions
98
@inline any(a::StaticArray{Bool}) = reduce(|, false, a) # (benchmarking needed)
test/mapreduce.jl
@@ -20,6 +20,8 @@
20
v1 = @SVector [2,4,6,8]
21
@test reduce(+, v1) === 20
22
@test reduce(+, 0, v1) === 20
23
+ @test sum(v1) === 20
24
+ @test prod(v1) === 384
25
end
26
27
@testset "mapreduce" begin
0 commit comments