Path: news.mathworks.com!not-for-mail
From: "Anthony Hopf" <anthony.hopf@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Index matrix to sparse matrix... saving memory
Date: Sat, 29 May 2010 16:30:23 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <htrfev$fo7$1@fred.mathworks.com>
Reply-To: "Anthony Hopf" <anthony.hopf@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1275150623 16135 172.30.248.35 (29 May 2010 16:30:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 29 May 2010 16:30:23 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1899184
Xref: news.mathworks.com comp.soft-sys.matlab:640484

Latest problem....

I have a matrix NxM that is N indexing vectors.  Some of these vectors have very few index values, but they all have to be M long (the largest number of index values) so they are filled with zeros.  Turns out I only utilize about 3% of the matrix to valid index values so I thought it would be a "good" idea to take advantage of sparse matrices to save a ton of memory, the MxN matrix can be over a gig.

S = [1 2 3 0 0 0 0 0 0
       4 5 6 0 0 0 0 0 0
       7 8 9 10 11 12 13 14 0
       15 16 17 18 19 20 21 22 23]

I would access each vector by S(1,:) and would have to cull out the 0's... but it would be great to just get the nonzeros!!

S_s = sparse(S);%<-- Much less memory (in the above case there isn't much savings)

Is there any way address S_s row wise to grab out the vectors I need without turning it back into a full matrix?

I am trying to figure out if I can use Bruno Luong's Sparse Sub Access, but I don't have su access to the server I am using to test it out...

Thanks in advance