Vectorizing for loops - an efficient way to do it
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!