import numpy as np
import sympy
from scipy.optimize import fsolve
from sympy import *
H = np.array(
[[0, 0, 0, 1, 1, 1, 1],
[0, 1, 1, 0, 0, 1, 1],
[1, 0, 1, 0, 1, 0, 1]])
def func(X):
'''
'''
H = np.array(
[[0, 0, 0, 1, 1, 1, 1],
[0, 1, 1, 0, 0, 1, 1],
[1, 0, 1, 0, 1, 0, 1]])
G1 = np.eye(4)
G2 = [[X[0], X[1], X[2]]
, [X[3], X[4], X[5]]
, [X[6], X[7], X[8]]
, [X[9], X[10], X[11]]]
G = np.concatenate((G1, G2), axis=1)
#print(G.shape)
GH_T = np.dot(G, np.transpose(H))
m, n = GH_T.shape[0], GH_T.shape[1]
for i in range(m):
for j in range(n):
GH_T[i][j] %= 2
GH_T = np.array(GH_T)
GH_T = GH_T.reshape(1,12)
#print(GH_T)
return GH_T
for i in range(0,pow(2,12)):
i_str = str(i)
待解决的代码2
最新推荐文章于 2024-11-05 15:28:12 发布
该博客探讨了如何使用Python的NumPy和SymPy库进行矩阵操作,特别关注了如何通过`fsolve`函数求解线性方程组。通过实例演示了如何构造矩阵H,定义GH_T并利用模运算进行优化,最后展示了如何找到特定矩阵系统的解。
摘要由CSDN通过智能技术生成