Skip to main content

gf2lib is a library for manipulating GF (2) polynomials and GF (2) matrices over finite fields

Project description

gf2lib

gf2lib是一个操作有限域GF(2)多项式和GF(2)矩阵的库

  • gf2lib.gf2poly:GF(2)多项式
  • gf2lib.gf2matrix:GF(2)矩阵

一、 快速开始

  • (1) 通过pip安装
pip install gf2lib
  • (2)直接拷贝位于src中的源代码

二、 demo

更多参考样例见GitHub中的example文件夹,gf2lib

  • (1) gf2poly
from gf2lib.gf2poly import GF2Poly

ir_poly = 0x11b  # p(x)=x^8+x^4+x^3+x+1

a = GF2Poly(0b101, ir_poly)  # x^2+1
b = GF2Poly(0b010, ir_poly)  # x

print(a.value)  # 0b101
print(a.ir_poly)  # 0b100011011
print(a)  # 0b101

c = a + b  # 加法
d = a * b  # 乘法
e = a ** 4  # 幂
f = a / b  # 除法
g = a % b  # 模
h = a.inverse()  # 求逆
  • (2) gf2matrix
from gf2lib.gf2matrix import GF2Matrix

M = GF2Matrix([[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0]])
M = M * M  # 乘法
M = M.inverse()  # 求逆
print(M)  # [[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]

gf2lib

gf2lib is a library for manipulating GF (2) polynomials and GF (2) matrices over finite fields

  • gf2lib.gf2poly: GF (2) polynomial
  • gf2lib.gf2matrix: GF (2) matrix

1. Quick Start

  • (1) Install via pip
pip install gf2lib
  • (2) Directly copy the source code in src

2. Demo

For more reference examples, see the example folder in GitHub. gf2lib

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gf2lib-0.0.1.tar.gz (7.9 kB view hashes)

Uploaded Source

Built Distribution

gf2lib-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page