Fix complexity of getindex(::ScalarFunctionIterator, i)#1257
Conversation
|
This does not fix #418 completely. |
|
Okay. I've rewritten all the |
|
Creating a vector of vector will be much slower than a single vector as suggested in #1257 (comment). next = Vector{Int}(undef, length(terms))
last = zeros(Int, output_dimension)
for i in eachindex(terms)
j = term[i].output_index
if !iszero(last[j])
next[last[j]] = i
end
last[j] = i
end
for j in eachindex(last)
if !iszero(last[j])
next[last[j]] = 0
end
endthen you store |
|
This assumes that the function is canonicalized? This fixes the existing performance problem. I don't know if it's worth checking for canonical and adding both look-up ways. It gets rid of the current bottleneck, we can revisit if it becomes a problem in future. |
No |
|
@blegat's way is faster: julia> @time main(300);
0.129429 seconds (2.69 k allocations: 123.049 MiB, 19.75% gc time) |
Updated times for most recent commit
Before
After
Code
Closes #1137
Closes #418