MATLAB PARALLEL COMPUTING TOOLBOX - S Guía de usuario Pagina 58

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 656
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 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
Vista de pagina 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 655 656

Comentarios a estos manuales

Sin comentarios