This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Delete a column from a sparse matrix

Tags: None
(comma "," separated)
zoharl
Registered Member
Posts
55
Karma
0
OS
Hi,

How do I delete a row or a column from a sparse matrix?

I can construct a new matrix by concatenating two sub matrices, but I think it would be costly:

viewtopic.php?f=74&t=106944
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Do you really need to have it before suppressing it? Perhaps it's better to not insert it or if you want to remove several ones, maybe a using a permutation matrix would do a better job?

If your matrix is column major you can still remove columns efficiently by first pruning the entries with SparseMatrix::prune(...), then play with the internal structure to copy the outer pointers of the remaining columns from j+1 to j (see the outerIndexPtr() function), and finally call conservative resize to remove the last empty one.
zoharl
Registered Member
Posts
55
Karma
0
OS
I'll consider these options; thanks.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]