필터 지우기
필터 지우기

create big matrix with only 0s and 1s

조회 수: 1 (최근 30일)
freebil
freebil 2013년 11월 6일
댓글: freebil 2013년 11월 7일
I want to run the following
n = 10^6;
m = n/2;
H = sparse(m,n);
parfor jj=1:n
pos = sample(cumulative);
H(:,jj) = (rand(m,1) > 1 - degrees(pos)/m);
end
but the memory is over.
degrees(pos)/m is a different number every time. Is there any way to run it quickly?

답변 (1개)

the cyclist
the cyclist 2013년 11월 6일
Unless I did the math in my head wrong, you are trying to create a matrix that is 4 terabytes of data (and is not actually sparse). That's too big.
  댓글 수: 2
Image Analyst
Image Analyst 2013년 11월 6일
theodor, why do you need it that big? You'll just have to get by without the whole thing in memory at once. You'll have to figure out how to process the thing in smaller chunks.
freebil
freebil 2013년 11월 7일
thanks for the answers.. I actually don't need zeros but only 1s.. Is there any way to create a sparse matrix with only ones? I thought something like that
finalcolpos=0;
parfor jj=1:n
pos = sample(cumulative);
col = (rand(m,1) > 1 - degrees(pos)/m);
colpos = find(col);
finalcolpos = [finalcolpos; colpos];
end
finalcolpos(1)=[];
H(finalcolpos)=1;
but it is slow for n>10^5

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by