Fast way to modify values in big sparse matrix?

3 views (last 30 days)
Hi, I am sovling some non-linear optimization problem with big sparse matrix whoose dimension is about 756m x 762m. The locations of each entry are fixed which means that the row and column index vectors are fixed. I had tried to create this matrix by using 'sparse(i,j,v,m,n)' like,
M = sparse(I(:), J(:), V(:), m, n);
It takes 1.3s (it may vary depending on what computer uses). Also, I had tried another approach which seems more valid for me
Mt = sparse(I(:), J(:), 1:length(I(:)), m, n);
...
M = spfun(@(x) V(x), Mt);
It takes about 0.5s. Since the matrix M is created at every iteration, I think the latter approach is right for me.
However, I don`t under stand where this difference comes from. In the spfun(at line 22), there is a code
f = sparse(i,j,feval(fun,x),m,n);
which can be thought as identical approach in the first one above.
Is there any reason why those difference comes from? and any faster method than what i tried?

Answers (0)

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!