当前位置: 首页>>代码示例>>Python>>正文


Python numpy.poly方法代码示例

本文整理汇总了Python中numpy.poly方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.poly方法的具体用法?Python numpy.poly怎么用?Python numpy.poly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy的用法示例。


在下文中一共展示了numpy.poly方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_poly

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_poly(self):
        assert_array_almost_equal(np.poly([3, -np.sqrt(2), np.sqrt(2)]),
                                  [1, -3, -2, 6])

        # From matlab docs
        A = [[1, 2, 3], [4, 5, 6], [7, 8, 0]]
        assert_array_almost_equal(np.poly(A), [1, -6, -72, -27])

        # Should produce real output for perfect conjugates
        assert_(np.isrealobj(np.poly([+1.082j, +2.613j, -2.613j, -1.082j])))
        assert_(np.isrealobj(np.poly([0+1j, -0+-1j, 1+2j,
                                      1-2j, 1.+3.5j, 1-3.5j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j, 1+3j, 1-3.j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 1+2j, 1-2j])))
        assert_(np.isrealobj(np.poly([1j, -1j, 2j, -2j])))
        assert_(np.isrealobj(np.poly([1j, -1j])))
        assert_(np.isrealobj(np.poly([1, -1])))

        assert_(np.iscomplexobj(np.poly([1j, -1.0000001j])))

        np.random.seed(42)
        a = np.random.randn(100) + 1j*np.random.randn(100)
        assert_(np.isrealobj(np.poly(np.concatenate((a, np.conjugate(a)))))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:test_polynomial.py

示例2: poly2ac

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def poly2ac(poly, efinal):
    """ Convert prediction filter polynomial to autocorrelation sequence

    :param array poly: the AR parameters
    :param efinal: an estimate of the final error
    :return: the autocorrelation  sequence in complex format.

    .. doctest::

        >>> from numpy import array
        >>> from spectrum import poly2ac
        >>> poly = [ 1. ,  0.38 , -0.05]
        >>> efinal = 4.1895
        >>> poly2ac(poly, efinal)
        array([ 5.00+0.j, -2.00+0.j,  1.01-0.j])

    """
    results = rlevinson(poly, efinal)
    return results[0] 
开发者ID:cokelaer,项目名称:spectrum,代码行数:21,代码来源:linear_prediction.py

示例3: _gener

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def _gener(delta2, m, mu, symbolic):
    # Computes the lambda_q from the article, eq. (9).
    lmbdas2 = []
    for q in range(1, m + 1):
        if not lmbdas2:
            # https://github.com/numpy/numpy/issues/16152
            coeffs = [1]
        else:
            coeffs = numpy.poly(lmbdas2)

        a0 = [c * mu(2 * (q - k) + 2, symbolic) for k, c in enumerate(coeffs)]
        a1 = [c * mu(2 * (q - k), symbolic) for k, c in enumerate(coeffs)]
        prod_ = prod([1 - lmbda2 / delta2 for lmbda2 in lmbdas2])
        a = sum(a0) - mu(2, symbolic) ** (q + 1) / mu(0, symbolic) ** q * prod_
        b = sum(a1) - mu(2, symbolic) ** (q + 1) / mu(0, symbolic) ** q * prod_ / delta2
        lmbdas2.append(a / b)
    return lmbdas2 
开发者ID:nschloe,项目名称:quadpy,代码行数:19,代码来源:_cools_haegemans.py

示例4: lsf2poly

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def lsf2poly(L):

    # always use double precision 
    dtype = L.dtype
    L = L.astype(np.float64)

    order = len(L)
    Q = L[::2]
    P = L[1::2]
    poles_P = np.r_[np.exp(1j*P),np.exp(-1j*P)]
    poles_Q = np.r_[np.exp(1j*Q),np.exp(-1j*Q)]
    
    P = np.poly(poles_P)
    Q = np.poly(poles_Q)
    
    # convolve from scipy.signal
    # only supports even orders
    P = convolve(P, np.array([1.0, -1.0]))
    Q = convolve(Q, np.array([1.0, 1.0]))
    
    a = 0.5*(P+Q)
 
    a = a[:-1]

    return a.astype(dtype) 
开发者ID:ljuvela,项目名称:ResGAN,代码行数:27,代码来源:get_mfcc.py

示例5: test_minreal_2

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_minreal_2(self):
        """This one gave a problem, due to poly([]) giving simply 1
        instead of numpy.array([1])"""
        s = TransferFunction([1, 0], [1])
        G = 6205/(s*(s**2 + 13*s + 1281))
        Heq = G.feedback(1)
        H1 = 1/(s+5)
        H2a = Heq/H1
        H2b = H2a.minreal()
        hr = 6205/(s**2+8*s+1241)
        np.testing.assert_array_almost_equal(H2b.num[0][0], hr.num[0][0])
        np.testing.assert_array_almost_equal(H2b.den[0][0], hr.den[0][0])
        np.testing.assert_equal(H2b.dt, hr.dt) 
开发者ID:python-control,项目名称:python-control,代码行数:15,代码来源:xferfcn_test.py

示例6: test_objects

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_objects(self):
        from decimal import Decimal
        p = np.poly1d([Decimal('4.0'), Decimal('3.0'), Decimal('2.0')])
        p2 = p * Decimal('1.333333333333333')
        assert_(p2[1] == Decimal("3.9999999999999990"))
        p2 = p.deriv()
        assert_(p2[1] == Decimal('8.0'))
        p2 = p.integ()
        assert_(p2[3] == Decimal("1.333333333333333333333333333"))
        assert_(p2[2] == Decimal('1.5'))
        assert_(np.issubdtype(p2.coeffs.dtype, np.object_))
        p = np.poly([Decimal(1), Decimal(2)])
        assert_equal(np.poly([Decimal(1), Decimal(2)]),
                     [1, Decimal(-3), Decimal(2)]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:test_polynomial.py

示例7: test_zero_dims

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_zero_dims(self):
        try:
            np.poly(np.zeros((0, 0)))
        except ValueError:
            pass 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_polynomial.py

示例8: test_poly_int_overflow

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_poly_int_overflow(self):
        """
        Regression test for gh-5096.
        """
        v = np.arange(1, 21)
        assert_almost_equal(np.poly(v), np.poly(np.diag(v))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_polynomial.py

示例9: test_simple

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import poly [as 别名]
def test_simple(self):
        z_r = np.array([0.5, -0.5])
        p_r = np.array([1.j / np.sqrt(2), -1.j / np.sqrt(2)])
        # Sort the zeros/poles so that we don't fail the test if the order
        # changes
        z_r.sort()
        p_r.sort()
        b = np.poly(z_r)
        a = np.poly(p_r)

        z, p, k = tf2zpk(b, a)
        z.sort()
        p.sort()
        assert_array_almost_equal(z, z_r)
        assert_array_almost_equal(p, p_r) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:test_filter_design.py


注:本文中的numpy.poly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。