-
Notifications
You must be signed in to change notification settings - Fork 92
Fix complexity of getindex(::ScalarFunctionIterator, i) #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
end then 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