I'm trying to create a coordinate ring of an algebraic set (where the algebrais set is specified by some set of polynomials in arbitrary variables over a field).
我正在尝试创建一个代数集的坐标环(其中代数集由一个字段上的任意变量中的一些多项式集指定)。
So I'm using Sympy's poly_ring()
function
所以我使用Sympy的poly_ring()函数
It's usually used to create coordinate rings when you already know the generators of the ideal you want to define it for, for example;
例如,当您已经知道要为其定义理想的生成器时,它通常用于创建坐标环;
CoordinateRing = QQ.poly_ring(x,y,z) / [y**2 - z*x, xy*2 + z]
But I want to make no assumption on the number of variables used in the defining polynomials for my algebraic sets. So I wrote a function get_symbols()
that extracts all the symbols used in the defining polynomials. Is there a way to set the generators for poly_ring()
without having to list them as parameters?
但是我想对我的代数集的定义多项式中使用的变量数量没有假设。所以我编写了一个函数get_symbols(),它提取定义多项式中使用的所有符号。有没有办法为poly_ring()设置生成器而不必将它们列为参数?
from sympy import *
class AlgebraicSet(object):
def __init__(self, polynomials,field):
self.polynomials = polynomials
self.field = field
def get_symbols(self):
symbols = set()
for f in self.polynomials:
symbols = set(symbols | f.atoms(Symbol))
return symbols
def get_cooridinate_ring(self):
return self.field.poly_ring(self.get_symbols(),order="ilex") / self.polynomials
1 个解决方案
#1
2
Your code wasn't working for me, but I found using old_poly_ring
instead of poly_ring
did the trick:
您的代码对我不起作用,但我发现使用old_poly_ring而不是poly_ring就可以了:
from sympy import *
class AlgebraicSet(object):
def __init__(self, polynomials,field):
self.polynomials = polynomials
self.field = field
def get_symbols(self):
symbols = set()
for f in self.polynomials:
symbols = set(symbols | f.atoms(Symbol))
return symbols
def get_coordinate_ring(self):
poly_ring = self.field.old_poly_ring(*self.get_symbols(),order="ilex")
return poly_ring / poly_ring.ideal(*self.polynomials)
from sympy.abc import x, y, z
print AlgebraicSet([y**2 - z*x, x*y*2 + z], QQ).get_coordinate_ring()
#1
2
Your code wasn't working for me, but I found using old_poly_ring
instead of poly_ring
did the trick:
您的代码对我不起作用,但我发现使用old_poly_ring而不是poly_ring就可以了:
from sympy import *
class AlgebraicSet(object):
def __init__(self, polynomials,field):
self.polynomials = polynomials
self.field = field
def get_symbols(self):
symbols = set()
for f in self.polynomials:
symbols = set(symbols | f.atoms(Symbol))
return symbols
def get_coordinate_ring(self):
poly_ring = self.field.old_poly_ring(*self.get_symbols(),order="ilex")
return poly_ring / poly_ring.ideal(*self.polynomials)
from sympy.abc import x, y, z
print AlgebraicSet([y**2 - z*x, x*y*2 + z], QQ).get_coordinate_ring()