Python numpy.asmatrix()
numpy.asmatrix(data, dtype =None)通过将输入解释为一个矩阵返回一个矩阵。
参数 :
data :类似数组的输入数据
dtype : 返回数组的数据类型
返回值 :
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]]