Borrar filtros
Borrar filtros

Error when using distributive property

1 visualización (últimos 30 días)
D G
D G el 26 de Jul. de 2011
Hello!
The function below compares the output of two functions which run the same calculation. However, in one function the calculation's multiplications are distributed. It should output a matrix of 1s. However, it doesn't!
What's up with that?
function errorTest()
compute(1:100) == distributed(1:100)
function out = compute(a)
out = 10.1 * (a - 1);
end
function out = distributed(a)
out = 10.1 * a - 10.1;
end
end
Thanks!

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 26 de Jul. de 2011
The propagation of floating approximations is different:
idx = abs(compute(1:100) - distributed(1:100)) > 2*eps
nnz(idx)
How many values over 2eps?
  4 comentarios
D G
D G el 26 de Jul. de 2011
I guess I had that backwards. If you remove the 2*, a lot of the answers are still different.
Oleg Komarov
Oleg Komarov el 26 de Jul. de 2011
Cannot really help you more than that, I don't have experience with distributed server.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by