[英]How to write a polynomial in x**3 instead of x using Polynomial
At the moment i have a polynomial (of a galois field) in function of x.目前我在 x 的 function 中有一个多项式(伽罗瓦域)。 But i want to "evaluate" it in x^3.
但我想在 x^3 中“评估”它。
Any ideas on how to do it?关于如何做的任何想法?
import galois
GF = galois.GF(31)
f = galois.Poly([1, 0, 0, 15], field=GF);
>> x^3 + 15
So now f is in function of x: f(x) But i want to have f(x^3)所以现在 f 在 x: f(x) 的 function 但我想要 f(x^3)
I am the author of the galois
library.我是
galois
图书馆的作者。 Converting f(x)
to g(x) = f(x^3)
is equivalent to multiplying the degrees of f(x)
with non-zero coefficients by 3. In galois
, this is done like this.将
f(x)
转换为g(x) = f(x^3)
相当于将f(x)
与非零系数的度数乘以 3。在galois
中,这样做是这样的。
In [1]: import galois
In [2]: galois.__version__
Out[2]: '0.0.26'
In [3]: GF = galois.GF(31)
In [4]: f = galois.Poly([1, 0, 0, 15], field=GF); f
Out[4]: Poly(x^3 + 15, GF(31))
In [5]: f.nonzero_degrees
Out[5]: array([3, 0])
In [6]: f.nonzero_coeffs
Out[6]: GF([ 1, 15], order=31)
In [7]: g = galois.Poly.Degrees(3*f.nonzero_degrees, f.nonzero_coeffs); g
Out[7]: Poly(x^9 + 15, GF(31))
EDIT: As of v0.0.31, polynomial composition is supported.编辑:从 v0.0.31 开始,支持多项式组合。 You can now evaluate a polynomial
f(x)
at a second polynomial g(x)
.您现在可以在第二个多项式
g(x)
) 处评估多项式f(x)
x)。
In [1]: import galois
In [2]: galois.__version__
Out[2]: '0.0.31'
In [3]: GF = galois.GF(31)
In [4]: f = galois.Poly([1, 0, 0, 15], field=GF); f
Out[4]: Poly(x^3 + 15, GF(31))
In [5]: g = galois.Poly.Degrees([3], field=GF); g
Out[5]: Poly(x^3, GF(31))
In [6]: f(g)
Out[6]: Poly(x^9 + 15, GF(31))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.