In my code the parfor is slower than for loop when using backslah with matrices.
Afficher commentaires plus anciens
I have following code. I am using backslash for matrices and parfor loop is slower than for loop. What kind of problems are there in following code? Thank you so much.
A = radn(3000);
[n,~] = size(A);
I = eye(n);
c = [0,-1/5, 1/5,-1/10, 1/10];
b = [128/3, 20/9, 85/3, -15, -(515/9)];
E = zeros(n);
tic
for k = 1:5
E = E + b(k)*((I-c(k)*A)\(c(k)*A));
end
toc
tic
parfor k = 1:5
E = E + b(k)*((I-c(k)*A)\(c(k)*A));
end
toc
E=E+I;
my results with 8 workers are as follows:
Elapsed time is 2.656596 seconds
Elapsed time is 3.542917 seconds
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!