Question ) What is the difference between putting @. and . for every algebraic operator?

Welcome! Please quote your code by surrounding it with triple backticks (```) to make it easier to read.

When you use z = @. max_op(y) + ..., max_op also receives a dot. It’s the same as if you had written

z = max_op.(y) .+ max_op.(...)

So in max_op, x[i] = 0 fails because you can’t index into a Float to set a value. After all, it’s already a scalar.

2 Likes