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


Python Q.algebraic方法代码示例

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


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

示例1: _construct_simple

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def _construct_simple(coeffs, opt):
    """Handle simple domains, e.g.: ZZ, QQ, RR and algebraic domains. """
    result, rationals, reals, algebraics = {}, False, False, False

    if opt.extension is True:
        is_algebraic = lambda coeff: ask(Q.algebraic(coeff))
    else:
        is_algebraic = lambda coeff: False

    # XXX: add support for a + b*I coefficients
    for coeff in coeffs:
        if coeff.is_Rational:
            if not coeff.is_Integer:
                rationals = True
        elif coeff.is_Float:
            if not algebraics:
                reals = True
            else:
                # there are both reals and algebraics -> EX
                return False
        elif is_algebraic(coeff):
            if not reals:
                algebraics = True
            else:
                # there are both algebraics and reals -> EX
                return False
        else:
            # this is a composite domain, e.g. ZZ[X], EX
            return None

    if algebraics:
        domain, result = _construct_algebraic(coeffs, opt)
    else:
        if reals:
            domain = RR
        else:
            if opt.field or rationals:
                domain = QQ
            else:
                domain = ZZ

        result = []

        for coeff in coeffs:
            result.append(domain.from_sympy(coeff))

    return domain, result
开发者ID:FireJade,项目名称:sympy,代码行数:49,代码来源:constructor.py

示例2: Pow

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
 def Pow(expr, assumptions):
     return expr.exp.is_Rational and ask(
         Q.algebraic(expr.base), assumptions)
开发者ID:Tarang1993,项目名称:sympy,代码行数:5,代码来源:sets.py

示例3: log

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
 def log(expr, assumptions):
     x = expr.args[0]
     if ask(Q.algebraic(x), assumptions):
         return ask(~Q.nonzero(x - 1), assumptions)
开发者ID:Davidjohnwilson,项目名称:sympy,代码行数:6,代码来源:sets.py

示例4: cot

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
 def cot(expr, assumptions):
     x = expr.args[0]
     if ask(Q.algebraic(x), assumptions):
         return False
开发者ID:Davidjohnwilson,项目名称:sympy,代码行数:6,代码来源:sets.py

示例5: _is_coeff

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
 def _is_coeff(factor):
     return ask(Q.algebraic(factor))
开发者ID:ALGHeArT,项目名称:sympy,代码行数:4,代码来源:polyutils.py

示例6: test_algebraic

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import algebraic [as 别名]
def test_algebraic():
    x, y = symbols('x,y')

    assert ask(Q.algebraic(x)) == None

    assert ask(Q.algebraic(I)) == True
    assert ask(Q.algebraic(2*I)) == True
    assert ask(Q.algebraic(I/3)) == True

    assert ask(Q.algebraic(sqrt(7))) == True
    assert ask(Q.algebraic(2*sqrt(7))) == True
    assert ask(Q.algebraic(sqrt(7)/3)) == True

    assert ask(Q.algebraic(I*sqrt(3))) == True
    assert ask(Q.algebraic(sqrt(1+I*sqrt(3)))) == True

    assert ask(Q.algebraic((1+I*sqrt(3)**(S(17)/31)))) == True
    assert ask(Q.algebraic((1+I*sqrt(3)**(S(17)/pi)))) == False

    assert ask(Q.algebraic(sin(7))) == None
    assert ask(Q.algebraic(sqrt(sin(7)))) == None
    assert ask(Q.algebraic(sqrt(y+I*sqrt(7)))) == None

    assert ask(Q.algebraic(oo)) == False
    assert ask(Q.algebraic(-oo)) == False

    assert ask(Q.algebraic(2.47)) == False
开发者ID:lazovich,项目名称:sympy,代码行数:29,代码来源:test_query.py


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