Sparse matrix memory problem

조회 수: 1 (최근 30일)
Pawel
Pawel 2012년 4월 5일
I need to create really big sparse matrix, which will have very few non zero elements. I am trying to do this callling function:
A = sparse([1], [1000000000], 1);
But Matlab then allocates 7GB of memory! I think sparse matrices uses memory only for non zero elements, but it seems it allocates full matrix. Am I doing something wrong or this is Matlab bug? How can I bypass it?

채택된 답변

Teja Muppirala
Teja Muppirala 2012년 4월 5일
Sparse matrices keep track of data by each column. This means that if you have a lot of columns (here you have one billion of them...), then you will need lots of memory even though it is sparse. A workaround would be to make it a single column vector with 1e9 rows instead.
A = sparse(1000000000, 1, 1);

추가 답변 (1개)

Pawel
Pawel 2012년 4월 5일
I am wondering why is that. When you have sparse data like features extracted from web pages common case is: in rows you have samples and columns are sparse features. All statistics algorithms in Matlab makes such assumption. So with this implementation of sparse matrix all algorithms from statistics toolbox are useless for sparse data :/

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by