當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.polydiv方法代碼示例

本文整理匯總了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.]))) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:22,代碼來源:test_polynomial.py

示例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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_polynomial.py

示例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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:8,代碼來源:test_regression.py

示例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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_regression.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:test_regression.py

示例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) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:12,代碼來源:test_regression.py

示例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) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:test_regression.py

示例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) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:12,代碼來源:test_regression.py


注:本文中的numpy.polydiv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。