简体   繁体   English

有限域上的 SymPy 多项式

[英]SymPy polynomials over finite fields

import sympy as S 
F = S.FiniteField(101)

When I call f = S.poly(y ** 2 - x ** 3 - x - 1,F) I get the following error:当我调用f = S.poly(y ** 2 - x ** 3 - x - 1,F)我收到以下错误:

'FiniteField' object has no attribute 'is_commutative' 'FiniteField' 对象没有属性 'is_commutative'

But finite fields are commutative by definition!但是根据定义,有限域是可交换的! So I'm not really sure what this error is supposed to mean!所以我不太确定这个错误是什么意思!

Has anyone come across this before?有没有人遇到过这个? How do you declare polynomials over a finite field?如何在有限域上声明多项式?

is_commutative is an attribute of operators generally. is_commutative一般是 算子的一个属性。 It is not implemented for domains (unlike is_numeric etc).它不是为 实现的(与is_numeric等不同)。

eg例如

>>> F = sympy.RealField() #returns the same error
>>> f = sympy.poly(y ** 2 - x ** 3 - x - 1, F)

AttributeError: 'RealField' object has no attribute 'is_commutative'

Hence, poly is interpreting your positional argument as something other than the domain.因此, poly将您的位置参数解释为域以外的东西。 To get the intended behaviour with poly (and factor etc) you must use the domain (or equivalent) kwarg ie:要使用poly (和factor等)获得预期的行为,您必须使用domain (或等效的)kwarg,即:

f = sympy.poly(y ** 2 - x ** 3 - x - 1, domain=F)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM