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


Python Q.finite方法代码示例

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


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

示例1: Mul

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import finite [as 别名]
    def Mul(expr, assumptions):
        """
        Return True if expr is bounded, False if not and None if unknown.

        Truth Table:

        +---+---+---+--------+
        |   |   |   |        |
        |   | B | U |   ?    |
        |   |   |   |        |
        +---+---+---+---+----+
        |   |   |   |   |    |
        |   |   |   | s | /s |
        |   |   |   |   |    |
        +---+---+---+---+----+
        |   |   |   |        |
        | B | B | U |   ?    |
        |   |   |   |        |
        +---+---+---+---+----+
        |   |   |   |   |    |
        | U |   | U | U | ?  |
        |   |   |   |   |    |
        +---+---+---+---+----+
        |   |   |   |        |
        | ? |   |   |   ?    |
        |   |   |   |        |
        +---+---+---+---+----+

            * B = Bounded

            * U = Unbounded

            * ? = unknown boundedness

            * s = signed (hence nonzero)

            * /s = not signed

        """
        result = True
        for arg in expr.args:
            _bounded = ask(Q.finite(arg), assumptions)
            if _bounded:
                continue
            elif _bounded is None:
                if result is None:
                    return None
                if ask(Q.nonzero(arg), assumptions) is None:
                    return None
                if result is not False:
                    result = None
            else:
                result = False
        return result
开发者ID:EuanFree,项目名称:sympy,代码行数:56,代码来源:calculus.py

示例2: Pow

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import finite [as 别名]
 def Pow(expr, assumptions):
     """
     Unbounded ** NonZero -> Unbounded
     Bounded ** Bounded -> Bounded
     Abs()<=1 ** Positive -> Bounded
     Abs()>=1 ** Negative -> Bounded
     Otherwise unknown
     """
     base_bounded = ask(Q.finite(expr.base), assumptions)
     exp_bounded = ask(Q.finite(expr.exp), assumptions)
     if base_bounded is None and exp_bounded is None:  # Common Case
         return None
     if base_bounded is False and ask(Q.nonzero(expr.exp), assumptions):
         return False
     if base_bounded and exp_bounded:
         return True
     if (abs(expr.base) <= 1) == True and ask(Q.positive(expr.exp), assumptions):
         return True
     if (abs(expr.base) >= 1) == True and ask(Q.negative(expr.exp), assumptions):
         return True
     if (abs(expr.base) >= 1) == True and exp_bounded is False:
         return False
     return None
开发者ID:EuanFree,项目名称:sympy,代码行数:25,代码来源:calculus.py

示例3: Symbol

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import finite [as 别名]
    def Symbol(expr, assumptions):
        """
        Handles Symbol.

        Examples
        ========

        >>> from sympy import Symbol, Q
        >>> from sympy.assumptions.handlers.calculus import AskFiniteHandler
        >>> from sympy.abc import x
        >>> a = AskFiniteHandler()
        >>> a.Symbol(x, Q.positive(x)) == None
        True
        >>> a.Symbol(x, Q.finite(x))
        True

        """
        if Q.finite(expr) in conjuncts(assumptions):
            return True
        return None
开发者ID:EuanFree,项目名称:sympy,代码行数:22,代码来源:calculus.py

示例4: Add

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import finite [as 别名]
    def Add(expr, assumptions):
        """
        Return True if expr is bounded, False if not and None if unknown.

        Truth Table:

        +-------+-----+-----------+-----------+
        |       |     |           |           |
        |       |  B  |     U     |     ?     |
        |       |     |           |           |
        +-------+-----+---+---+---+---+---+---+
        |       |     |   |   |   |   |   |   |
        |       |     |'+'|'-'|'x'|'+'|'-'|'x'|
        |       |     |   |   |   |   |   |   |
        +-------+-----+---+---+---+---+---+---+
        |       |     |           |           |
        |   B   |  B  |     U     |     ?     |
        |       |     |           |           |
        +---+---+-----+---+---+---+---+---+---+
        |   |   |     |   |   |   |   |   |   |
        |   |'+'|     | U | ? | ? | U | ? | ? |
        |   |   |     |   |   |   |   |   |   |
        |   +---+-----+---+---+---+---+---+---+
        |   |   |     |   |   |   |   |   |   |
        | U |'-'|     | ? | U | ? | ? | U | ? |
        |   |   |     |   |   |   |   |   |   |
        |   +---+-----+---+---+---+---+---+---+
        |   |   |     |           |           |
        |   |'x'|     |     ?     |     ?     |
        |   |   |     |           |           |
        +---+---+-----+---+---+---+---+---+---+
        |       |     |           |           |
        |   ?   |     |           |     ?     |
        |       |     |           |           |
        +-------+-----+-----------+---+---+---+

            * 'B' = Bounded

            * 'U' = Unbounded

            * '?' = unknown boundedness

            * '+' = positive sign

            * '-' = negative sign

            * 'x' = sign unknown

|

            * All Bounded -> True

            * 1 Unbounded and the rest Bounded -> False

            * >1 Unbounded, all with same known sign -> False

            * Any Unknown and unknown sign -> None

            * Else -> None

        When the signs are not the same you can have an undefined
        result as in oo - oo, hence 'bounded' is also undefined.

        """

        sign = -1  # sign of unknown or infinite
        result = True
        for arg in expr.args:
            _bounded = ask(Q.finite(arg), assumptions)
            if _bounded:
                continue
            s = ask(Q.positive(arg), assumptions)
            # if there has been more than one sign or if the sign of this arg
            # is None and Bounded is None or there was already
            # an unknown sign, return None
            if sign != -1 and s != sign or \
                    s is None and (s == _bounded or s == sign):
                return None
            else:
                sign = s
            # once False, do not change
            if result is not False:
                result = _bounded
        return result
开发者ID:EuanFree,项目名称:sympy,代码行数:86,代码来源:calculus.py

示例5: log

# 需要导入模块: from sympy.assumptions import Q [as 别名]
# 或者: from sympy.assumptions.Q import finite [as 别名]
 def log(expr, assumptions):
     return ask(Q.finite(expr.args[0]), assumptions)
开发者ID:EuanFree,项目名称:sympy,代码行数:4,代码来源:calculus.py


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