ary8 = np.eye(3) # 对角线全1矩阵(3行3列方阵) ary9 = np.diag([1, 2, 3]) # 对角线矩阵,指定对角线元素为1,2,3 matr1 = np.mat("1 2 3;4 5 6;7 8 9") matr2 = np.matrix([[123], [456], [789]]) # (5)生成随机数数组 ary10 = np.random.random((2, 3)) # [0,...
np.array(range(0,10,2) #两个输出结果均为[0,2,4,6,8] np.arange(0,10).reshape((2,5)) #输出结果为[[0,1,2,3,4],[5,6,7,8,9]] 以2行5列的矩阵展现 1. 2. 3. 4. linspace函数 import numpy as np >>>np.linsapce(0,1,5) #元素个数为5 array([0.,0.25,0.5,0.75,1.])...