python - Characteristic polynomial of binary matrix over the field F2 or GF(2)
问题描述
How can the characteristic polynomial of a binary matrix (one with only zeros and ones) be found programmatically, where the process operates in the finite field F2 (also known as GF(2)) and the coefficients are zeros and ones?
Here's what I have tried:
- SymPy's
charpoly()
method doesn't give the answer I want, since it doesn't operate on the field F2 and gives a polynomial with coefficients well beyond 0 and 1. However, is it possible to adapt the output ofcharpoly()
to return the characteristic polynomial over F2, or to have thecharpoly()
method operate on that field? - This repository is about the most convenient thing I could find that could solve this question. As of this writing I am trying it out now. However, it is very slow (is on track to take many hours) for the sizes of matrices I am interested in (128x128 to 256x256). Moreover, I had to modify the source code to fit my needs since the code, as is, doesn't take arbitrary matrices.
I am asking this question because finding the characteristic polynomial in F2 is part of the process of calculating the appropriate jump parameter for certain random number generators (see my note on this).
解决方案
事实证明,返回的特征多项式的系数charpoly()
可以适应 GF(2) 有限域,而且很容易做到:奇数系数变为 1,偶数系数变为 0。这对我的目的来说已经足够了。因此,我的问题解决了。
推荐阅读
- android - 从视图模型中删除当前片段并启动另一个片段
- sql - BigQuery:获取每个组的前 3 条记录
- python - log1p 是对图表进行对数比例转换的“正确”方式吗?
- ios - 打开日历应用程序的通用链接
- vue.js - vue 为每个组件创建不可观察的变量
- python-3.x - zip 参数#1 必须支持迭代,同时评估和获取未合并 python 的单个 dict
- solidity - 被调用函数应在withdraw函数中支付错误
- tensorflow - 加载在早期 tensorflow 版本中训练的已保存模型
- python - 为什么我在使用 map 函数时得到 TypeError 'list' object is not callable?
- javascript - 使用 JavaScript 将 SELECT 元素与对象数组绑定