Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: size(sparse matrix) > size(full matrix)
Date: Fri, 18 Sep 2009 08:05:06 +0000 (UTC)
Organization: ErasmusMC
Lines: 14
Message-ID: <h8vevi$46g$1@fred.mathworks.com>
References: <8e83f86c-df5e-413d-9943-da36c83a66d2@g1g2000vbr.googlegroups.com> <c6a3a485-e8b4-459b-8a67-5ed0e5b16a22@h30g2000vbr.googlegroups.com>
Reply-To: <HIDDEN>
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 1253261106 4304 172.30.248.37 (18 Sep 2009 08:05:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 18 Sep 2009 08:05:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1095751
Xref: news.mathworks.com comp.soft-sys.matlab:571280


Hi,
> 
> And this seems to be true. The problem is that, my data set has 0, 0.5
> and 1. There are only 648 0's but 38423871 0.5's and 9140609 1's. I
> guess sparse doesn't look for most-frequently occurring element and
> stores the remaining... but just stores the non-zero values.. yes, it
> is by definition.
> 

You can try to scale/translate your data, i.e. subtract 0.5 from it. Depending on what you are doing, you might have to rescale the other data in your algorithm as well (and undo it afterwards of course).

Simplest alternative is Bruno's suggestion to store 2*A as uint8. This will reduce the memory to 1/8th. However, your operations should allow it.

What operation are you trying to do on the matrix? So far, you have only told us how you make it.