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

  • 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 443
11 Functions — Alphabetical List
11-100
Examples
Find the rank of magic squares. Access only the local portion of a codistributed array.
r = zeros(1, 40, codistributor());
for n = drange(1:40)
r(n) = rank(magic(n));
end
r = gather(r);
Perform Monte Carlo approximation of pi. Each worker is initialized to a different
random number state.
m = 10000;
for p = drange(1:numlabs)
z = rand(m, 1) + i*rand(m, 1);
c = sum(abs(z) < 1)
end
k = gplus(c)
p = 4*k/(m*numlabs);
Attempt to compute Fibonacci numbers. This will not work, because the loop bodies are
dependent.
f = zeros(1, 50, codistributor());
f(1) = 1;
f(2) = 2;
for n = drange(3:50)
f(n) = f(n - 1) + f(n - 2)
end
See Also
for | numlabs | parfor
Vista de pagina 443
1 2 ... 439 440 441 442 443 444 445 446 447 448 449 ... 655 656

Comentarios a estos manuales

Sin comentarios