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


Python ZZ.old_poly_ring方法代码示例

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


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

示例1: test_localring

# 需要导入模块: from sympy.polys.domains import ZZ [as 别名]
# 或者: from sympy.polys.domains.ZZ import old_poly_ring [as 别名]
def test_localring():
    Qxy = QQ.old_frac_field(x, y)
    R = QQ.old_poly_ring(x, y, order="ilex")
    X = R.convert(x)
    Y = R.convert(y)

    assert x in R
    assert 1/x not in R
    assert 1/(1 + x) in R
    assert Y in R
    assert X.ring == R
    assert X*(Y**2 + 1)/(1 + X) == R.convert(x*(y**2 + 1)/(1 + x))
    assert X*y == X*Y
    raises(ExactQuotientFailed, lambda: X/Y)
    raises(ExactQuotientFailed, lambda: x/Y)
    raises(ExactQuotientFailed, lambda: X/y)
    assert X + y == X + Y == R.convert(x + y) == x + Y
    assert X - y == X - Y == R.convert(x - y) == x - Y
    assert X + 1 == R.convert(x + 1)
    assert X**2 / X == X

    assert R.from_GlobalPolynomialRing(ZZ.old_poly_ring(x, y).convert(x), ZZ.old_poly_ring(x, y)) == X
    assert R.from_FractionField(Qxy.convert(x), Qxy) == X
    raises(CoercionFailed, lambda: R.from_FractionField(Qxy.convert(x)/y, Qxy))
    raises(ExactQuotientFailed, lambda: X/Y)
    raises(NotReversible, lambda: X.invert())

    assert R._sdm_to_vector(
        R._vector_to_sdm([X/(X + 1), Y/(1 + X*Y)], R.order), 2) == \
        [X*(1 + X*Y), Y*(1 + X)]
开发者ID:AALEKH,项目名称:sympy,代码行数:32,代码来源:test_polynomialring.py

示例2: test_globalring

# 需要导入模块: from sympy.polys.domains import ZZ [as 别名]
# 或者: from sympy.polys.domains.ZZ import old_poly_ring [as 别名]
def test_globalring():
    Qxy = QQ.old_frac_field(x, y)
    R = QQ.old_poly_ring(x, y)
    X = R.convert(x)
    Y = R.convert(y)

    assert x in R
    assert 1/x not in R
    assert 1/(1 + x) not in R
    assert Y in R
    assert X.ring == R
    assert X * (Y**2 + 1) == R.convert(x * (y**2 + 1))
    assert X * y == X * Y == R.convert(x * y) == x * Y
    assert X + y == X + Y == R.convert(x + y) == x + Y
    assert X - y == X - Y == R.convert(x - y) == x - Y
    assert X + 1 == R.convert(x + 1)
    raises(ExactQuotientFailed, lambda: X/Y)
    raises(ExactQuotientFailed, lambda: x/Y)
    raises(ExactQuotientFailed, lambda: X/y)
    assert X**2 / X == X

    assert R.from_GlobalPolynomialRing(ZZ.old_poly_ring(x, y).convert(x), ZZ.old_poly_ring(x, y)) == X
    assert R.from_FractionField(Qxy.convert(x), Qxy) == X
    assert R.from_FractionField(Qxy.convert(x)/y, Qxy) is None

    assert R._sdm_to_vector(R._vector_to_sdm([X, Y], R.order), 2) == [X, Y]
开发者ID:AALEKH,项目名称:sympy,代码行数:28,代码来源:test_polynomialring.py

示例3: _normalize

