[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: generating sparse matricies

From: Paul Roberts
Subject: Re: generating sparse matricies
Date: Sat, 1 Oct 2005 13:28:04 -0700

Thanks for all of information. That clears up a lot of questions that I had after trying to use the assignment operator with sparse matrices.

I do agree that it is much faster to first compute the indicies in the matrix that will be non-zero along with the value first. I will try that since I can  then use sparse.m to create the matrix once I have all of the indicies.

It is however slightly more complicated to do it this way as the number of non-zero entries in the matrix must now be drawn from a binomial distribution with parameters p = 0.01 and r = 10000*1000, and the indicies must be drawn from a uniform distribution.



On 10/1/05, David Bateman <address@hidden> wrote:
Søren Hauberg a écrit :

>I can't remember if this works in 2.164, but in 2.9.3 you can just use
>fre, 30 09 2005 kl. 23:07 -0700, skrev Paul Roberts:
>>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;
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 for-loop. 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.

Note the assign function isn't implemented in the octave-forge 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]