Skip to content

Commit 9fea76a

Browse files
committed
Merge pull request #11080 from yomichi/fix-cumprod
fixed `cumprod` and `cumprod!`
2 parents 9aacf5e + bb7ad6c commit 9fea76a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ for (f, f!, fp, op) = ((:cumsum, :cumsum!, :cumsum_pairwise!, :+),
15091509
else
15101510
n2 = n >> 1
15111511
s_ = ($fp)(v, c, s, i1, n2)
1512-
s_ = $(op)(s_, ($fp)(v, c, s + s_, i1+n2, n-n2))
1512+
s_ = $(op)(s_, ($fp)(v, c, ($op)(s, s_), i1+n2, n-n2))
15131513
end
15141514
return s_
15151515
end

test/arrayops.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,3 +1092,8 @@ end
10921092
# PR #10164
10931093
@test eltype(Array{Int}) == Int
10941094
@test eltype(Array{Int,1}) == Int
1095+
1096+
# PR #11080
1097+
let x = fill(0.9, 1000)
1098+
@test_approx_eq prod(x) cumprod(x)[end]
1099+
end

0 commit comments

Comments
 (0)