I was addicted to using numpy the other day, but it seems that numpy's matrix
and mat
are different. Looking at the Original Document, mat
ismatrix (data, copy = False)
It is written as equivalent, and it seems that it is not copied. What does this mean?
>>> import numpy as np
>>> m = np.matrix([[1.0, 2.0],[3.0, 4.0]])
>>> m
matrix([[ 1., 2.],
[ 3., 4.]])
>>> a = np.matrix(m)
>>> a[0, 0] = 5.0
>>> a
matrix([[ 5., 2.],
[ 3., 4.]])
>>> m
matrix([[ 1., 2.],
[ 3., 4.]])
>>> #Even if a is changed, m does not change
>>>
>>> b = np.mat(m)
>>> b[0, 0] = 6.0
>>> b
matrix([[ 6., 2.],
[ 3., 4.]])
>>> m
matrix([[ 6., 2.],
[ 3., 4.]])
>>> #Changing b changes m
I was a little addicted to it, so I wrote it.