[Numpy-discussion] Matrix addition, +=
Alan G Isaac
alan.isaac at gmail.com
Mon Sep 12 07:58:31 EDT 2011
On 9/12/2011 7:18 AM, Jonas Wallin wrote:
> Why does
> MuY += MuY.transpose()
> MuY = MuY + MuY.transpose()
> give different answers?
Because the first one is done in-place,
so you are changing MuY (and thus MuY.transpose)
as the operation proceeds.
MuY.transpose() is generally a *view* of MuY.
Use the second one.
More information about the NumPy-Discussion