Skip to content

Commit

Permalink
use add_fast
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsas committed Sep 6, 2022
1 parent 1639b4d commit 846818b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/JumpProcesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using DataStructures, PoissonRandom, Random, ArrayInterfaceCore
using FunctionWrappers, UnPack
using Graphs
using SciMLBase: SciMLBase
using Base.FastMath: add_fast

import DiffEqBase: DiscreteCallback, init, solve, solve!, plot_indices, initialize!
import Base: size, getindex, setindex!, length, similar, show, merge!, merge
Expand Down
10 changes: 5 additions & 5 deletions src/aggregators/direct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end
# calculate the next jump / jump time
function generate_jumps!(p::DirectJumpAggregation, integrator, u, params, t)
p.sum_rate, ttnj = time_to_next_jump(p, u, params, t)
p.next_jump_time = t + ttnj
p.next_jump_time = add_fast(t, ttnj)
@inbounds p.next_jump = searchsortedfirst(p.cur_rates, rand(p.rng) * p.sum_rate)
nothing
end
Expand All @@ -77,7 +77,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
idx = get_num_majumps(majumps)
@inbounds for i in 1:idx
new_rate = evalrxrate(u, i, majumps)
cur_rates[i] = new_rate + prev_rate
cur_rates[i] = add_fast(new_rate, prev_rate)
prev_rate = cur_rates[i]
end

Expand All @@ -87,7 +87,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
idx += 1
fill_cur_rates(u, params, t, cur_rates, idx, rates...)
@inbounds for i in idx:length(cur_rates)
cur_rates[i] = cur_rates[i] + prev_rate
cur_rates[i] = add_fast(cur_rates[i], prev_rate)
prev_rate = cur_rates[i]
end
end
Expand Down Expand Up @@ -119,7 +119,7 @@ function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, param
idx = get_num_majumps(majumps)
@inbounds for i in 1:idx
new_rate = evalrxrate(u, i, majumps)
cur_rates[i] = new_rate + prev_rate
cur_rates[i] = add_fast(new_rate, prev_rate)
prev_rate = cur_rates[i]
end

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

0 comments on commit 846818b

Please sign in to comment.