Vectorizing for loops - an efficient way to do it
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, i want to know how should i vectorize two loops like this:
length=100000;
limit=8;
j=primes(9000);
j=j(randperm(limit));
d=j(randperm(limit));
X=zeros([1,length]);
X(1)=1;
for k=1:length-1
for p=0:limit-1
X(k+1)=X(k+1)+ power(-1,-p+1)*j(p+1)*X(k-p);
end
X(k+1)=rem(abs(X(k+1)),m);
end
I'm looking for an efficient way cause i've to traduce this code for gpu. I've also a big amount of data.
Thank u.
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!