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

  • 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 136
Looping Over a Distributed Range (for-drange)
5-23
To loop over all elements in the array, you can use for-drange on the dimension of
distribution, and regular for-loops on all other dimensions. The following example
executes in an spmd statement running on a parallel pool of 4 workers:
spmd
PP = zeros(6,8,12,'codistributed');
RR = rand(6,8,12,codistributor())
% Default distribution:
% by third dimension, evenly across 4 workers.
for ii = 1:6
for jj = 1:8
for kk = drange(1:12)
PP(ii,jj,kk) = RR(ii,jj,kk) + labindex;
end
end
end
end
To view the contents of the array, type:
PP
Vue de la page 136
1 2 ... 132 133 134 135 136 137 138 139 140 141 142 ... 655 656

Commentaires sur ces manuels

Pas de commentaire