|
58 | 58 | # calculate the next jump / jump time |
59 | 59 | function generate_jumps!(p::DirectJumpAggregation, integrator, u, params, t) |
60 | 60 | p.sum_rate, ttnj = time_to_next_jump(p, u, params, t) |
61 | | - @fastmath p.next_jump_time = t + ttnj |
| 61 | + p.next_jump_time = add_fast(t, ttnj) |
62 | 62 | @inbounds p.next_jump = searchsortedfirst(p.cur_rates, rand(p.rng) * p.sum_rate) |
63 | 63 | nothing |
64 | 64 | end |
65 | 65 |
|
66 | 66 | ######################## SSA specific helper routines ######################## |
67 | 67 |
|
68 | 68 | # tuple-based constant jumps |
69 | | -@fastmath function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, params, |
70 | | - t) where {T, S, F1 <: Tuple, F2 <: Tuple, RNG} |
| 69 | +function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, params, |
| 70 | + t) where {T, S, F1 <: Tuple, F2 <: Tuple, RNG} |
71 | 71 | prev_rate = zero(t) |
72 | 72 | new_rate = zero(t) |
73 | 73 | cur_rates = p.cur_rates |
|
77 | 77 | idx = get_num_majumps(majumps) |
78 | 78 | @inbounds for i in 1:idx |
79 | 79 | new_rate = evalrxrate(u, i, majumps) |
80 | | - cur_rates[i] = new_rate + prev_rate |
| 80 | + cur_rates[i] = add_fast(new_rate, prev_rate) |
81 | 81 | prev_rate = cur_rates[i] |
82 | 82 | end |
83 | 83 |
|
|
87 | 87 | idx += 1 |
88 | 88 | fill_cur_rates(u, params, t, cur_rates, idx, rates...) |
89 | 89 | @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) |
91 | 91 | prev_rate = cur_rates[i] |
92 | 92 | end |
93 | 93 | end |
|
108 | 108 | end |
109 | 109 |
|
110 | 110 | # function wrapper-based constant jumps |
111 | | -@fastmath function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, params, |
112 | | - t) where {T, S, F1 <: AbstractArray, |
113 | | - F2 <: AbstractArray, RNG} |
| 111 | +function time_to_next_jump(p::DirectJumpAggregation{T, S, F1, F2, RNG}, u, params, |
| 112 | + t) where {T, S, F1 <: AbstractArray, F2 <: AbstractArray, RNG} |
114 | 113 | prev_rate = zero(t) |
115 | 114 | new_rate = zero(t) |
116 | 115 | cur_rates = p.cur_rates |
|
120 | 119 | idx = get_num_majumps(majumps) |
121 | 120 | @inbounds for i in 1:idx |
122 | 121 | new_rate = evalrxrate(u, i, majumps) |
123 | | - cur_rates[i] = new_rate + prev_rate |
| 122 | + cur_rates[i] = add_fast(new_rate, prev_rate) |
124 | 123 | prev_rate = cur_rates[i] |
125 | 124 | end |
126 | 125 |
|
|
129 | 128 | rates = p.rates |
130 | 129 | @inbounds for i in 1:length(p.rates) |
131 | 130 | new_rate = rates[i](u, params, t) |
132 | | - cur_rates[idx] = new_rate + prev_rate |
| 131 | + cur_rates[idx] = add_fast(new_rate, prev_rate) |
133 | 132 | prev_rate = cur_rates[idx] |
134 | 133 | idx += 1 |
135 | 134 | end |
|
0 commit comments