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


Python ComplexIntervalField.real方法代码示例

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


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

示例1: _eval_

# 需要导入模块: from sage.rings.all import ComplexIntervalField [as 别名]
# 或者: from sage.rings.all.ComplexIntervalField import real [as 别名]
    def _eval_(self, x):
        """
        INPUT:

        -  ``x`` - a real number or a symbolic expression

        EXAMPLES::

            sage: dirac_delta(1)
            0
            sage: dirac_delta(0)
            dirac_delta(0)
            sage: dirac_delta(x)
            dirac_delta(x)
            sage: dirac_delta(exp(-10000000000000000000))
            0

        Evaluation test::

            sage: dirac_delta(x).subs(x=1)
            0
        """
        try:
            approx_x = ComplexIntervalField()(x)
            if bool(approx_x.imag() == 0):      # x is real
                if bool(approx_x.real() == 0):  # x is zero
                    return None
                else:
                    return 0
        except Exception:                     # x is symbolic
            pass
        return None
开发者ID:Etn40ff,项目名称:sage,代码行数:34,代码来源:generalized.py

示例2: _evalf_

# 需要导入模块: from sage.rings.all import ComplexIntervalField [as 别名]
# 或者: from sage.rings.all.ComplexIntervalField import real [as 别名]
    def _evalf_(self, x, **kwds):
        """
        TESTS:

        Check that :trac:`16587` is fixed::

            sage: M = sgn(3/2, hold=True); M
            sgn(3/2)
            sage: M.n()
            1
            sage: h(x) = sgn(x)
            sage: h(pi).numerical_approx()
            1.00000000000000
        """
        if hasattr(x,'sign'): # First check if x has a sign method
            return x.sign()
        if hasattr(x,'sgn'): # or a sgn method
            return x.sgn()
        approx_x = ComplexIntervalField()(x)
        if bool(approx_x.imag() == 0):      # x is real
            if bool(approx_x.real() == 0):  # x is zero
                return ZZ(0)
            # Now we have a non-zero real
            if bool((approx_x**(0.5)).imag() == 0): # Check: x > 0
                return ZZ(1)
            else:
                return ZZ(-1)
        raise ValueError("Numeric evaluation of symbolic expression")
开发者ID:sagemath,项目名称:sage,代码行数:30,代码来源:generalized.py

示例3: _is_numerically_zero_CIF

# 需要导入模块: from sage.rings.all import ComplexIntervalField [as 别名]
# 或者: from sage.rings.all.ComplexIntervalField import real [as 别名]
def _is_numerically_zero_CIF(x):
    from sage.rings.all import ComplexIntervalField
    try:
        approx_x = ComplexIntervalField()(x)
        if bool(approx_x.imag() == 0) and bool(approx_x.real() == 0):
            return True
    except:
        return False
开发者ID:benjaminfjones,项目名称:sage-devel,代码行数:10,代码来源:trac_11513_CIF.py

示例4: _evalf_

# 需要导入模块: from sage.rings.all import ComplexIntervalField [as 别名]
# 或者: from sage.rings.all.ComplexIntervalField import real [as 别名]
    def _evalf_(self, x, **kwds):
        """
        TESTS::

            sage: h(x) = unit_step(x)
            sage: h(pi).numerical_approx()
            1.00000000000000
        """
        approx_x = ComplexIntervalField()(x)
        if bool(approx_x.imag() == 0):      # x is real
            if bool(approx_x.real() == 0):  # x is zero
                return 1
            # Now we have a non-zero real
            if bool((approx_x**(0.5)).imag() == 0): # Check: x > 0
                return 1
            else:
                return 0
        raise ValueError("Numeric evaluation of symbolic expression")
开发者ID:robertwb,项目名称:sage,代码行数:20,代码来源:generalized.py


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