当前位置: 首页>>代码示例>>Python>>正文


Python QQ.poly_ring方法代码示例

本文整理汇总了Python中sympy.polys.QQ.poly_ring方法的典型用法代码示例。如果您正苦于以下问题:Python QQ.poly_ring方法的具体用法?Python QQ.poly_ring怎么用?Python QQ.poly_ring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.polys.QQ的用法示例。


在下文中一共展示了QQ.poly_ring方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_FreeModule

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_FreeModule():
    M1 = FreeModule(QQ[x], 2)
    assert M1 == FreeModule(QQ[x], 2)
    assert M1 != FreeModule(QQ[y], 2)
    assert M1 != FreeModule(QQ[x], 3)
    M2 = FreeModule(QQ.poly_ring(x, order="ilex"), 2)

    assert [x, 1] in M1
    assert [x] not in M1
    assert [2, y] not in M1
    assert [1/(x + 1), 2] not in M1

    e = M1.convert([x, x**2 + 1])
    X = QQ[x].convert(x)
    assert e == [X, X**2 + 1]
    assert e == [x, x**2 + 1]
    assert 2*e == [2*x, 2*x**2 + 2]
    assert e*2 == [2*x, 2*x**2 + 2]
    assert e/2 == [x/2, (x**2 + 1)/2]
    assert x*e == [x**2, x**3 + x]
    assert e*x == [x**2, x**3 + x]
    assert X*e == [x**2, x**3 + x]
    assert e*X == [x**2, x**3 + x]

    assert [x, 1] in M2
    assert [x] not in M2
    assert [2, y] not in M2
    assert [1/(x + 1), 2] in M2

    e = M2.convert([x, x**2 + 1])
    X = QQ.poly_ring(x, order="ilex").convert(x)
    assert e == [X, X**2 + 1]
    assert e == [x, x**2 + 1]
    assert 2*e == [2*x, 2*x**2 + 2]
    assert e*2 == [2*x, 2*x**2 + 2]
    assert e/2 == [x/2, (x**2 + 1)/2]
    assert x*e == [x**2, x**3 + x]
    assert e*x == [x**2, x**3 + x]
    assert e/(1 + x) == [x/(1 + x), (x**2 + 1)/(1 + x)]
    assert X*e == [x**2, x**3 + x]
    assert e*X == [x**2, x**3 + x]

    M3 = FreeModule(QQ[x, y], 2)
    assert M3.convert(e) == M3.convert([x, x**2 + 1])

    assert not M3.is_submodule(0)
    assert not M3.is_zero()

    raises(NotImplementedError, lambda: ZZ[x].free_module(2))
    raises(NotImplementedError, lambda: FreeModulePolyRing(ZZ, 2))
    raises(CoercionFailed, lambda: M1.convert(QQ[x].free_module(3)
           .convert([1, 2, 3])))
    raises(CoercionFailed, lambda: M3.convert(1))
开发者ID:jenshnielsen,项目名称:sympy,代码行数:55,代码来源:test_modules.py

示例2: test_SubModulePolyRing_local

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_SubModulePolyRing_local():
    R = QQ.poly_ring(x, y, order=ilex)
    F = R.free_module(3)
    Fd = F.submodule([1+x, 0, 0], [1+y, 2+2*y, 0], [1, 2, 3])
    M = F.submodule([x**2 + y**2, 1, 0], [x, y, 1])

    assert F == Fd
    assert Fd == F
    assert F != M
    assert M != F
    assert Fd != M
    assert M != Fd
    assert Fd == F.submodule(*F.basis())

    assert Fd.is_full_module()
    assert not M.is_full_module()
    assert not Fd.is_zero()
    assert not M.is_zero()
    assert Fd.submodule().is_zero()

    assert M.contains([x**2 + y**2 + x, 1 + y, 1])
    assert not M.contains([x**2 + y**2 + x, 1 + y, 2])
    assert M.contains([y**2, 1 - x*y, -x])

    assert F.submodule([1 + x, 0, 0]) == F.submodule([1, 0, 0])
    assert F.submodule([1, 0, 0], [0, 1, 0]).union(F.submodule([0, 0, 1 + x*y])) == F

    raises(ValueError, lambda: M.submodule([1, 0, 0]))
开发者ID:piyushbansal,项目名称:sympy,代码行数:30,代码来源:test_modules.py

示例3: test_intersection

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_intersection():
    R = QQ[x, y, z]
    # SCA, example 1.8.11
    assert R.ideal(x, y).intersect(R.ideal(y**2, z)) == R.ideal(y**2, y*z, x*z)

    assert R.ideal(x, y).intersect(R.ideal()).is_zero()

    R = QQ.poly_ring(x, y, z, order="ilex")
    assert R.ideal(x, y).intersect(R.ideal(y**2 + y**2*z, z + z*x**3*y)) == \
           R.ideal(y**2, y*z, x*z)
开发者ID:StefenYin,项目名称:sympy,代码行数:12,代码来源:test_ideals.py

