Skip to content

Commit 06689d4

Browse files
authored
Merge pull request #85 from umgrmxsvaf/fix-prod
Fix definition of prod()
2 parents 261939b + 491c481 commit 06689d4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/mapreduce.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ end
9292

9393
# These are all similar in Base but not @inline'd
9494
@inline sum{T}(a::StaticArray{T}) = reduce(+, zero(T), a)
95-
@inline prod{T}(a::StaticArray{T}) = reduce(+, zero(T), a)
95+
@inline prod{T}(a::StaticArray{T}) = reduce(*, one(T), a)
9696
@inline count(a::StaticArray{Bool}) = reduce(+, 0, a)
9797
@inline all(a::StaticArray{Bool}) = reduce(&, true, a) # non-branching versions
9898
@inline any(a::StaticArray{Bool}) = reduce(|, false, a) # (benchmarking needed)

test/mapreduce.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
v1 = @SVector [2,4,6,8]
2121
@test reduce(+, v1) === 20
2222
@test reduce(+, 0, v1) === 20
23+
@test sum(v1) === 20
24+
@test prod(v1) === 384
2325
end
2426

2527
@testset "mapreduce" begin

0 commit comments

Comments
 (0)