Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: size(sparse matrix) > size(full matrix)
Date: Thu, 17 Sep 2009 09:22:01 -0400
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <h8td5b$bld$1@fred.mathworks.com>
References: <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com> <a56978d9-99f2-4ff6-8073-a77ab61bb6d6@o21g2000vbl.googlegroups.com> <h8t5eb$anh$1@fred.mathworks.com> <3f28c1c1-af9b-458a-a802-25e66f1bc1bb@p15g2000vbl.googlegroups.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1253193707 11949 172.31.44.65 (17 Sep 2009 13:21:47 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Sep 2009 13:21:47 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
Xref: news.mathworks.com comp.soft-sys.matlab:571072



"arun" <aragorn168b@gmail.com> wrote in message 
news:3f28c1c1-af9b-458a-a802-25e66f1bc1bb@p15g2000vbl.googlegroups.com...
> On Sep 17, 1:10 pm, "Bruno Luong" <b.lu...@fogale.findmycountry>
wrote:
> > Rune Allnor <all...@tele.ntnu.no> wrote in message 
> > <a56978d9-99f2-4ff6-8073-a77ab61bb...@o21g2000vbl.googlegroups.com>...
> >
> > > Sparse matrices are not used to gain speed, but to save
> > > space.
> >
> > Wrong, many linear algebra algorithms are designed to gain speed with 
> > sparse matrix since Matrix-vector product is much faster than for full 
> > matrix. That lead to the class of iterative method (gradient conjugate, 
> > GMRES, Lanczos, etc...) that is suitable when working with sparse 
> > matrix. The full matrix is not even competitive, even for speed.
> >
> > Bruno
>
> Bruno,
> Yes, its true, however I see that when operations involving sparse-
> matrices result in a more-or-less full matrix (as in my case at some
> intermediate point), it becomes slow. But as Rune pointed out, my data
> set is quite huge 1200 * 312000. So I had to split them and I thought
> I could also save more space by storing sparse as my calculations are
> faster already and shouldn't take much *even if* sparse makes it
> slow.

What types of operations are you doing on this sparse matrix?  If you're 
working along the rows, I recommend you store your matrix transposed and 
work down the columns.  The size in memory of a sparse matrix depends on the 
number of columns in the matrix, not the number of rows, and due to the way 
it's stored in memory retrieving a column of a sparse matrix is likely to be 
faster and more efficient than retrieving a row.

-- 
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