本文整理汇总了Python中sympy.polys.densearith.dup_mul函数的典型用法代码示例。如果您正苦于以下问题:Python dup_mul函数的具体用法?Python dup_mul怎么用?Python dup_mul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dup_mul函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: dup_transform
def dup_transform(f, p, q, K):
"""
Evaluate functional transformation ``q**n * f(p/q)`` in ``K[x]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)
>>> R.dup_transform(x**2 - 2*x + 1, x**2 + 1, x - 1)
x**4 - 2*x**3 + 5*x**2 - 4*x + 4
"""
if not f:
return []
n = len(f) - 1
h, Q = [f[0]], [[K.one]]
for i in range(0, n):
Q.append(dup_mul(Q[-1], q, K))
for c, q in zip(f[1:], Q[1:]):
h = dup_mul(h, p, K)
q = dup_mul_ground(q, c, K)
h = dup_add(h, q, K)
return h
开发者ID:asmeurer,项目名称:sympy,代码行数:29,代码来源:densetools.py
示例2: dup_transform
def dup_transform(f, p, q, K):
"""
Evaluate functional transformation ``q**n * f(p/q)`` in ``K[x]``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densetools import dup_transform
>>> f = ZZ.map([1, -2, 1])
>>> p = ZZ.map([1, 0, 1])
>>> q = ZZ.map([1, -1])
>>> dup_transform(f, p, q, ZZ)
[1, -2, 5, -4, 4]
"""
if not f:
return []
n = dup_degree(f)
h, Q = [f[0]], [[K.one]]
for i in xrange(0, n):
Q.append(dup_mul(Q[-1], q, K))
for c, q in zip(f[1:], Q[1:]):
h = dup_mul(h, p, K)
q = dup_mul_ground(q, c, K)
h = dup_add(h, q, K)
return h
开发者ID:jenshnielsen,项目名称:sympy,代码行数:33,代码来源:densetools.py
示例3: test_dup_gcdex
def test_dup_gcdex():
f = dup_normal([1,-2,-6,12,15], QQ)
g = dup_normal([1,1,-4,-4], QQ)
s = [QQ(-1,5),QQ(3,5)]
t = [QQ(1,5),QQ(-6,5),QQ(2)]
h = [QQ(1),QQ(1)]
assert dup_half_gcdex(f, g, QQ) == (s, h)
assert dup_gcdex(f, g, QQ) == (s, t, h)
f = dup_normal([1,4,0,-1,1], QQ)
g = dup_normal([1,0,-1,1], QQ)
s, t, h = dup_gcdex(f, g, QQ)
S, T, H = dup_gcdex(g, f, QQ)
assert dup_add(dup_mul(s, f, QQ),
dup_mul(t, g, QQ), QQ) == h
assert dup_add(dup_mul(S, g, QQ),
dup_mul(T, f, QQ), QQ) == H
f = dup_normal([2,0], QQ)
g = dup_normal([1,0,-16], QQ)
s = [QQ(1,32),QQ(0)]
t = [QQ(-1,16)]
h = [QQ(1)]
assert dup_half_gcdex(f, g, QQ) == (s, h)
assert dup_gcdex(f, g, QQ) == (s, t, h)
开发者ID:addisonc,项目名称:sympy,代码行数:31,代码来源:test_euclidtools.py
示例4: test_dmp_mul
def test_dmp_mul():
assert dmp_mul([ZZ(5)], [ZZ(7)], 0, ZZ) == dup_mul([ZZ(5)], [ZZ(7)], ZZ)
assert dmp_mul([QQ(5, 7)], [QQ(3, 7)], 0, QQ) == dup_mul([QQ(5, 7)], [QQ(3, 7)], QQ)
assert dmp_mul([[[]]], [[[]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[ZZ(1)]]], [[[]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[]]], [[[ZZ(1)]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[ZZ(2)]]], [[[ZZ(1)]]], 2, ZZ) == [[[ZZ(2)]]]
assert dmp_mul([[[ZZ(1)]]], [[[ZZ(2)]]], 2, ZZ) == [[[ZZ(2)]]]
assert dmp_mul([[[]]], [[[]]], 2, QQ) == [[[]]]
assert dmp_mul([[[QQ(1, 2)]]], [[[]]], 2, QQ) == [[[]]]
assert dmp_mul([[[]]], [[[QQ(1, 2)]]], 2, QQ) == [[[]]]
assert dmp_mul([[[QQ(2, 7)]]], [[[QQ(1, 3)]]], 2, QQ) == [[[QQ(2, 21)]]]
assert dmp_mul([[[QQ(1, 7)]]], [[[QQ(2, 3)]]], 2, QQ) == [[[QQ(2, 21)]]]
开发者ID:unix0000,项目名称:sympy-polys,代码行数:15,代码来源:test_densearith.py
示例5: dup_compose
def dup_compose(f, g, K):
"""
Evaluate functional composition ``f(g)`` in ``K[x]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)
>>> R.dup_compose(x**2 + x, x - 1)
x**2 - x
"""
if len(g) <= 1:
return dup_strip([dup_eval(f, dup_LC(g, K), K)])
if not f:
return []
h = [f[0]]
for c in f[1:]:
h = dup_mul(h, g, K)
h = dup_add_term(h, c, 0, K)
return h
开发者ID:asmeurer,项目名称:sympy,代码行数:27,代码来源:densetools.py
示例6: dup_gff_list
def dup_gff_list(f, K):
"""
Compute greatest factorial factorization of ``f`` in ``K[x]``.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)
>>> R.dup_gff_list(x**5 + 2*x**4 - x**3 - 2*x**2)
[(x, 1), (x + 2, 4)]
"""
if not f:
raise ValueError("greatest factorial factorization doesn't exist for a zero polynomial")
f = dup_monic(f, K)
if not dup_degree(f):
return []
else:
g = dup_gcd(f, dup_shift(f, K.one, K), K)
H = dup_gff_list(g, K)
for i, (h, k) in enumerate(H):
g = dup_mul(g, dup_shift(h, -K(k), K), K)
H[i] = (h, k + 1)
f = dup_quo(f, g, K)
if not dup_degree(f):
return H
else:
return [(f, 1)] + H
开发者ID:alhirzel,项目名称:sympy,代码行数:35,代码来源:sqfreetools.py
示例7: dup_rr_lcm
def dup_rr_lcm(f, g, K):
"""
Computes polynomial LCM over a ring in ``K[x]``.
**Examples**
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.euclidtools import dup_rr_lcm
>>> f = ZZ.map([1, 0, -1])
>>> g = ZZ.map([1, -3, 2])
>>> dup_rr_lcm(f, g, ZZ)
[1, -2, -1, 2]
"""
fc, f = dup_primitive(f, K)
gc, g = dup_primitive(g, K)
c = K.lcm(fc, gc)
h = dup_exquo(dup_mul(f, g, K),
dup_gcd(f, g, K), K)
return dup_mul_ground(h, c, K)
开发者ID:addisonc,项目名称:sympy,代码行数:25,代码来源:euclidtools.py
示例8: dup_compose
def dup_compose(f, g, K):
"""
Evaluate functional composition ``f(g)`` in ``K[x]``.
Examples
========
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.densetools import dup_compose
>>> f = ZZ.map([1, 1, 0])
>>> g = ZZ.map([1, -1])
>>> dup_compose(f, g, ZZ)
[1, -1, 0]
"""
if len(g) <= 1:
return dup_strip([dup_eval(f, dup_LC(g, K), K)])
if not f:
return []
h = [f[0]]
for c in f[1:]:
h = dup_mul(h, g, K)
h = dup_add_term(h, c, 0, K)
return h
开发者ID:jenshnielsen,项目名称:sympy,代码行数:30,代码来源:densetools.py
示例9: dup_revert
def dup_revert(f, n, K):
"""
Compute ``f**(-1)`` mod ``x**n`` using Newton iteration.
This function computes first ``2**n`` terms of a polynomial that
is a result of inversion of a polynomial modulo ``x**n``. This is
useful to efficiently compute series expansion of ``1/f``.
Examples
========
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.densetools import dup_revert
>>> f = [-QQ(1,720), QQ(0), QQ(1,24), QQ(0), -QQ(1,2), QQ(0), QQ(1)]
>>> dup_revert(f, 8, QQ)
[61/720, 0/1, 5/24, 0/1, 1/2, 0/1, 1/1]
"""
g = [K.revert(dup_TC(f, K))]
h = [K.one, K.zero, K.zero]
N = int(_ceil(_log(n, 2)))
for i in xrange(1, N + 1):
a = dup_mul_ground(g, K(2), K)
b = dup_mul(f, dup_sqr(g, K), K)
g = dup_rem(dup_sub(a, b, K), h, K)
h = dup_lshift(h, dup_degree(h), K)
return g
开发者ID:jenshnielsen,项目名称:sympy,代码行数:32,代码来源:densetools.py
示例10: dup_revert
def dup_revert(f, n, K):
"""
Compute ``f**(-1)`` mod ``x**n`` using Newton iteration.
This function computes first ``2**n`` terms of a polynomial that
is a result of inversion of a polynomial modulo ``x**n``. This is
useful to efficiently compute series expansion of ``1/f``.
Examples
========
>>> from sympy.polys import ring, QQ
>>> R, x = ring("x", QQ)
>>> f = -QQ(1,720)*x**6 + QQ(1,24)*x**4 - QQ(1,2)*x**2 + 1
>>> R.dup_revert(f, 8)
61/720*x**6 + 5/24*x**4 + 1/2*x**2 + 1
"""
g = [K.revert(dup_TC(f, K))]
h = [K.one, K.zero, K.zero]
N = int(_ceil(_log(n, 2)))
for i in range(1, N + 1):
a = dup_mul_ground(g, K(2), K)
b = dup_mul(f, dup_sqr(g, K), K)
g = dup_rem(dup_sub(a, b, K), h, K)
h = dup_lshift(h, dup_degree(h), K)
return g
开发者ID:asmeurer,项目名称:sympy,代码行数:32,代码来源:densetools.py
示例11: dup_zz_hensel_step
def dup_zz_hensel_step(m, f, g, h, s, t, K):
"""
One step in Hensel lifting in `Z[x]`.
Given positive integer `m` and `Z[x]` polynomials `f`, `g`, `h`, `s`
and `t` such that::
f == g*h (mod m)
s*g + t*h == 1 (mod m)
lc(f) is not a zero divisor (mod m)
lc(h) == 1
deg(f) == deg(g) + deg(h)
deg(s) < deg(h)
deg(t) < deg(g)
returns polynomials `G`, `H`, `S` and `T`, such that::
f == G*H (mod m**2)
S*G + T**H == 1 (mod m**2)
References
==========
1. [Gathen99]_
"""
M = m**2
e = dup_sub_mul(f, g, h, K)
e = dup_trunc(e, M, K)
q, r = dup_div(dup_mul(s, e, K), h, K)
q = dup_trunc(q, M, K)
r = dup_trunc(r, M, K)
u = dup_add(dup_mul(t, e, K), dup_mul(q, g, K), K)
G = dup_trunc(dup_add(g, u, K), M, K)
H = dup_trunc(dup_add(h, r, K), M, K)
u = dup_add(dup_mul(s, G, K), dup_mul(t, H, K), K)
b = dup_trunc(dup_sub(u, [K.one], K), M, K)
c, d = dup_div(dup_mul(s, b, K), H, K)
c = dup_trunc(c, M, K)
d = dup_trunc(d, M, K)
u = dup_add(dup_mul(t, b, K), dup_mul(c, G, K), K)
S = dup_trunc(dup_sub(s, d, K), M, K)
T = dup_trunc(dup_sub(t, u, K), M, K)
return G, H, S, T
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:55,代码来源:factortools.py
示例12: dup_laguerre
def dup_laguerre(n, alpha, K):
"""Low-level implementation of Laguerre polynomials. """
seq = [[K.zero], [K.one]]
for i in range(1, n + 1):
a = dup_mul(seq[-1], [-K.one/i, alpha/i + K(2*i - 1)/i], K)
b = dup_mul_ground(seq[-2], alpha/i + K(i - 1)/i, K)
seq.append(dup_sub(a, b, K))
return seq[-1]
开发者ID:A-turing-machine,项目名称:sympy,代码行数:11,代码来源:orthopolys.py
示例13: dup_laguerre
def dup_laguerre(n, K):
"""Low-level implementation of Laguerre polynomials. """
seq = [[K.one], [-K.one, K.one]]
for i in xrange(2, n+1):
a = dup_mul(seq[-1], [-K(1, i), K(2*i-1, i)], K)
b = dup_mul_ground(seq[-2], K(i-1, i), K)
seq.append(dup_sub(a, b, K))
return seq[n]
开发者ID:haz,项目名称:sympy,代码行数:11,代码来源:orthopolys.py
示例14: test_dmp_mul
def test_dmp_mul():
assert dmp_mul([ZZ(5)], [ZZ(7)], 0, ZZ) == \
dup_mul([ZZ(5)], [ZZ(7)], ZZ)
assert dmp_mul([QQ(5,7)], [QQ(3,7)], 0, QQ) == \
dup_mul([QQ(5,7)], [QQ(3,7)], QQ)
assert dmp_mul([[[]]], [[[]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[ZZ(1)]]], [[[]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[]]], [[[ZZ(1)]]], 2, ZZ) == [[[]]]
assert dmp_mul([[[ZZ(2)]]], [[[ZZ(1)]]], 2, ZZ) == [[[ZZ(2)]]]
assert dmp_mul([[[ZZ(1)]]], [[[ZZ(2)]]], 2, ZZ) == [[[ZZ(2)]]]
assert dmp_mul([[[]]], [[[]]], 2, QQ) == [[[]]]
assert dmp_mul([[[QQ(1,2)]]], [[[]]], 2, QQ) == [[[]]]
assert dmp_mul([[[]]], [[[QQ(1,2)]]], 2, QQ) == [[[]]]
assert dmp_mul([[[QQ(2,7)]]], [[[QQ(1,3)]]], 2, QQ) == [[[QQ(2,21)]]]
assert dmp_mul([[[QQ(1,7)]]], [[[QQ(2,3)]]], 2, QQ) == [[[QQ(2,21)]]]
K = FF(6)
assert dmp_mul([[K(2)],[K(1)]], [[K(3)],[K(4)]], 1, K) == [[K(5)],[K(4)]]
开发者ID:BDGLunde,项目名称:sympy,代码行数:21,代码来源:test_densearith.py
示例15: test_dmp_content
def test_dmp_content():
assert dmp_content([[-2]], 1, ZZ) == [2]
f, g, F = [ZZ(3),ZZ(2),ZZ(1)], [ZZ(1)], []
for i in xrange(0, 5):
g = dup_mul(g, f, ZZ)
F.insert(0, g)
assert dmp_content(F, 1, ZZ) == f
assert dmp_one_p(dmp_content(f_4, 2, ZZ), 1, ZZ)
assert dmp_one_p(dmp_content(f_5, 2, ZZ), 1, ZZ)
assert dmp_one_p(dmp_content(f_6, 3, ZZ), 2, ZZ)
开发者ID:addisonc,项目名称:sympy,代码行数:14,代码来源:test_euclidtools.py
示例16: dup_zz_diophantine
def dup_zz_diophantine(F, m, p, K):
"""Wang/EEZ: Solve univariate Diophantine equations. """
if len(F) == 2:
a, b = F
f = gf_from_int_poly(a, p)
g = gf_from_int_poly(b, p)
s, t, G = gf_gcdex(g, f, p, K)
s = gf_lshift(s, m, K)
t = gf_lshift(t, m, K)
q, s = gf_div(s, f, p, K)
t = gf_add_mul(t, q, g, p, K)
s = gf_to_int_poly(s, p)
t = gf_to_int_poly(t, p)
result = [s, t]
else:
G = [F[-1]]
for f in reversed(F[1:-1]):
G.insert(0, dup_mul(f, G[0], K))
S, T = [], [[1]]
for f, g in zip(F, G):
t, s = dmp_zz_diophantine([g, f], T[-1], [], 0, p, 1, K)
T.append(t)
S.append(s)
result, S = [], S + [T[-1]]
for s, f in zip(S, F):
s = gf_from_int_poly(s, p)
f = gf_from_int_poly(f, p)
r = gf_rem(gf_lshift(s, m, K), f, p, K)
s = gf_to_int_poly(r, p)
result.append(s)
return result
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:46,代码来源:factortools.py
示例17: test_dmp_primitive
def test_dmp_primitive():
assert dmp_primitive([[]], 1, ZZ) == ([], [[]])
assert dmp_primitive([[1]], 1, ZZ) == ([1], [[1]])
f, g, F = [ZZ(3),ZZ(2),ZZ(1)], [ZZ(1)], []
for i in xrange(0, 5):
g = dup_mul(g, f, ZZ)
F.insert(0, g)
assert dmp_primitive(F, 1, ZZ) == (f,
[ dup_exquo(c, f, ZZ) for c in F ])
cont, f = dmp_primitive(f_4, 2, ZZ)
assert dmp_one_p(cont, 1, ZZ) and f == f_4
cont, f = dmp_primitive(f_5, 2, ZZ)
assert dmp_one_p(cont, 1, ZZ) and f == f_5
cont, f = dmp_primitive(f_6, 3, ZZ)
assert dmp_one_p(cont, 2, ZZ) and f == f_6
开发者ID:addisonc,项目名称:sympy,代码行数:19,代码来源:test_euclidtools.py
示例18: dup_ff_lcm
def dup_ff_lcm(f, g, K):
"""
Computes polynomial LCM over a field in ``K[x]``.
**Examples**
>>> from sympy.polys.domains import QQ
>>> from sympy.polys.euclidtools import dup_ff_lcm
>>> f = [QQ(1,2), QQ(7,4), QQ(3,2)]
>>> g = [QQ(1,2), QQ(1), QQ(0)]
>>> dup_ff_lcm(f, g, QQ)
[1/1, 7/2, 3/1, 0/1]
"""
h = dup_exquo(dup_mul(f, g, K),
dup_gcd(f, g, K), K)
return dup_monic(h, K)
开发者ID:addisonc,项目名称:sympy,代码行数:20,代码来源:euclidtools.py
示例19: dup_ff_lcm
def dup_ff_lcm(f, g, K):
"""
Computes polynomial LCM over a field in `K[x]`.
Examples
========
>>> from sympy.polys import ring, QQ
>>> R, x = ring("x", QQ)
>>> f = QQ(1,2)*x**2 + QQ(7,4)*x + QQ(3,2)
>>> g = QQ(1,2)*x**2 + x
>>> R.dup_ff_lcm(f, g)
x**3 + 7/2*x**2 + 3*x
"""
h = dup_quo(dup_mul(f, g, K), dup_gcd(f, g, K), K)
return dup_monic(h, K)
开发者ID:mattpap,项目名称:sympy,代码行数:20,代码来源:euclidtools.py
示例20: dup_rr_lcm
def dup_rr_lcm(f, g, K):
"""
Computes polynomial LCM over a ring in `K[x]`.
Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x = ring("x", ZZ)
>>> R.dup_rr_lcm(x**2 - 1, x**2 - 3*x + 2)
x**3 - 2*x**2 - x + 2
"""
fc, f = dup_primitive(f, K)
gc, g = dup_primitive(g, K)
c = K.lcm(fc, gc)
h = dup_quo(dup_mul(f, g, K), dup_gcd(f, g, K), K)
return dup_mul_ground(h, c, K)
开发者ID:mattpap,项目名称:sympy,代码行数:22,代码来源:euclidtools.py
注:本文中的sympy.polys.densearith.dup_mul函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论