Closed
Description
The current ScalarFunctionIterator
has a best case quadratic and worst case cubic (if the constraints are dense) complexity. If we do a Radix sort by the output_index
then it becomes O(nk) where k is the average number of terms per constraint. For sparse constraints, this is linear complexity. This together with the use of StructsOfArrays.jl
can enable returning a view from scalar_terms_at_index
which reduces allocations. The catch here is if the user/solver expects the terms to be in a certain order and sorting will just confuse everyone. I haven't seen this assumption made anywhere so I am asking if you know otherwise.