Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!g23g2000vbr.googlegroups.com!not-for-mail
From: arun <aragorn168b@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: size(sparse matrix) > size(full matrix)
Date: Thu, 17 Sep 2009 03:49:56 -0700 (PDT)
Organization: http://groups.google.com
Lines: 26
Message-ID: <2226e4a4-2e61-4c44-98ce-8cddb92116b5@g23g2000vbr.googlegroups.com>
References: <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com> 
	<139c9961-df1a-449d-a48c-72ee0d54f9f6@l35g2000vba.googlegroups.com>
NNTP-Posting-Host: 192.124.26.250
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1253184596 29151 127.0.0.1 (17 Sep 2009 10:49:56 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 17 Sep 2009 10:49:56 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: g23g2000vbr.googlegroups.com; posting-host=192.124.26.250; 
	posting-account=fyqXpgoAAABqt-0BifyaNxmZhzggFACu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; 
	rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:571042


On Sep 17, 12:31 pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> On 17 Sep, 12:15, arun <aragorn1...@gmail.com> wrote:
>
> > Hi,
> > I just discovered that my data set which is about 1200 * 39000 and
> > contains only values 0, 0.5 and 1, when stored as sparse has size of
> > 760 MB and when stored as double has about 380 MB.
> > I agree, the number of zeros may not be a lot, which again might
> > suggest that using sparse might not be advantageous. However, why
> > should it result in this *explosion* of size???
>
> Sparse matrices store indexes of where a non-zero elemented
> is located along with the actual value of the value. So there
> is three times as much information stored per element in a
> sparse matrix. This means that you need a certain large fraction
> of zero elements (the exact numbers depend on implementation
> details) before the total memory footprint of the sparse matrix
> becomes smaller than the footprint of the same matrix stored
> on dense format.
>
> Rune

Understood. thank you very much.
I changed the data back to full matrices.
The code is even more faster now.
best, arun.