|
Executing the
following code has the side effect of modifying one of the arguments (matrices)
I passed to matrixmultiply. Note that the matrix m2 changes after the call to
matrixmultiply. This is on Windows with numarray 1.0.
Why does this
happen?
Code:
from numarray import array, matrixmultiply
m1
= array( [[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]] )
m2 =
array( [[ 0.500011, 0.86601905, 0. ], [-0.86601905, 0.500011, 0. ], [
0., 0., 1. ]] )
print "m1 before\n", m1 print "m2 before\n",
m2 matrixmultiply(m1, m2) print "m1 after\n", m1 print "m2 after\n",
m2
Output:
m1 before [[ 1. 0. 0.] [ 0. 1. 0.] [ 0. 0.
1.]] m2 before [[ 0.500011 0.86601905 0. ] [-0.86601905 0.500011 0.
] [ 0. 0. 1. ]] m1 after [[ 1. 0. 0.] [ 0. 1. 0.] [ 0. 0.
1.]] m2 after [[ 0.500011 -0.86601905 0. ] [ 0.86601905 0.500011 0.
] [ 0. 0. 1. ]]
|