Protect from @

Is there a way not to broadcast some part of an expression with @.? MWE:

xs = (1, 2)
λs = (0.1, 0.2)
log.(xs) + log.(1.-xs) + log.(1. + rev(xs). + xs. * λs)

(note: no broadcasting for rev) would be much more convenient and readable as

@. log(xs) + log(1-xs) + log(1 + PROTECT(rev(xs)) + xs * λs)

You can opt-out of the dots for specific function calls by splicing with $, e.g. @. sqrt($sort(abs(x))) is equivalent to sqrt.(sort(abs.(x))).

quote from https://github.com/JuliaLang/julia/pull/20321 :slight_smile:

4 Likes