本文整理汇总了Python中sympy.polys.polyclasses.DMP.from_list方法的典型用法代码示例。如果您正苦于以下问题:Python DMP.from_list方法的具体用法?Python DMP.from_list怎么用?Python DMP.from_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.polyclasses.DMP
的用法示例。
在下文中一共展示了DMP.from_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __new__
# 需要导入模块: from sympy.polys.polyclasses import DMP [as 别名]
# 或者: from sympy.polys.polyclasses.DMP import from_list [as 别名]
def __new__(cls, expr, coeffs=Tuple(), alias=None, **args):
"""Construct a new algebraic number. """
expr = sympify(expr)
if isinstance(expr, (tuple, Tuple)):
minpoly, root = expr
if not minpoly.is_Poly:
minpoly = Poly(minpoly)
elif expr.is_AlgebraicNumber:
minpoly, root = expr.minpoly, expr.root
else:
minpoly, root = minimal_polynomial(
expr, args.get('gen'), polys=True), expr
dom = minpoly.get_domain()
if coeffs != Tuple():
if not isinstance(coeffs, ANP):
rep = DMP.from_sympy_list(sympify(coeffs), 0, dom)
scoeffs = Tuple(*coeffs)
else:
rep = DMP.from_list(coeffs.to_list(), 0, dom)
scoeffs = Tuple(*coeffs.to_list())
if rep.degree() >= minpoly.degree():
rep = rep.rem(minpoly.rep)
sargs = (root, scoeffs)
else:
rep = DMP.from_list([1, 0], 0, dom)
if ask(Q.negative(root)):
rep = -rep
sargs = (root, coeffs)
if alias is not None:
if not isinstance(alias, Symbol):
alias = Symbol(alias)
sargs = sargs + (alias,)
obj = Expr.__new__(cls, *sargs)
obj.rep = rep
obj.root = root
obj.alias = alias
obj.minpoly = minpoly
return obj