How to vectorize only one argument in function call

You can protect arguments against broadcasting by wrapping them in a container. You should probably use Ref or a tuple, like this:

f.(a, Ref(b), Ref(c))
f.(a, (b,), (c,))

You could even use a vector:

f.(a, [b], [c]) 

though that would be less efficient.

When you wrap it in an outer container, broadcasting happens over the outer layer, leaving the contents as is.

5 Likes