當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。