Path: news.mathworks.com!not-for-mail
From: "Tim Davis" <davis@cise.ufl.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to insert/delete rows in a matrix without copy the rest of matrix
Date: Fri, 16 Nov 2007 02:30:02 +0000 (UTC)
Organization: University of Florida
Lines: 29
Message-ID: <fhivba$3bf$1@fred.mathworks.com>
References: <f87kg3$9ri$1@fred.mathworks.com> <f87ooi$rma$1@fred.mathworks.com> <f87t7h$mje$1@fred.mathworks.com> <f87uil$ggh$1@fred.mathworks.com> <fgv6vr$d7c$1@fred.mathworks.com>
Reply-To: "Tim Davis" <davis@cise.ufl.edu>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1195180202 3439 172.30.248.38 (16 Nov 2007 02:30:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Nov 2007 02:30:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 45902
Xref: news.mathworks.com comp.soft-sys.matlab:437845



"Sterren Latsky" <stez17@hotmail.com> wrote in message
<fgv6vr$d7c$1@fred.mathworks.com>...
> Hi guys. I have a similar query.
> 
> > MATLAB stores a dense matrix in an m-by-n array, in column
> major form, without pointers.  Using pointers would cause a
> dreadful slowdown in any matrix computations other than
> > 
> > a (:,1) = [ ] ;
> 
> I want to delete a row and column in an arbitrary position
> in a very large matrix (up to 2000 rows / columns). The
> matrix is a sparse matrix, so I am assuming it uses pointers
> to non zero elements in rows and columns.
> Theoretically, if it does this, there must be an easier way
> to delete a row or column. Does anyone know how?
> 
> Thanks,
> 
> Sterren

Check out Loren's March 1st blog for details of how MATLAB
stores its sparse matrices.

MATLAB stores its sparse matrices by column.  Deleting a row
or column requires a complete copy of the matrix, even if
you were to do it in a C mexFunction.  The data structure is
designed for fast whole-matrix operations, not for the (less
frequently used) a(:,1)=[] kind of operation.