Skip to content

Commit 0b0a61a

Browse files
committed
Remove sum (does pairwise addition?)
1 parent 2363f8f commit 0b0a61a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/gamma_inc.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,11 @@ function gamma_inc_taylor(a::Float64, x::Float64, ind::Integer)
444444
sm += t
445445
end
446446

447-
# Sum terms from small to large
448-
sm += sum(reverse!(@view wk[1:i]))
447+
# sum terms from small to large
448+
for v @view wk[i:-1:1]
449+
sm += v
450+
end
451+
449452
p = (rgammax(a, x) / a) * (1.0 + sm)
450453
return (p, 1.0 - p)
451454
end
@@ -486,8 +489,11 @@ function gamma_inc_asym(a::Float64, x::Float64, ind::Integer)
486489
sm += t
487490
end
488491

489-
# Sum terms from small to large
490-
sm += sum(reverse!(@view wk[1:i]))
492+
# sum terms from small to large
493+
for v @view wk[i:-1:1]
494+
sm += v
495+
end
496+
491497
q = (rgammax(a, x) / x) * (1.0 + sm)
492498
return (1.0 - q, q)
493499
end

0 commit comments

Comments
 (0)