I like the @. macro, but is there a way to partly escape it? Use case is a situation where in an expression 9 out of 10 operations need the
. and one operation does not.
@. sum(a + b + c + d)
where a to d are vectors and I want the sum of the sum them, so
sum should not be broadcast.
I could imagine one just inverts the notation, i.e.
. then means “do not broadcast, but that did not work”.
Convert every function call or operator in expr into a "dot call" (e.g. convert f(x) to f.(x)), and convert every assignment in expr to a "dot assignment" (e.g. convert += to .+=).
If you want to avoid adding dots for selected function calls in expr, splice those function calls in with $. For example, @. sqrt(abs($sort(x))) is equivalent to sqrt.(abs.(sort(x))) (no
dot for sort).
(@. is equivalent to a call to @__dot__.)
julia> x = 1.0:3.0; y = similar(x);
julia> @. y = x + 3 * sin(x)
So perhaps try
@. $sum(a + b + c + d)
Thanks - should have read the help indeed