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 ns
Any advice on how to speed this up, or what kind of alternative datastructure would be appropriate for my case?
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:
Any advice on how to speed this up, or what kind of alternative datastructure would be appropriate for my case?