
From:  David Bateman 
Subject:  Re: generating sparse matricies 
Date:  Sat, 01 Oct 2005 14:59:08 +0200 
Useragent:  Mozilla Thunderbird 1.0.2 (Windows/20050317) 
Søren Hauberg a écrit :
Furthermore, if you use a structure like the above in octave 2.9.x (or even matlab for the above case, use spalloc in matlab for the above), you'll reallocate the memory for the sparse matrix at each iteration of the forloop. Therefore, this is likely to be slow.. Its much better to create three vectors for the row, column and value and create the matrix directly. See section 22.1.2 of the manual in 2.9.3 version of octave. I've written some patchy documentation for the sparse stuff that is in section 22.I can't remember if this works in 2.164, but in 2.9.3 you can just use 'sprand' /Søren fre, 30 09 2005 kl. 23:07 0700, skrev Paul Roberts:Hello, I am using Octave 2.1.64. I would like to iteratively build a sparse matrix uring code like: X = sparse(10000,1000); for j=1:1000 X(:, j) = rand(10000,1) < 0.01; end
Note the assign function isn't implemented in the octaveforge sparse toolbox which is what made me start implementing a new sparse implementation in the first place. So the above won't work, though sprand will.
Cheers David  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 
[Prev in Thread]  Current Thread  [Next in Thread] 