本文整理汇总了Python中sympy.core.C.re方法的典型用法代码示例。如果您正苦于以下问题:Python C.re方法的具体用法?Python C.re怎么用?Python C.re使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.core.C
的用法示例。
在下文中一共展示了C.re方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _roots_trivial
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import re [as 别名]
def _roots_trivial(cls, poly, radicals):
"""Compute roots in linear, quadratic and binomial cases. """
if poly.degree() == 1:
return roots_linear(poly)
if not radicals:
return None
free = len(poly.free_symbols)
sort = isinstance(poly, PurePoly) and free or free > 1
if poly.degree() == 2:
roots = roots_quadratic(poly, sort=sort)
elif poly.length() == 2 and poly.TC():
roots = roots_binomial(poly, sort=sort)
else:
return None
# put roots in same order as RootOf instances
if not sort:
key = [r.n(2) for r in roots]
key = [(1 if not r.is_real else 0, C.re(r), C.im(r))
for r in key]
_, roots = zip(*sorted(zip(key, roots)))
return roots