I was looking at the Devectorise package and was wondering, why not have an 
operator that calls elementwise operations?

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.

Reply via email to