@@ -93,7 +93,7 @@ times ts (sorted), with values timeseries and derivatives ks
93
93
end
94
94
@inbounds for j in idx
95
95
t = tvals[j]
96
- i = findfirst ((x) -> tdir * x >= tdir * t, @view ts[i: end ])+ i- 1 # It's in the interval ts[i-1] to ts[i]
96
+ i = searchsortedfirst ( @view ( ts[i: end ]),t,rev = tdir < 0 )+ i- 1 # It's in the interval ts[i-1] to ts[i]
97
97
if ts[i] == t
98
98
if idxs == nothing
99
99
vals[j] = timeseries[i]
@@ -129,7 +129,7 @@ times ts (sorted), with values timeseries and derivatives ks
129
129
@inline function sde_interpolation (tval:: Number ,id,idxs,deriv)
130
130
@unpack ts,timeseries = id
131
131
tdir = sign (ts[end ]- ts[1 ])
132
- i = findfirst ((x) -> tdir * x >= tdir * tval,ts ) # It's in the interval ts[i-1] to ts[i]
132
+ @inbounds i = searchsortedfirst (ts, tval,rev = tdir < 0 ) # It's in the interval ts[i-1] to ts[i]
133
133
@inbounds if ts[i] == tval
134
134
if idxs == nothing
135
135
val = timeseries[i]
158
158
@inline function sde_interpolation! (out,tval:: Number ,id,idxs,deriv)
159
159
@unpack ts,timeseries = id
160
160
tdir = sign (ts[end ]- ts[1 ])
161
- @inbounds i = findfirst ((x) -> tdir * x >= tdir * tval,@view ts[notsaveat_idxs] ) # It's in the interval ts[i-1] to ts[i]
161
+ @inbounds i = searchsortedfirst (ts, tval,rev = tdir < 0 ) # It's in the interval ts[i-1] to ts[i]
162
162
@inbounds if ts[i] == tval
163
163
if idxs == nothing
164
164
copy! (out,timeseries[i])
190
190
i = 2 # Start the search thinking it's between ts[1] and ts[2]
191
191
@inbounds for j in idx
192
192
t = tvals[j]
193
- i = findfirst ((x) -> tdir * x >= tdir * t, ts[i: end ])+ i- 1 # It's in the interval ts[i-1] to ts[i]
193
+ i = searchsortedfirst ( @view ( ts[i: end ]),t,rev = tdir < 0 )+ i- 1 # It's in the interval ts[i-1] to ts[i]
194
194
if ts[i] == t
195
195
if idxs == nothing
196
196
vals[j] = timeseries[i]
0 commit comments