Open AWildSugar opened 3 years ago
Hey, thank you!
I can implement something like this. I think that your algorithm is roughly the best we can hope for since this is not a natural operation for sparse binary matrices.
However, out of curiosity, can you just add a second matrix with the value 1 at the positions you want to change to do the modifications? This is the way I am doing it right now in other projects using this one.
If this is not possible for you, I will also implement a constructor taking into account the capacity of the matrix. That is, the expected maximum of ones it will ever contain. That way, you won't have to pay for vector resizing to make room for new elements.
Ohh that's how you're doing it, makes sense. That does work for me, though I think it might still be useful, or at least nice, to have a function that will set a position to value as opposed to toggling a set value.
Also just a suggestion: maybe add an example of constructing a matrix by adding unit matrices to the readme, just to help any future confused people.
Thanks!
Yes, I don't have much time for this in the next few days, but I will give it a shot next week.
This is now implemented. This required version 0.6.0 since I also implemented a wrapper for binary numbers. Normally, this should be mostly transparent because it implements From<u8>
and vice-versa.
What you want is the emplace_at method.
Cool, thanks
Hey nice package. I don't know if I'm missing something obvious but for my use case it'd be super helpful to have a simple function to update individual entries in place on a mutable matrix.
I'm coming from C++ and I have a simple sparse matrix there I use sometimes, I copied the logic over to rust. What do you think about something like this?
`
`
With a little test:
`
`
Obviously not super efficient but honestly not too bad either, I couldn't see an obvious way to construct it row by row or anything similar, anyways this atleast just gets you coding.