Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Indexing into large sparse matrix
Date: Tue, 24 Mar 2009 21:50:18 +0000 (UTC)
Organization: Xoran Technologies
Lines: 8
Message-ID: <gqbkiq$e1s$1@fred.mathworks.com>
References: <gqbgmi$ll6$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237931418 14396 172.30.248.35 (24 Mar 2009 21:50:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 24 Mar 2009 21:50:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:527414


"NIcholas" <remove.this_nmg33@cornell.edu> wrote in message <gqbgmi$ll6$1@fred.mathworks.com>...
> I have a large sparse matrix with number of elements exceeding the maximum variable size allowed in matlab (though number of rows and columns do not) e.g. A = sparse([],[],[],10e6,10e6,0))
> 
> I have a list of row indices r, and colomn indices c (numel(r)==numel(c)).  I would like to extract the elements A(r(i),c(i)) for i=1:numel(r).  For a small matrix I could index as A(sub2ind(size(A),r,c)), however for large A I get the error that it can't index into A since "maximum variable size allowed by the program is exceeded".  I was wondering if there was a way to extract these values without looping over the r, c index.

In general, probably not, but there may be workarounds if you tell us how r,c were generated.

In particular, do you have to index into A? Or could you perhaps index into nonzeros(A) ?