[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sparse 2D lookup
From: 
John W. Eaton 
Subject: 
sparse 2D lookup 
Date: 
Tue, 25 Oct 2005 20:18:43 0400 
On 25Oct2005, Jeff Abrahamson wrote:
 I want an array of (x,y,z) triples. The problem is that x and y come
 from the same very large set, but very few (x,y) pairs will actually
 be used. The z value is computed based on x and y, so this is really
 a function f(x,y) = z.

 Naively I'd create a sparse array, but sparse arrays seem (it's not
 clear, though) to become regular arrays if I add elements to them.
 Thus,

 v = sparse(10000000,10000000)
 v =

 Compressed Column Sparse (rows=10000000, cols=10000000, nnz=0)

 octave:3> v(1,1) = 1

 (and memory usage jumps to near 2 GB and my machine slows to a crawl).
You must be using the sparse code from octaveforge. The sparse code
that is part of Octave 2.9.x does not have this problem.
jwe

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