# 需要导入模块: from sympy.polys.domains import ZZ [as 别名]
# 或者: from sympy.polys.domains.ZZ import old_poly_ring [as 别名]
def _normalize(list_of, parent, negative=True):
    """
    Normalize a given annihilator
    """

    num = []
    denom = []
    base = parent.base
    K = base.get_field()
    R = ZZ.old_poly_ring(base.gens[0])
    lcm_denom = R.from_sympy(S(1))
    list_of_coeff = []

    # convert polynomials to the elements of associated
    # fraction field
    for i, j in enumerate(list_of):
        if isinstance(j, base.dtype):
            list_of_coeff.append(K.new(j.rep))
        elif not isinstance(j, K.dtype):
            list_of_coeff.append(K.from_sympy(sympify(j)))
        else:
            list_of_coeff.append(j)

        # corresponding numerators of the sequence of polynomials
        num.append(base(list_of_coeff[i].num))

        # corresponding denominators
        den = list_of_coeff[i].den
        if isinstance(den[0], PythonRational):
            for i, j in enumerate(den):
                den[i] = j.p

        denom.append(R(den))

    # lcm of denominators in the coefficients
    for i in denom:
        lcm_denom = i.lcm(lcm_denom)

    if negative is True:
        lcm_denom = -lcm_denom

    lcm_denom = K.new(lcm_denom.rep)

    # multiply the coefficients with lcm
    for i, j in enumerate(list_of_coeff):
        list_of_coeff[i] = j * lcm_denom

    gcd_numer = base.from_FractionField(list_of_coeff[-1], K)

    # gcd of numerators in the coefficients
    for i in num:
        gcd_numer = i.gcd(gcd_numer)

    gcd_numer = K.new(gcd_numer.rep)

    # divide all the coefficients by the gcd
    for i, j in enumerate(list_of_coeff):
        list_of_coeff[i] = base.from_FractionField(j / gcd_numer, K)

    return DifferentialOperator(list_of_coeff, parent)
开发者ID:Carreau,项目名称:sympy,代码行数:62,代码来源:holonomic.py

示例4: test_units

# 需要导入模块: from sympy.polys.domains import ZZ [as 别名]
# 或者: from sympy.polys.domains.ZZ import old_poly_ring [as 别名]
def test_units():
    R = QQ.old_poly_ring(x)
    assert R.is_unit(R.convert(1))
    assert R.is_unit(R.convert(2))
    assert not R.is_unit(R.convert(x))
    assert not R.is_unit(R.convert(1 + x))

    R = QQ.old_poly_ring(x, order='ilex')
    assert R.is_unit(R.convert(1))
    assert R.is_unit(R.convert(2))
    assert not R.is_unit(R.convert(x))
    assert R.is_unit(R.convert(1 + x))

    R = ZZ.old_poly_ring(x)
    assert R.is_unit(R.convert(1))
    assert not R.is_unit(R.convert(2))
    assert not R.is_unit(R.convert(x))
    assert not R.is_unit(R.convert(1 + x))
开发者ID:AALEKH,项目名称:sympy,代码行数:20,代码来源:test_polynomialring.py

示例5: _normalize

# 需要导入模块: from sympy.polys.domains import ZZ [as 别名]
# 或者: from sympy.polys.domains.ZZ import old_poly_ring [as 别名]
def _normalize(list_of, parent, negative=True):
    """
    Normalize a given annihilator
    """

    num = []
    denom = []
    base = parent.base
    K = base.get_field()
    R = ZZ.old_poly_ring(base.gens[0])
    lcm_denom = R.from_sympy(S(1))
    list_of_coeff = []

    for i, j in enumerate(list_of):
        if not isinstance(j, K.dtype):
            list_of_coeff.append(K.from_sympy(sympify(j)))
        else:
            list_of_coeff.append(j)
        num.append(base(list_of_coeff[i].num))
        den = list_of_coeff[i].den
        if isinstance(den[0], PythonRational):
            for i, j in enumerate(den):
                den[i] = j.p
        denom.append(R(den))

    for i in denom:
        lcm_denom = i.lcm(lcm_denom)

    if negative is True:
        lcm_denom = -lcm_denom

    lcm_denom = K.new(lcm_denom.rep)

    for i, j in enumerate(list_of_coeff):
        list_of_coeff[i] = j * lcm_denom

    gcd_numer = base.from_FractionField(list_of_coeff[-1], K)
    for i in num:
        gcd_numer = i.gcd(gcd_numer)
    gcd_numer = K.new(gcd_numer.rep)
    for i, j in enumerate(list_of_coeff):
        list_of_coeff[i] = base.from_FractionField(j / gcd_numer, K)

    return DifferentialOperator(list_of_coeff, parent)
开发者ID:ChristinaZografou,项目名称:sympy,代码行数:46,代码来源:holonomic.py


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