Skip to content

Commit 846818b

Browse files
committed
use add_fast
1 parent 1639b4d commit 846818b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/JumpProcesses.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ using DataStructures, PoissonRandom, Random, ArrayInterfaceCore
88
using FunctionWrappers, UnPack
99
using Graphs
1010
using SciMLBase: SciMLBase
11+
using Base.FastMath: add_fast
1112

1213
import DiffEqBase: DiscreteCallback, init, solve, solve!, plot_indices, initialize!
1314
import Base: size, getindex, setindex!, length, similar, show, merge!, merge

src/aggregators/direct.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
# calculate the next jump / jump time
5959
function generate_jumps!(p::DirectJumpAggregation, integrator, u, params, t)
6060
p.sum_rate, ttnj = time_to_next_jump(p, u, params, t)
61-
p.next_jump_time = t + ttnj
61+
p.next_jump_time = add_fast(t, ttnj)
6262
@inbounds p.next_jump = searchsortedfirst(p.cur_rates, rand(p.rng) * p.sum_rate)
6363
nothing
6464
end
@@ -77,7 +77,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
7777
idx = get_num_majumps(majumps)
7878
@inbounds for i in 1:idx
7979
new_rate = evalrxrate(u, i, majumps)
80-
cur_rates[i] = new_rate + prev_rate
80+
cur_rates[i] = add_fast(new_rate, prev_rate)
8181
prev_rate = cur_rates[i]
8282
end
8383

@@ -87,7 +87,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
8787
idx += 1
8888
fill_cur_rates(u, params, t, cur_rates, idx, rates...)
8989
@inbounds for i in idx:length(cur_rates)
90-
cur_rates[i] = cur_rates[i] + prev_rate
90+
cur_rates[i] = add_fast(cur_rates[i], prev_rate)
9191
prev_rate = cur_rates[i]
9292
end
9393
end
@@ -119,7 +119,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
119119
idx = get_num_majumps(majumps)
120120
@inbounds for i in 1:idx
121121
new_rate = evalrxrate(u, i, majumps)
122-
cur_rates[i] = new_rate + prev_rate
122+
cur_rates[i] = add_fast(new_rate, prev_rate)
123123
prev_rate = cur_rates[i]
124124
end
125125

@@ -128,7 +128,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
128128
rates = p.rates
129129
@inbounds for i in 1:length(p.rates)
130130
new_rate = rates[i](u, params, t)
131-
cur_rates[idx] = new_rate + prev_rate
131+
cur_rates[idx] = add_fast(new_rate, prev_rate)
132132
prev_rate = cur_rates[idx]
133133
idx += 1
134134
end

0 commit comments

Comments
 (0)