我有一个 4x4 的多项式 sympy 矩阵:
S = Matrix([[Poly(alpha**4 + alpha**3, alpha, modulus=2), Poly(alpha**4 + alpha**3 + alpha + 1, alpha, modulus=2),Poly(alpha**3 + alpha**2 + alpha, alpha, modulus=2), Poly(alpha**4 + alpha**3 + alpha**2 + alpha, alpha, modulus=2)],
[Poly(alpha**4 + alpha**3 + alpha + 1, alpha, modulus=2), Poly(alpha**3 + alpha**2 + alpha, alpha, modulus=2), Poly(alpha**4 + alpha**3 + alpha**2 + alpha, alpha, modulus=2),Poly(alpha**3 + alpha**2, alpha, modulus=2)],
[Poly(alpha**3 + alpha**2 + alpha, alpha, modulus=2), Poly(alpha**4 + alpha**3 + alpha**2 + alpha, alpha, modulus=2), Poly(alpha**3 + alpha**2, alpha, modulus=2), Poly(alpha**4 + alpha + 1, alpha, modulus=2)],
[Poly(alpha**4 + alpha**3 + alpha**2 + alpha, alpha, modulus=2), Poly(alpha**3 + alpha**2, alpha, modulus=2), Poly(alpha**4 + alpha + 1, alpha, modulus=2),Poly(alpha**2 + alpha + 1, alpha, modulus=2)]])
目标是获取 S.det() 并设置域:
S_det = (S.det()).set_domain(GF(self.q))
调试器输出:
File "/home/gamergod77/work/Staircase codes/Product Codes/bchcoder.py", line 52, in decode
S_det = (S.det()).set_domain(GF(self.q))
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/matrices.py", line 123, in det
return _det(self, method=method, iszerofunc=iszerofunc)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/determinant.py", line 596, in _det
return M._eval_det_bareiss(iszerofunc=iszerofunc)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/matrices.py", line 99, in _eval_det_bareiss
return _det_bareiss(self, iszerofunc=iszerofunc)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/determinant.py", line 669, in _det_bareiss
return bareiss(M)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/determinant.py", line 637, in bareiss
pivot_pos, pivot_val, _, _ = _find_reasonable_pivot(mat[:, 0], iszerofunc=iszerofunc)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/determinant.py", line 56, in _find_reasonable_pivot
is_zero = iszerofunc(x)
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/matrices/utilities.py", line 84, in _is_zero_after_expand_mul
return expand_mul(x) == 0
File "/home/gamergod77/.local/lib/python3.8/site-packages/sympy/core/function.py", line 2799, in expand_mul
return sympify(expr).expand(deep=deep, mul=True, power_exp=False,
AttributeError: 'Poly' object has no attribute 'expand'
值得注意的是,像
S[:3, :3].det().set_domain(GF(2))
具有相同的S通过非常好