Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

delete some rows in Sparse Matrix

859 views
Skip to first unread message

lifei zhang

unread,
Jan 30, 2002, 4:06:10 AM1/30/02
to
HI.


Anyone can tell me how I efficiently delete some rows in sparse
matrix?
 
I found manipulation for full matrix and sparse is very different.
for example--deleting rows in matrix.


a=eye(1000,1000);
b=[2,3,5]';
a(b,:)=[]; %speed is fast.


c=speye(1000,1000);
b=[2,3,5]';
c(b,:)=[]; %speed is very low.


This is only for example. How can I get fast speed for sparse matrix?


thanks a lot.

Penny Anderson

unread,
Jan 30, 2002, 10:39:33 AM1/30/02
to
Row operations are extremely slow in sparse matrices because they are stored in compressed column format.

Indeed, even deleting the early columns is slow because all the following columns need to be shifted along in the data structure.

You might be better off
(1) transposing your matrix first, if you are going to be doing alot of row deletions. The column deletions may be faster.
(2) using find and then working with the i,j, and s vectors returned instead.
(3) Just use full. sparse is useful for much larger matrices (with mostly nonzeros).

Penny Anderson
The MathWorks, Inc.

"lifei zhang" <shifei...@yahoo.com> wrote in message news:eea9d...@WebX.raydaftYaTP...

0 new messages