Le lundi 10 novembre 2014 à 22:30 -0800, Michael Louwrens a écrit : > I was looking at the Devectorise package and was wondering, why not > have an operator that calls elementwise operations? Several people around indeed consider this as a very good idea, but so far an agreement on what the good design would be needs to be found. See this issue: https://github.com/JuliaLang/julia/issues/8450
Regards > While syntax is not something I have considered, using something basic > like the example I see > > > r = a .* b + c .* d + a > > > could be expressed as > > > r = .(a * b + c * d + a) > > > which would then apply the expression > > > a * b + c * d + a > > > to each element in the array. > > > .= could possibly be used in place of surrounding the expression > with .(Expr). > > > I am not too familiar with Devectorise here but the advantage of this > (from what I can tell with a limited look through of the readme) is > that this could include user functions as well as user functions would > then be applied. > > > r = .(a * b + c * d + foo(a) * bar(c,d)) > or > r .= a * b + c * d + foo(a) * bar(c,d)) > > > Should theoretically be possible then. > > > The obvious advantage would be that memory only needs to be allocated > once for the new array instead of each broadcasted operator. > > > Just a thought which may be stepping on Devectorise's toes but reading > through some of the vectorised code issues I thought this may be a > simple solution which may provide a performance benefit.
