本文整理汇总了Python中sympy.polys.densebasic.dmp_to_dict函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_to_dict函数的具体用法?Python dmp_to_dict怎么用?Python dmp_to_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_to_dict函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dmp_from_to_dict
def test_dmp_from_to_dict():
assert dmp_from_dict({}, 1, ZZ) == [[]]
assert dmp_to_dict([[]], 1) == {}
f = [[3],[],[],[2],[],[],[],[],[8]]
g = {(8,0): 3, (5,0): 2, (0,0): 8}
assert dmp_from_dict(g, 1, ZZ) == f
assert dmp_to_dict(f, 1) == g
开发者ID:addisonc,项目名称:sympy,代码行数:9,代码来源:test_densebasic.py
示例2: test_dmp_from_to_dict
def test_dmp_from_to_dict():
assert dmp_from_dict({}, 1, ZZ) == [[]]
assert dmp_to_dict([[]], 1) == {}
assert dmp_to_dict([], 0, ZZ, zero=True) == {(0,): ZZ(0)}
assert dmp_to_dict([[]], 1, ZZ, zero=True) == {(0,0): ZZ(0)}
f = [[3],[],[],[2],[],[],[],[],[8]]
g = {(8,0): 3, (5,0): 2, (0,0): 8}
assert dmp_from_dict(g, 1, ZZ) == f
assert dmp_to_dict(f, 1) == g
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:12,代码来源:test_densebasic.py
示例3: to_sympy_dict
def to_sympy_dict(f, zero=False):
"""Convert `f` to a dict representation with SymPy coefficients. """
rep = dmp_to_dict(f.rep, f.lev, f.dom, zero=zero)
for k, v in rep.iteritems():
rep[k] = f.dom.to_sympy(v)
return rep
开发者ID:fxkr,项目名称:sympy,代码行数:8,代码来源:polyclasses.py
示例4: to_sympy_dict
def to_sympy_dict(f):
"""Convert ``f`` to a dict representation with SymPy coefficients. """
rep = dmp_to_dict(f.rep, 0, f.dom)
for k, v in rep.iteritems():
rep[k] = f.dom.to_sympy(v)
return rep
开发者ID:Ryzh,项目名称:sympy,代码行数:8,代码来源:polyclasses.py
示例5: dmp_lift
def dmp_lift(f, u, K):
"""
Convert algebraic coefficients to integers in ``K[X]``.
Examples
========
>>> from sympy.polys import ring, QQ
>>> from sympy import I
>>> K = QQ.algebraic_field(I)
>>> R, x = ring("x", K)
>>> f = x**2 + K([QQ(1), QQ(0)])*x + K([QQ(2), QQ(0)])
>>> R.dmp_lift(f)
x**8 + 2*x**6 + 9*x**4 - 8*x**2 + 16
"""
if not K.is_Algebraic:
raise DomainError(
'computation can be done only in an algebraic domain')
F, monoms, polys = dmp_to_dict(f, u), [], []
for monom, coeff in F.items():
if not coeff.is_ground:
monoms.append(monom)
perms = variations([-1, 1], len(monoms), repetition=True)
for perm in perms:
G = dict(F)
for sign, monom in zip(perm, monoms):
if sign == -1:
G[monom] = -G[monom]
polys.append(dmp_from_dict(G, u, K))
return dmp_convert(dmp_expand(polys, u, K), u, K, K.dom)
开发者ID:asmeurer,项目名称:sympy,代码行数:41,代码来源:densetools.py
示例6: dmp_lift
def dmp_lift(f, u, K):
"""
Convert algebraic coefficients to integers in ``K[X]``.
Examples
========
>>> from sympy import I
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.densetools import dmp_lift
>>> K = QQ.algebraic_field(I)
>>> f = [K(1), K([QQ(1), QQ(0)]), K([QQ(2), QQ(0)])]
>>> dmp_lift(f, 0, K)
[1/1, 0/1, 2/1, 0/1, 9/1, 0/1, -8/1, 0/1, 16/1]
"""
if not K.is_Algebraic:
raise DomainError(
'computation can be done only in an algebraic domain')
F, monoms, polys = dmp_to_dict(f, u), [], []
for monom, coeff in F.iteritems():
if not coeff.is_ground:
monoms.append(monom)
perms = variations([-1, 1], len(monoms), repetition=True)
for perm in perms:
G = dict(F)
for sign, monom in zip(perm, monoms):
if sign == -1:
G[monom] = -G[monom]
polys.append(dmp_from_dict(G, u, K))
return dmp_convert(dmp_expand(polys, u, K), u, K, K.dom)
开发者ID:jenshnielsen,项目名称:sympy,代码行数:40,代码来源:densetools.py
示例7: is_quadratic
def is_quadratic(f):
"""Returns `True` if `f` is quadratic in all its variables. """
return all([ sum(monom) <= 2 for monom in dmp_to_dict(f.rep, f.lev, f.dom).keys() ])
开发者ID:fxkr,项目名称:sympy,代码行数:3,代码来源:polyclasses.py
示例8: is_linear
def is_linear(f):
"""Returns `True` if `f` is linear in all its variables. """
return all([ sum(monom) <= 1 for monom in dmp_to_dict(f.rep, f.lev, f.dom).keys() ])
开发者ID:fxkr,项目名称:sympy,代码行数:3,代码来源:polyclasses.py
示例9: to_dict
def to_dict(f, zero=False):
"""Convert `f` to a dict representation with native coefficients. """
return dmp_to_dict(f.rep, f.lev, f.dom, zero=zero)
开发者ID:fxkr,项目名称:sympy,代码行数:3,代码来源:polyclasses.py
注:本文中的sympy.polys.densebasic.dmp_to_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论