Sparse building seems slow
显示 更早的评论
Hi, I'm working with some large scale LP matrices, exactly two nonzero entries per row and 500k+ rows. I'm using sparse to generate the matrices but it seems slow, about 20min for ~500k rows, 1hr+ for ~1M rows. This accounts for about 80% of my overall run time, once it hits the LP solver things go quickly. Any ideas on how to speed things up? I'm hoping to increase my number of data points which would require a larger matrix (~5M rows). Code below:
%row indices%
i=[1:n_active,1:n_active];
%column indices%
j=[row,col+n];
%constraint ones%
s=ones(2*n_active,1);
%filling sparse matrix%
A=sparse(i,j,s,n_active,n+m,2*n_active);
I'm running on a modestly powered laptop (i5 dual core, 4g Ram). If I can provide any more info let me know, or feel free to tell me to just be patient =) Thanks! Nick
2 个评论
Nick Henscheid
2011-6-28
James
2011-11-15
I am working on the finite element method and I have the same problem. sparse is very slow when the matrix is in the order of 1M*1M. For FEM, this kind of matrices is very normal. It seems that sparse is the best code that Matlab can give. Perheps c or fortran is better?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!