摘要:
`import numpy as np a = np.eye(4) b = np.rot90(a) c, d = np.linalg.eig(b) print('特征值为:', c) print('特征向量为:\n', d) print("学号:3005")` 阅读全文
摘要:
`import numpy as np a = np.array([[3, 1], [1, 2], [1, 1]]) b = np.array([9, 8, 6]) x = np.linalg.pinv(a) @ b print(np.round(x, 4)) print("学号:3005")` 阅读全文
摘要:
`import numpy as np a = np.array([[3, 1], [1, 2]]) b = np.array([9, 8]) x1 = np.linalg.inv(a) @ b #第一种解法 上面语句中@表示矩阵乘法 x2 = np.linalg.solve(a, b) #第二种解 阅读全文
摘要:
`import numpy as np a = np.array([[0, 3, 4], [1, 6, 4]]) b = np.linalg.norm(a, axis=1) #求行向量2范数 c = np.linalg.norm(a, axis=0) #求列向量2范数 d = np.linalg.n 阅读全文
摘要:
`import numpy as np a = np.ones(4) b = np.arange(2, 10, 2) c = a @ b #a作为行向量,b作为列向量 d = np.arange(16).reshape(4,4) f = a @ d #a作为行向量 g = d @ a #a作为列向量 阅读全文
摘要:
`import numpy as np a = np.array([[0, 3, 4], [1, 6, 4]]) b = np.array([[1, 2, 3], [2, 1, 4]]) c = a / b #两个矩阵对应元素相除 d = np.array([2, 3, 2]) e = a * d 阅读全文
摘要:
`import numpy as np a = np.array([[0, 3, 4], [1, 6, 4]]) b = a.sum() #使用方法,求矩阵所有元素的和 c1 = sum(a) #使用内置函数,求矩阵逐列元素的和 c2 = np.sum(a, axis=0) #使用函数,求矩阵逐列元 阅读全文
摘要:
`import numpy as np a = np.arange(16).reshape(4,4) #生成4行4列的数组 b = np.vsplit(a, 2) #行分割 print('行分割:\n', b[0], '\n', b[1]) c = np.hsplit(a, 4) #列分割 prin 阅读全文
摘要:
`import numpy as np a = np.arange(16).reshape(4,4) #生成4行4列的数组 b = np.floor(5np.random.random((2, 4))) c = np.ceil(6np.random.random((4, 2))) d = np.vs 阅读全文
摘要:
`import numpy as np a = np.arange(16).reshape(4,4) #生成4行4列的数组 b = a[1][2] #输出6 c = a[1, 2] #同b d = a[1:2, 2:3] #输出[[6]] x = np.array([0, 1, 2, 1]) pri 阅读全文