[Numpy-discussion] Matrix addition, +=
Alan G Isaac
Mon Sep 12 06:58:31 CDT 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