Python中的 numpy.asmatrix()
numpy.asmatrix(data, dtype = None) 通过将输入解释为矩阵来返回矩阵。
参数 :
data : array-like input data
dtype : Data type of returned array
返回:
Interprets the input as a matrix
# Python Programming illustrating
# numpy.asmatrix
import numpy as geek
# array-like input
b = geek.matrix([[5, 6, 7], [4, 6]])
print("Via array-like input : \n", b, "\n")
c = geek.asmatrix(b)
b[0, 1] = 10
print("c matrix : \n", c)
输出 :
Via array-like input :
[[[5, 6, 7] [4, 6]]]
c matrix :
[[[5, 6, 7] 10]]