-
Notifications
You must be signed in to change notification settings - Fork 47
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
Safety implications of unsorted indices #232
Comments
As you pointed out, there are two separate concerns here:
Here are the possible ways forward in my opinion, including the options you mentioned:
Do you see other alternatives? |
The usage of The sorted indices are very nice for so many algorithms, dot-product, kronecker product, arrays from a matrix slice*, more efficient use of cache. I think option 2 would be preferable, as most algorithms that works on sorted indices will probably also produce sorted indices. We can avoid the runtime checks by allowing an In #35 you mention the need for unsorted indices. Has this changed? [*]: If we introduce a new slicetype with an offset field |
Yes I think I agree, the sorted indices is a very convenient property in many algorithms. The
There are some decompositions that can only produce unsorted indices as far as I know. But the case is quite rare, and they don't need that many operations, so when these decompositions get implemented we can define a limited sparse matrix type with unsorted indices to help in these decompositions. |
It seems to me like some algorithms requiring sorted indices and some not could be handled with a private
Additionally, a method to sort if needed would be useful. Possibly |
Just for reference the C++ lib eigen has similar questions: https://gitlab.com/libeigen/eigen/-/issues/694#note_254554694 |
This is a discussion issue for how to handle unsorted indices in arrays and matrices. The situation as it is today is relaxed, we try to avoid it, having unsorted indices won't cause safety issues, but might produce unexpected results/panics in some algorithms.
The primary motivation for bringing this up is to allow/disallow future optimisations to take advantage of the sorted property, and how the library should behave when these invariants are broken.
Should we formalise this behaviour and document it or should we disallow creation of unsorted structures?
Ref #231, #35, #16, #136
The text was updated successfully, but these errors were encountered: