NumPy - 矩阵库

NumPy 包包含一个 Matrix库numpy.matlib。此模块的函数返回矩阵而不是返回ndarray对象

代码举例:

import numpy.matlib
import numpy as np

print(np.matlib.empty((2, 2))) # 填充为随机数据
print(np.matlib.zeros((2, 2)))
print(np.matlib.ones((2, 2)))
print(np.matlib.eye(n=3, M=4, k=0, dtype=float))
print(np.matlib.identity(5, dtype=float))
print(np.matlib.rand(3, 3))
i = np.matrix(‘1,2;3,4’)
print(np.asarray(i))
print(np.asmatrix(i))

代码 Github地址:https://github.com/shadowagnoy/python_learn/

参考文档:https://docs.scipy.org/doc/numpy/reference/routines.html

参考文档:https://www.tutorialspoint.com/numpy/index.htm