Registered Member
|
Is there a way to randomly delete a previous non-zero entry in a sparse matrix. I understand that this is not possible in a simple sparse matrix. How about a dynamic sparse matrix? If I say M.coeffref(i,j)=0, does it delete the (i,j)th element, or simply store it as a zero value. If its the second case, over time the dynamic matrix may become cluttered with these zero values. Is there another way than to manually copy the whole matrix other than the element in question?
|
Moderator
|
You can already do that with all sparse objects (SparseMatrix, DynamicSparseMatrix and SparseVector):
* set all the elements you want to delete to zero: m.coeffRef(i,j) = 0; * call m.prune(0); that will delete all elements x_i,j <= 0 The complexity is O(nnz) regardless of the number of deletion. That's much faster than deleting elements per elements (unless you want to delete a single element). |
Registered Member
|
What if m is a complex type?
|
Moderator
|
Registered users: Bing [Bot], Evergrowing, Google [Bot], rockscient