Hallo,

I would like to understand how the dot operator works. There are two specific problems:

at Performance Tips · The Julia Language (headline: Consider using views for slicing)

I learned that "…on the left-hand side of an assignment, where `array[1:5, :] = ...`

assigns in-place to that portion of `array`

". As I understand it, no unnecessary copies are stored in memory.

Now I read here:

Functions · The Julia Language that if I use the dot-operator .= :

"If the left-hand side is an array-indexing expression, e.g. `X[begin+1:end] .= sin.(Y)`

, then it translates to `broadcast!`

on a `view`

, e.g. `broadcast!(sin, view(X, firstindex(X)+1:lastindex(X)), Y)`

, so that the left-hand side is updated in-place. "

Now I wonder why the dot near the equal sign in X[begin+1:end] .= sin.(Y) is necessary. Shouldn’t it be updated in-place anyway? What is the advantage of the View in this case?

If I have an expression like: Θ[:,k+1] = K*Θ[:,k]+B

and K is a 10x10 matrix , Θ[:,k] is a 10x1 vector and B is another 10x1 vector.

Can I take advantage of the dot vector in this case?

I can’t use . * because I don’t want a broadcast. So I can’t use @.

Because of the array-indexing expression on the left-hand side the .= seems unnecessary (it’s in-place anyway). And .+ without fusion doesn’t seem to make sense.

Did I get that right?

It would be great if someone could explain this to me