parfor with sliced and reduction variable

5 ビュー (過去 30 日間)
lingyan
lingyan 2013 年 6 月 20 日
Hello, i'm trying to use parfor in this way:
oldc = c(:,index);
delta = thirds(biggy+1);
newc_left = oldc(:,ones(1,lssize));
newc_right = oldc(:,ones(1,lssize));
f_left = zeros(1,lssize);
f_right = zeros(1,lssize);
parfor i = 1:lssize
lsi = ls(i);
newc_left(lsi,i) = newc_left(lsi,i) - delta;
newc_right(lsi,i) = newc_right(lsi,i) + delta;
[f_left(i), con_left(i), fflag_left(i)] = CallObjFcn(Problem,newc_left(:,i),a,b,impcons,calltype,varargin{:});
[f_right(i), con_right(i), fflag_right(i)] = CallObjFcn(Problem,newc_right(:,i),a,b,impcons,calltype,varargin{:});
fcncounter = fcncounter + 2;
end
There is something wrong with the use of newc-left. can I use parfor in this case and how?

採用された回答

Edric Ellis
Edric Ellis 2013 年 6 月 20 日
編集済み: Edric Ellis 2013 年 6 月 20 日
You could try something like this so that you're updating whole columns of newc_left and newc_right:
numRows = size(oldc, 1);
...
parfor ...
increment = zeros(numRows, 1);
increment(lsi(i)) = delta;
newc_left(:,i) = newc_left(:,i) - increment;
newc_right(:,i) = newc_right(:,i) + increment;
...
  1 件のコメント
lingyan
lingyan 2013 年 6 月 20 日
Thanks a lot! Now it works. Can you please explain where am i wrong and why?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Analytics Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by