import numpy as np
# 創(chuàng)建一個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)
這些是一些常用的矩陣計算技巧,希望對你有幫助!