numpy.matrix.getA
matrix.getA()[source]
返回一个数组对象
Return self as an ndarray object.
Equivalent to np.asarray(self).
Parameters: None
Returns: ret : ndarray
self as an ndarray
Examples
>>> x = np.matrix(np.arange(12).reshape((3,4))); x
matrix([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> x.getA()
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
numpy.matrix.transpose
矩阵转置
Returns a view of the array with axes transposed.
For a 1-D array, this has no effect. (To change between column and row vectors, first cast the 1-D array into a matrix object.) For a 2-D array, this is the usual matrix transpose. For an n-D array, if axes are given, their order indicates how the axes are permuted (see Examples). If axes are not provided and a.shape = (i[0], i[1], … i[n-2], i[n-1]), then a.transpose().shape = (i[n-1], i[n-2], … i[1], i[0]).
、
Examples
>>> a = np.array([[1, 2], [3, 4]])
>>> a
array([[1, 2],
[3, 4]])
>>> a.transpose()
array([[1, 3],
[2, 4]])
>>> a.transpose((1, 0))
array([[1, 3],
[2, 4]])
>>> a.transpose(1, 0)
array([[1, 3],
[2, 4]])
本文介绍了numpy库中matrix对象的getA方法,它将matrix转换为ndarray对象,等价于np.asarray(self)。同时讨论了transpose函数,用于进行矩阵转置,1-D数组不受影响,2-D数组则是常规的转置操作,对于n-D数组,可以指定轴的排列方式。附带了相关示例。
2231

被折叠的 条评论
为什么被折叠?



