I've been curious, after various recent observations, about if/when matrix multiplication allocates fresh memory for its output. For example, suppose I do something like
Is this equivalent to
z=B*x; %memory allocated here A(:,1)=z;
Or, does the output of B*x get directly generated in the memory locations occupied by A(:,1)? Obviously, the latter would be more efficient, but I wasn't sure how it worked. I know for example that this
is equivalent to
z=B(1,:); %memory allocated here A(1,:)=z*x;
so obviously not everything is as well optimized as it could be.