Registered Member
|
Can triplets be used for acculumation purposes?
For example, I want to replace this line:
with a triplet, however, I need to acculumate the values first, since I don't know all the final values beforehand. coeffRef is very slow for me, even when I try to reserve space. |
Registered Member
|
If you create a Sparse matrix, create a list of triplet and in this list you have 2 triplets pointing at the same coefficient, the two values will add when you use the setFromTriplet method.
Hope this help |
Registered Member
|
Thanks! You're right, I now see a function called sumupDuplicates. Why isn't this acculumation feature documentated? Very useful. I have one more question. If I partially set some values in a sparse matrix, then later, need to set some more, it seems I cannot use Triplets, because the call to setFromTriplets() destroys the matrix. It doesn't overwrite or preserve the old values. Is there a way to use Triplets and not destroy the old matrix values? |
Moderator
|
You can keep your triplet list and extend it or create a new triplet list from the current matrix, append them, and call setFromTriplet. Perhaps we could add an addFromTripplets() members doing exactly this. Feel free to propose a patch (ideally with respective unit test).
|
Registered Member
|
Thanks, those are great suggestions. How does one fill a triplet list from a sparse matrix?
|
Moderator
|
You iterate manually over the non zeros and push_back them to the container. See http://eigen.tuxfamily.org/dox-devel/gr ... tml#title2 for a code-snippet.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]