Vectorizing for loops - an efficient way to do it

1 visualización (últimos 30 días)
Damiano Capocci
Damiano Capocci el 24 de Dic. de 2017
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.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by