import numpy as np
# 创建一个2x3的矩阵
matrix = np.array([[1, 2, 3], [4, 5, 6]])
print(matrix)
matrix1 = np.array([[1, 2], [3, 4]])
matrix2 = np.array([[5, 6], [7, 8]])
# 矩阵加法
result_add = matrix1 + matrix2
print(result_add)
# 矩阵减法
result_sub = matrix1 - matrix2
print(result_sub)
matrix1 = np.array([[1, 2], [3, 4]])
matrix2 = np.array([[5, 6], [7, 8]])
# 矩阵乘法
result_mul = np.dot(matrix1, matrix2)
print(result_mul)
matrix = np.array([[1, 2, 3], [4, 5, 6]])
# 矩阵转置
result_transpose = matrix.T
print(result_transpose)
matrix = np.array([[1, 2], [3, 4]])
# 求矩阵的逆
result_inv = np.linalg.inv(matrix)
print(result_inv)
这些是一些常用的矩阵计算技巧,希望对你有帮助!