Skip to content

Instantly share code, notes, and snippets.

@shoya140
Created October 29, 2012 02:20
Show Gist options
  • Save shoya140/3971059 to your computer and use it in GitHub Desktop.
Save shoya140/3971059 to your computer and use it in GitHub Desktop.
MAX = 100;
x = rand(MAX, MAX);
s = ones(MAX, 1) * sum(x);
%良くないアルゴリズム
%for i = 1:MAX
% for j = 1:MAX
% ans(j, i) = x(j, i)/s(j, i);
% end
%end
%ans
%良いアルゴリズム(要素ごとの演算処理)
ans = x ./ s
%TESTCODE 全要素が1ならばOK
%sum(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment