本文整理汇总了Python中sympy.polys.densebasic.dmp_inject函数的典型用法代码示例。如果您正苦于以下问题:Python dmp_inject函数的具体用法?Python dmp_inject怎么用?Python dmp_inject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dmp_inject函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dup_factor_list
def dup_factor_list(f, K0):
"""Factor univariate polynomials into irreducibles in `K[x]`. """
j, f = dup_terms_gcd(f, K0)
cont, f = dup_primitive(f, K0)
if K0.is_FiniteField:
coeff, factors = dup_gf_factor(f, K0)
elif K0.is_Algebraic:
coeff, factors = dup_ext_factor(f, K0)
else:
if not K0.is_Exact:
K0_inexact, K0 = K0, K0.get_exact()
f = dup_convert(f, K0_inexact, K0)
else:
K0_inexact = None
if K0.is_Field:
K = K0.get_ring()
denom, f = dup_clear_denoms(f, K0, K)
f = dup_convert(f, K0, K)
else:
K = K0
if K.is_ZZ:
coeff, factors = dup_zz_factor(f, K)
elif K.is_Poly:
f, u = dmp_inject(f, 0, K)
coeff, factors = dmp_factor_list(f, u, K.dom)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_eject(f, u, K), k)
coeff = K.convert(coeff, K.dom)
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)
if K0.is_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K, K0), k)
coeff = K0.convert(coeff, K)
coeff = K0.quo(coeff, denom)
if K0_inexact:
for i, (f, k) in enumerate(factors):
max_norm = dup_max_norm(f, K0)
f = dup_quo_ground(f, max_norm, K0)
f = dup_convert(f, K0, K0_inexact)
factors[i] = (f, k)
coeff = K0.mul(coeff, K0.pow(max_norm, k))
coeff = K0_inexact.convert(coeff, K0)
K0 = K0_inexact
if j:
factors.insert(0, ([K0.one, K0.zero], j))
return coeff*cont, _sort_factors(factors)
开发者ID:bjodah,项目名称:sympy,代码行数:60,代码来源:factortools.py
示例2: dup_factor_list
def dup_factor_list(f, K0, **args):
"""Factor polynomials into irreducibles in `K[x]`. """
if not K0.has_CharacteristicZero: # pragma: no cover
raise DomainError('only characteristic zero allowed')
if K0.is_Algebraic:
coeff, factors = dup_ext_factor(f, K0)
else:
if not K0.is_Exact:
K0_inexact, K0 = K0, K0.get_exact()
f = dup_convert(f, K0_inexact, K0)
else:
K0_inexact = None
if K0.has_Field:
K = K0.get_ring()
denom, f = dup_ground_to_ring(f, K0, K)
f = dup_convert(f, K0, K)
else:
K = K0
if K.is_ZZ:
coeff, factors = dup_zz_factor(f, K, **args)
elif K.is_Poly:
f, u = dmp_inject(f, 0, K)
coeff, factors = dmp_factor_list(f, u, K.dom, **args)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_eject(f, u, K), k)
coeff = K.convert(coeff, K.dom)
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)
if K0.has_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K, K0), k)
coeff = K0.convert(coeff, K)
denom = K0.convert(denom, K)
coeff = K0.quo(coeff, denom)
if K0_inexact is not None:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K0, K0_inexact), k)
coeff = K0_inexact.convert(coeff, K0)
if not args.get('include', False):
return coeff, factors
else:
if not factors:
return [(dup_strip([coeff]), 1)]
else:
g = dup_mul_ground(factors[0][0], coeff, K)
return [(g, factors[0][1])] + factors[1:]
开发者ID:Aang,项目名称:sympy,代码行数:59,代码来源:factortools.py
示例3: dup_factor_list
def dup_factor_list(f, K0):
"""Factor polynomials into irreducibles in `K[x]`. """
j, f = dup_terms_gcd(f, K0)
if not K0.has_CharacteristicZero:
coeff, factors = dup_gf_factor(f, K0)
elif K0.is_Algebraic:
coeff, factors = dup_ext_factor(f, K0)
else:
if not K0.is_Exact:
K0_inexact, K0 = K0, K0.get_exact()
f = dup_convert(f, K0_inexact, K0)
else:
K0_inexact = None
if K0.has_Field:
K = K0.get_ring()
denom, f = dup_clear_denoms(f, K0, K)
f = dup_convert(f, K0, K)
else:
K = K0
if K.is_ZZ:
coeff, factors = dup_zz_factor(f, K)
elif K.is_Poly:
f, u = dmp_inject(f, 0, K)
coeff, factors = dmp_factor_list(f, u, K.dom)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_eject(f, u, K), k)
coeff = K.convert(coeff, K.dom)
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)
if K0.has_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K, K0), k)
coeff = K0.convert(coeff, K)
denom = K0.convert(denom, K)
coeff = K0.quo(coeff, denom)
if K0_inexact is not None:
for i, (f, k) in enumerate(factors):
factors[i] = (dup_convert(f, K0, K0_inexact), k)
coeff = K0_inexact.convert(coeff, K0)
if j:
factors.insert(0, ([K0.one, K0.zero], j))
return coeff, _sort_factors(factors)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:56,代码来源:factortools.py
示例4: dmp_norm
def dmp_norm(f, u, K):
"""
Norm of ``f`` in ``K[X1, ..., Xn]``, often not square-free.
"""
if not K.is_Algebraic:
raise DomainError("ground domain must be algebraic")
g = dmp_raise(K.mod.rep, u + 1, 0, K.dom)
h, _ = dmp_inject(f, u, K, front=True)
return dmp_resultant(g, h, u + 1, K.dom)
开发者ID:cklb,项目名称:sympy,代码行数:11,代码来源:sqfreetools.py
示例5: dmp_sqf_norm
def dmp_sqf_norm(f, u, K):
"""
Square-free norm of ``f`` in ``K[X]``, useful over algebraic domains.
Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and ``r(x) = Norm(g(x))``
is a square-free polynomial over K, where ``a`` is the algebraic extension of ``K``.
Examples
========
>>> from sympy.polys import ring, QQ
>>> from sympy import I
>>> K = QQ.algebraic_field(I)
>>> R, x, y = ring("x,y", K)
>>> _, X, Y = ring("x,y", QQ)
>>> s, f, r = R.dmp_sqf_norm(x*y + y**2)
>>> s == 1
True
>>> f == x*y + y**2 + K([QQ(-1), QQ(0)])*y
True
>>> r == X**2*Y**2 + 2*X*Y**3 + Y**4 + Y**2
True
"""
if not u:
return dup_sqf_norm(f, K)
if not K.is_Algebraic:
raise DomainError("ground domain must be algebraic")
g = dmp_raise(K.mod.rep, u + 1, 0, K.dom)
F = dmp_raise([K.one, -K.unit], u, 0, K)
s = 0
while True:
h, _ = dmp_inject(f, u, K, front=True)
r = dmp_resultant(g, h, u + 1, K.dom)
if dmp_sqf_p(r, u, K.dom):
break
else:
f, s = dmp_compose(f, F, u, K), s + 1
return s, f, r
开发者ID:alhirzel,项目名称:sympy,代码行数:48,代码来源:sqfreetools.py
示例6: dmp_sqf_norm
def dmp_sqf_norm(f, u, K):
"""
Square-free norm of ``f`` in ``K[X]``, useful over algebraic domains.
Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and ``r(x) = Norm(g(x))``
is a square-free polynomial over K, where ``a`` is the algebraic extension of ``K``.
Examples
========
>>> from sympy import I
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.sqfreetools import dmp_sqf_norm
>>> K = QQ.algebraic_field(I)
>>> s, f, r = dmp_sqf_norm([[K(1), K(0)], [K(1), K(0), K(0)]], 1, K)
>>> s == 1
True
>>> f == [[K(1), K(0)], [K(1), K([QQ(-1), QQ(0)]), K(0)]]
True
>>> r == [[1, 0, 0], [2, 0, 0, 0], [1, 0, 1, 0, 0]]
True
"""
if not u:
return dup_sqf_norm(f, K)
if not K.is_Algebraic:
raise DomainError("ground domain must be algebraic")
g = dmp_raise(K.mod.rep, u + 1, 0, K.dom)
F = dmp_raise([K.one, -K.unit], u, 0, K)
s = 0
while True:
h, _ = dmp_inject(f, u, K, front=True)
r = dmp_resultant(g, h, u + 1, K.dom)
if dmp_sqf_p(r, u, K.dom):
break
else:
f, s = dmp_compose(f, F, u, K), s + 1
return s, f, r
开发者ID:FireJade,项目名称:sympy,代码行数:47,代码来源:sqfreetools.py
示例7: dup_sqf_norm
def dup_sqf_norm(f, K):
"""
Square-free norm of ``f`` in ``K[x]``, useful over algebraic domains.
Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and ``r(x) = Norm(g(x))``
is a square-free polynomial over K, where ``a`` is the algebraic extension of ``K``.
Examples
========
>>> from sympy.polys import ring, QQ
>>> from sympy import sqrt
>>> K = QQ.algebraic_field(sqrt(3))
>>> R, x = ring("x", K)
>>> _, X = ring("x", QQ)
>>> s, f, r = R.dup_sqf_norm(x**2 - 2)
>>> s == 1
True
>>> f == x**2 + K([QQ(-2), QQ(0)])*x + 1
True
>>> r == X**4 - 10*X**2 + 1
True
"""
if not K.is_Algebraic:
raise DomainError("ground domain must be algebraic")
s, g = 0, dmp_raise(K.mod.rep, 1, 0, K.dom)
while True:
h, _ = dmp_inject(f, 0, K, front=True)
r = dmp_resultant(g, h, 1, K.dom)
if dup_sqf_p(r, K.dom):
break
else:
f, s = dup_shift(f, -K.unit, K), s + 1
return s, f, r
开发者ID:alhirzel,项目名称:sympy,代码行数:42,代码来源:sqfreetools.py
示例8: test_dmp_inject
def test_dmp_inject():
K = ZZ['x','y']
assert dmp_inject([], 0, K) == ([[[]]], 2)
assert dmp_inject([[]], 1, K) == ([[[[]]]], 3)
assert dmp_inject([K([[1]])], 0, K) == ([[[1]]], 2)
assert dmp_inject([[K([[1]])]], 1, K) == ([[[[1]]]], 3)
assert dmp_inject([K([[1]]),K([[2],[3,4]])], 0, K) == ([[[1]],[[2],[3,4]]], 2)
f = [K([[3],[7,0],[5,0,0]]),K([[2],[]]),K([[]]),K([[1,0,0],[11]])]
g = [[[3],[7,0],[5,0,0]],[[2],[]],[[]],[[1,0,0],[11]]]
assert dmp_inject(f, 0, K) == (g, 2)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:15,代码来源:test_densebasic.py
示例9: test_dmp_inject
def test_dmp_inject():
R, x,y = ring("x,y", ZZ)
K = R.to_domain()
assert dmp_inject([], 0, K) == ([[[]]], 2)
assert dmp_inject([[]], 1, K) == ([[[[]]]], 3)
assert dmp_inject([R(1)], 0, K) == ([[[1]]], 2)
assert dmp_inject([[R(1)]], 1, K) == ([[[[1]]]], 3)
assert dmp_inject([R(1), 2*x + 3*y + 4], 0, K) == ([[[1]], [[2], [3, 4]]], 2)
f = [3*x**2 + 7*x*y + 5*y**2, 2*x, R(0), x*y**2 + 11]
g = [[[3], [7, 0], [5, 0, 0]], [[2], []], [[]], [[1, 0, 0], [11]]]
assert dmp_inject(f, 0, K) == (g, 2)
开发者ID:AALEKH,项目名称:sympy,代码行数:16,代码来源:test_densebasic.py
示例10: dup_sqf_norm
def dup_sqf_norm(f, K):
"""
Square-free norm of ``f`` in ``K[x]``, useful over algebraic domains.
Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and ``r(x) = Norm(g(x))``
is a square-free polynomial over K, where ``a`` is the algebraic extension of ``K``.
**Examples**
>>> from sympy import sqrt
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.sqfreetools import dup_sqf_norm
>>> K = QQ.algebraic_field(sqrt(3))
>>> s, f, r = dup_sqf_norm([K(1), K(0), K(-2)], K)
>>> s == 1
True
>>> f == [K(1), K([QQ(-2), QQ(0)]), K(1)]
True
>>> r == [1, 0, -10, 0, 1]
True
"""
if not K.is_Algebraic:
raise DomainError("ground domain must be algebraic")
s, g = 0, dmp_raise(K.mod.rep, 1, 0, K.dom)
while True:
h, _ = dmp_inject(f, 0, K, front=True)
r = dmp_resultant(g, h, 1, K.dom)
if dup_sqf_p(r, K.dom):
break
else:
f, s = dup_shift(f, -K.unit, K), s+1
return s, f, r
开发者ID:101man,项目名称:sympy,代码行数:40,代码来源:sqfreetools.py
示例11: dmp_factor_list
def dmp_factor_list(f, u, K0):
"""Factor polynomials into irreducibles in `K[X]`. """
if not u:
return dup_factor_list(f, K0)
J, f = dmp_terms_gcd(f, u, K0)
if not K0.has_CharacteristicZero: # pragma: no cover
coeff, factors = dmp_gf_factor(f, u, K0)
elif K0.is_Algebraic:
coeff, factors = dmp_ext_factor(f, u, K0)
else:
if not K0.is_Exact:
K0_inexact, K0 = K0, K0.get_exact()
f = dmp_convert(f, u, K0_inexact, K0)
else:
K0_inexact = None
if K0.has_Field:
K = K0.get_ring()
denom, f = dmp_clear_denoms(f, u, K0, K)
f = dmp_convert(f, u, K0, K)
else:
K = K0
if K.is_ZZ:
levels, f, v = dmp_exclude(f, u, K)
coeff, factors = dmp_zz_factor(f, v, K)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_include(f, levels, v, K), k)
elif K.is_Poly:
f, v = dmp_inject(f, u, K)
coeff, factors = dmp_factor_list(f, v, K.dom)
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_eject(f, v, K), k)
coeff = K.convert(coeff, K.dom)
else: # pragma: no cover
raise DomainError('factorization not supported over %s' % K0)
if K0.has_Field:
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_convert(f, u, K, K0), k)
coeff = K0.convert(coeff, K)
denom = K0.convert(denom, K)
coeff = K0.quo(coeff, denom)
if K0_inexact is not None:
for i, (f, k) in enumerate(factors):
factors[i] = (dmp_convert(f, u, K0, K0_inexact), k)
coeff = K0_inexact.convert(coeff, K0)
for i, j in enumerate(reversed(J)):
if not j:
continue
term = {(0,)*(u-i) + (1,) + (0,)*i: K0.one}
factors.insert(0, (dmp_from_dict(term, u, K0), j))
return coeff, _sort_factors(factors)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:67,代码来源:factortools.py
示例12: inject
def inject(f, front=False):
"""Inject ground domain generators into ``f``. """
F, lev = dmp_inject(f.rep, f.lev, f.dom, front=front)
return f.__class__(F, f.dom.dom, lev)
开发者ID:fxkr,项目名称:sympy,代码行数:4,代码来源:polyclasses.py
注:本文中的sympy.polys.densebasic.dmp_inject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论