本文整理汇总了Python中numpy.polydiv方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.polydiv方法的具体用法?Python numpy.polydiv怎么用?Python numpy.polydiv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy
的用法示例。
在下文中一共展示了numpy.polydiv方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_poly1d_math
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_poly1d_math(self):
# here we use some simple coeffs to make calculations easier
p = np.poly1d([1., 2, 4])
q = np.poly1d([4., 2, 1])
assert_equal(p/q, (np.poly1d([0.25]), np.poly1d([1.5, 3.75])))
assert_equal(p.integ(), np.poly1d([1/3, 1., 4., 0.]))
assert_equal(p.integ(1), np.poly1d([1/3, 1., 4., 0.]))
p = np.poly1d([1., 2, 3])
q = np.poly1d([3., 2, 1])
assert_equal(p * q, np.poly1d([3., 8., 14., 8., 3.]))
assert_equal(p + q, np.poly1d([4., 4., 4.]))
assert_equal(p - q, np.poly1d([-2., 0., 2.]))
assert_equal(p ** 4, np.poly1d([1., 8., 36., 104., 214., 312., 324., 216., 81.]))
assert_equal(p(q), np.poly1d([9., 12., 16., 8., 6.]))
assert_equal(q(p), np.poly1d([3., 12., 32., 40., 34.]))
assert_equal(p.deriv(), np.poly1d([2., 2.]))
assert_equal(p.deriv(2), np.poly1d([2.]))
assert_equal(np.polydiv(np.poly1d([1, 0, -1]), np.poly1d([1, 1])),
(np.poly1d([1., -1.]), np.poly1d([0.])))
示例2: test_polydiv
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_polydiv(self):
b = np.poly1d([2, 6, 6, 1])
a = np.poly1d([-1j, (1+2j), -(2+1j), 1])
q, r = np.polydiv(b, a)
assert_equal(q.coeffs.dtype, np.complex128)
assert_equal(r.coeffs.dtype, np.complex128)
assert_equal(q*a + r, b)
示例3: test_poly_div
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_poly_div(self):
# Ticket #553
u = np.poly1d([1, 2, 3])
v = np.poly1d([1, 2, 3, 4, 5])
q, r = np.polydiv(u, v)
assert_equal(q*v + r, u)
示例4: test_polydiv_type
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_polydiv_type(self):
# Make polydiv work for complex types
msg = "Wrong type, should be complex"
x = np.ones(3, dtype=complex)
q, r = np.polydiv(x, x)
assert_(q.dtype == complex, msg)
msg = "Wrong type, should be float"
x = np.ones(3, dtype=int)
q, r = np.polydiv(x, x)
assert_(q.dtype == float, msg)
示例5: test_poly_div
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_poly_div(self, level=rlevel):
# Ticket #553
u = np.poly1d([1, 2, 3])
v = np.poly1d([1, 2, 3, 4, 5])
q, r = np.polydiv(u, v)
assert_equal(q*v + r, u)
示例6: test_polydiv_type
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_polydiv_type(self):
# Make polydiv work for complex types
msg = "Wrong type, should be complex"
x = np.ones(3, dtype=np.complex)
q, r = np.polydiv(x, x)
assert_(q.dtype == np.complex, msg)
msg = "Wrong type, should be float"
x = np.ones(3, dtype=np.int)
q, r = np.polydiv(x, x)
assert_(q.dtype == np.float, msg)
示例7: test_poly_div
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_poly_div(self, level=rlevel):
"""Ticket #553"""
u = np.poly1d([1, 2, 3])
v = np.poly1d([1, 2, 3, 4, 5])
q, r = np.polydiv(u, v)
assert_equal(q*v + r, u)
示例8: test_polydiv_type
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import polydiv [as 别名]
def test_polydiv_type(self) :
"""Make polydiv work for complex types"""
msg = "Wrong type, should be complex"
x = np.ones(3, dtype=np.complex)
q, r = np.polydiv(x, x)
assert_(q.dtype == np.complex, msg)
msg = "Wrong type, should be float"
x = np.ones(3, dtype=np.int)
q, r = np.polydiv(x, x)
assert_(q.dtype == np.float, msg)