本文整理汇总了Python中sage.rings.all.ComplexIntervalField类的典型用法代码示例。如果您正苦于以下问题:Python ComplexIntervalField类的具体用法?Python ComplexIntervalField怎么用?Python ComplexIntervalField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComplexIntervalField类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _eval_
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,代码行数:32,代码来源:generalized.py
示例2: _evalf_
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,代码行数:28,代码来源:generalized.py
示例3: _is_numerically_zero_CIF
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,代码行数:8,代码来源:trac_11513_CIF.py
示例4: _evalf_
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,代码行数:18,代码来源:generalized.py
注:本文中的sage.rings.all.ComplexIntervalField类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论