du = copy(W) changes what the variable name du refers to.
With the for loop you are instead modifying the array that the variable name du refers to. Another way you could do that is with a line like du .= W.
du = copy(W) changes what the variable name du refers to.
With the for loop you are instead modifying the array that the variable name du refers to. Another way you could do that is with a line like du .= W.