MATLAB PARALLEL COMPUTING TOOLBOX - S Betriebsanweisung Seite 137

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 656
  • Inhaltsverzeichnis
  • FEHLERBEHEBUNG
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 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
Seitenansicht 136
1 2 ... 132 133 134 135 136 137 138 139 140 141 142 ... 655 656

Kommentare zu diesen Handbüchern

Keine Kommentare