I have seen f = sympy.symbols('f', cls=Function) but not any documentation. Python does not like x = sympy.symbols('x', cls=FF(8)), it complains about
我见过f = sympy.symbols('f',cls = Function)但没有任何文档。 Python不喜欢x = sympy.symbols('x',cls = FF(8)),它抱怨
raise CoercionFailed("expected an integer, got %s" % a) CoercionFailed: expected an integer, got x
提高CoercionFailed(“预期一个整数,得到%s”%a)CoercionFailed:期望一个整数,得到x
Whan is the purpose of the cls parameters and what must I do so that cls=FF(8) is meaning full?
Whan是cls参数的目的,我必须做什么才能使cls = FF(8)意味着完整?
With x = sympy.symbols('x', cls=FF(8)) I want x to be a symbol in the field FF(8), i.e x^(2^8-1) must give me 1.
使用x = sympy.symbols('x',cls = FF(8))我希望x成为FF(8)字段中的符号,即x ^(2 ^ 8-1)必须给我1。
1 个解决方案
#1
2
There are a few issues here:
这里有一些问题:
-
The
FF
object does not allow Symbols. It only works for exact numerical entries, likeFF(3)(2)
.FF对象不允许使用符号。它仅适用于精确的数字输入,如FF(3)(2)。
-
Therefore, the
cls
parameter ofsymbols
will not work. That just changes what object is used to create the symbol, so it must take a string as an input (the default isSymbol
).因此,符号的cls参数将不起作用。这只是改变了用于创建符号的对象,因此它必须将字符串作为输入(默认为Symbol)。
-
SymPy does not currently support Symbols over finite fields. The best bet you can get is to use the
Poly
object with themodulus
flag.SymPy目前不支持有限域上的符号。您可以获得的最佳选择是使用带有模数标志的Poly对象。
-
FF
currently only supports finite fields of prime cardinality.FF(8)
has actually created the ring Z_8, not the finite field with 8 elements.FF目前仅支持主要基数的有限字段。 FF(8)实际上创建了环Z_8,而不是具有8个元素的有限域。
-
You probably know this, but
^
does not do exponentiation in SymPy/Python. Use**
.您可能知道这一点,但^不会在SymPy / Python中进行取幂。使用 **。
#1
2
There are a few issues here:
这里有一些问题:
-
The
FF
object does not allow Symbols. It only works for exact numerical entries, likeFF(3)(2)
.FF对象不允许使用符号。它仅适用于精确的数字输入,如FF(3)(2)。
-
Therefore, the
cls
parameter ofsymbols
will not work. That just changes what object is used to create the symbol, so it must take a string as an input (the default isSymbol
).因此,符号的cls参数将不起作用。这只是改变了用于创建符号的对象,因此它必须将字符串作为输入(默认为Symbol)。
-
SymPy does not currently support Symbols over finite fields. The best bet you can get is to use the
Poly
object with themodulus
flag.SymPy目前不支持有限域上的符号。您可以获得的最佳选择是使用带有模数标志的Poly对象。
-
FF
currently only supports finite fields of prime cardinality.FF(8)
has actually created the ring Z_8, not the finite field with 8 elements.FF目前仅支持主要基数的有限字段。 FF(8)实际上创建了环Z_8,而不是具有8个元素的有限域。
-
You probably know this, but
^
does not do exponentiation in SymPy/Python. Use**
.您可能知道这一点,但^不会在SymPy / Python中进行取幂。使用 **。