MATLAB PARALLEL COMPUTING TOOLBOX - S Guide de l'utilisateur Page 58

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 656
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 57
2 Parallel for-Loops (parfor)
2-30
However, if it is clear that in every iteration, every reference to an array element is
set before it is used, the variable is not a sliced input variable. In this example, all the
elements of A are set, and then only those fixed values are used:
parfor ii = 1:n
if someCondition
A(ii) = 32;
else
A(ii) = 17;
end
loop code that uses A(ii)
end
Even if a sliced variable is not explicitly referenced as an input, implicit usage might
make it so. In the following example, not all elements of A are necessarily set inside the
parfor-loop, so the original values of the array are received, held, and then returned
from the loop, making A both a sliced input and output variable.
A = 1:10;
parfor ii = 1:10
if rand < 0.5
A(ii) = 0;
end
end
More About
“Classification of Variables in parfor-Loops” on page 2-23
Vue de la page 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 655 656

Commentaires sur ces manuels

Pas de commentaire