Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: size(sparse matrix) > size(full matrix)
Date: Thu, 17 Sep 2009 10:53:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 25
Message-ID: <h8t4ee$13j$1@fred.mathworks.com>
References: <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1253184782 1139 172.30.248.37 (17 Sep 2009 10:53:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Sep 2009 10:53:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:571043


arun <aragorn168b@gmail.com> wrote in message <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com>...
> 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???
> if someone could clarify, it would be great.
> 
> best, arun.

Roughly speaking, a *non-zero* sparse element needs
- double, 32-byte platform: 12 bytes
- double, 64-byte platform: 16 bytes 
- logical, 32-byte platform: 5 bytes
- logical, 64-byte platform: 9 bytes 

A full matrix needs per element
- double, 8 bytes (both platforms)
- logical, 1 byte (both platforms)

Do the math.

Bruno