Yes, indeed, mape4b() is the most efficient because reduction is included 
in the loop. This is actually my mape5(). I am preparing this for my 
colleagues as an introductory course to Julia :).

Thanks,
Jan

Dňa piatok, 23. októbra 2015 11:52:30 UTC+2 DNF napísal(-a):
>
> I guess this is mostly about the behaviour of map!, but for avoiding 
> allocations I think this makes more sense:
>
> function mape4b(A, F)
>     tmp = zero(eltype(A))
>     N = length(A)
>     for i in 1:N
>         tmp += abs(_f(A[i], F[i]))
>     end
>     return 100 * tmp / N
> end
>
> For some reason, the time macro doesn't give me any number for allocation 
> in mape4b, but it's 20-25% faster than mape4a and almost twice as fast as 
> the broadcast! version on my computer.
>
> I tried using @inbounds but that had no effect whatsoever.
>

Reply via email to