Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!l35g2000vba.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: size(sparse matrix) > size(full matrix)
Date: Thu, 17 Sep 2009 03:31:36 -0700 (PDT)
Organization: http://groups.google.com
Lines: 19
Message-ID: <139c9961-df1a-449d-a48c-72ee0d54f9f6@l35g2000vba.googlegroups.com>
References: <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com>
NNTP-Posting-Host: 77.16.79.26
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: posting.google.com 1253183497 25504 127.0.0.1 (17 Sep 2009 10:31:37 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 17 Sep 2009 10:31:37 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: l35g2000vba.googlegroups.com; posting-host=77.16.79.26; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:571034


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