示例4: test_nontriv_local

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_nontriv_local():
    R = QQ.poly_ring(x, y, z, order=ilex)
    def contains(I, f):
        return R.ideal(*I).contains(f)

    assert contains([x, y], x)
    assert contains([x, y], x + y)
    assert not contains([x, y], 1)
    assert not contains([x, y], z)
    assert contains([x**2 + y, x**2 + x], x - y)
    assert not contains([x+y+z, x*y+x*z+y*z, x*y*z], x**2)
    assert contains([x*(1+x+y), y*(1+z)], x)
    assert contains([x*(1+x+y), y*(1+z)], x + y)
开发者ID:piyushbansal,项目名称:sympy,代码行数:15,代码来源:test_ideals.py

示例5: test_in_terms_of_generators

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_in_terms_of_generators():
    R = QQ.poly_ring(x, order="ilex")
    M = R.free_module(2).submodule([2*x, 0], [1, 2])
    assert M.in_terms_of_generators([x, x]) == [R.convert(S(1)/4), R.convert(x/2)]
    raises(ValueError, lambda: M.in_terms_of_generators([1, 0]))

    M = R.free_module(2) / ([x, 0], [1, 1])
    SM = M.submodule([1, x])
    assert SM.in_terms_of_generators([2, 0]) == [R.convert(2)]

    R = QQ[x, y] / [x**2 - y**2]
    M = R.free_module(2)
    SM = M.submodule([x, 0], [0, y])
    assert SM.in_terms_of_generators([x**2, x**2]) == [R.convert(x), R.convert(y)]
开发者ID:piyushbansal,项目名称:sympy,代码行数:16,代码来源:test_modules.py

示例6: test_SubModulePolyRing_nontriv_local

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_SubModulePolyRing_nontriv_local():
    R = QQ.poly_ring(x, y, z, order=ilex)
    F = R.free_module(1)
    def contains(I, f):
        return F.submodule(*[[g] for g in I]).contains([f])

    assert contains([x, y], x)
    assert contains([x, y], x + y)
    assert not contains([x, y], 1)
    assert not contains([x, y], z)
    assert contains([x**2 + y, x**2 + x], x - y)
    assert not contains([x+y+z, x*y+x*z+y*z, x*y*z], x**2)
    assert contains([x*(1+x+y), y*(1+z)], x)
    assert contains([x*(1+x+y), y*(1+z)], x + y)
开发者ID:piyushbansal,项目名称:sympy,代码行数:16,代码来源:test_modules.py

示例7: test_FreeModuleElement

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_FreeModuleElement():
    M = QQ[x].free_module(3)
    e = M.convert([1, x, x**2])
    f = [QQ[x].convert(1), QQ[x].convert(x), QQ[x].convert(x**2)]
    assert list(e) == f
    assert f[0] == e[0]
    assert f[1] == e[1]
    assert f[2] == e[2]
    raises(IndexError, lambda: e[3])

    g = M.convert([x, 0, 0])
    assert e + g == M.convert([x + 1, x, x**2])
    assert f + g == M.convert([x + 1, x, x**2])
    assert -e == M.convert([-1, -x, -x**2])
    assert e - g == M.convert([1 - x, x, x**2])
    assert e != g

    assert M.convert([x, x, x]) / QQ[x].convert(x) == [1, 1, 1]
    R = QQ.poly_ring(x, order="ilex")
    assert R.free_module(1).convert([x]) / R.convert(x) == [1]
开发者ID:piyushbansal,项目名称:sympy,代码行数:22,代码来源:test_modules.py

示例8: test_ModulesQuotientRing

# 需要导入模块: from sympy.polys import QQ [as 别名]
# 或者: from sympy.polys.QQ import poly_ring [as 别名]
def test_ModulesQuotientRing():
    R = QQ.poly_ring(x, y, order=(("lex", x), ("ilex", y))) / [x**2 + 1]
    M1 = R.free_module(2)
    assert M1 == R.free_module(2)
    assert M1 != QQ[x].free_module(2)
    assert M1 != R.free_module(3)

    assert [x, 1] in M1
    assert [x] not in M1
    assert [1/(R.convert(x) + 1), 2] in M1
    assert [1, 2/(1 + y)] in M1
    assert [1, 2/y] not in M1

    assert M1.convert([x**2, y]) == [-1, y]

    F = R.free_module(3)
    Fd = F.submodule([x**2, 0, 0], [1, 2, 0], [1, 2, 3])
    M = F.submodule([x**2 + y**2, 1, 0], [x, y, 1])

    assert F == Fd
    assert Fd == F
    assert F != M
    assert M != F
    assert Fd != M
    assert M != Fd
    assert Fd == F.submodule(*F.basis())

    assert Fd.is_full_module()
    assert not M.is_full_module()
    assert not Fd.is_zero()
    assert not M.is_zero()
    assert Fd.submodule().is_zero()

    assert M.contains([x**2 + y**2 + x, -x**2 + y, 1])
    assert not M.contains([x**2 + y**2 + x, 1 + y, 2])
    assert M.contains([y**2, 1 - x*y, -x])

    assert F.submodule([x, 0, 0]) == F.submodule([1, 0, 0])
    assert not F.submodule([y, 0, 0]) == F.submodule([1, 0, 0])
    assert F.submodule([1, 0, 0], [0, 1, 0]).union(F.submodule([0, 0, 1])) == F
    assert not M.is_submodule(0)
开发者ID:piyushbansal,项目名称:sympy,代码行数:43,代码来源:test_modules.py


注:本文中的sympy.polys.QQ.poly_ring方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。