-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
I am using the trees for representing autoregressive models.
This means that the evaluation of the tree cannot be vectorized easily, since the input at an iteration depends on the output of the previous iteration.
The overhead for this seems to be quite high:
function autoregressive_sym()
n = 1000
res = zeros(n)
res[1] = 1.0
for i in 2:n
res[i] = sym_mul([res[i-1],1.01])
end
return res
end
@btime autoregressive_sym() # 109.630 μs
function autoregressive_sym2(sym_mul)
n = 1000
res = zeros(n)
res[1] = 1.0
for i in 2:n
res[i] = sym_mul([res[i-1],1.01])
end
return res
end
@btime autoregressive_sym2(sym_mul) # 97.618 μs
function autoregressive()
n = 1000
res = zeros(n)
res[1] = 1.0
for i in 2:n
res[i] = res[i-1]*1.01
end
return res
end
@btime autoregressive() # 896.484 nsAny advice on how to speed this up, or what kind of alternative datastructure would be appropriate for my case?
Metadata
Metadata
Assignees
Labels
No labels