阅读背景:

如何减少这种组合计算中的内存使用?

来源:互联网 

I have the following program:

我有以下程序:

m = 4;
N = 3;

a = [ones(N+m-1,1)' zeros(m,1)']; % creates an array with specified number of 0's and 1's
b = perms(a);
c = unique(b,'rows'); % with these last two lines, I find all possible combinations

% the rest is probably not relevant for the question

d = [ones(length(c),1) c ones(length(c),1)]; 

a_powers = zeros(length(d(:,1)),1);
for i = 1:length(d(:,1))         
    a_powers(i) = nnz(diff(d(i,:))==0);
end

[n_terms,which_power]=hist(a_powers',unique(a_powers'));
m = 4



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: