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


Python linalg.eigvals方法代碼示例

本文整理匯總了Python中numpy.linalg.eigvals方法的典型用法代碼示例。如果您正苦於以下問題:Python linalg.eigvals方法的具體用法?Python linalg.eigvals怎麽用?Python linalg.eigvals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.linalg的用法示例。


在下文中一共展示了linalg.eigvals方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_0_size

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def test_0_size(self):
        # Check that all kinds of 0-sized arrays work
        class ArraySubclass(np.ndarray):
            pass
        a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
        res = linalg.eigvals(a)
        assert_(res.dtype.type is np.float64)
        assert_equal((0, 1), res.shape)
        # This is just for documentation, it might make sense to change:
        assert_(isinstance(res, np.ndarray))

        a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
        res = linalg.eigvals(a)
        assert_(res.dtype.type is np.complex64)
        assert_equal((0,), res.shape)
        # This is just for documentation, it might make sense to change:
        assert_(isinstance(res, np.ndarray)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:19,代碼來源:test_linalg.py

示例2: do

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def do(self, a, b, tags):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_linalg.py

示例3: do

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def do(self, a, b):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:18,代碼來源:test_linalg.py

示例4: pole

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def pole(self):
        """Compute the poles of a state space system."""

        return eigvals(self.A) if self.states else np.array([]) 
開發者ID:python-control,項目名稱:python-control,代碼行數:6,代碼來源:statesp.py

示例5: test_types

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def test_types(self, dtype):
        x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
        assert_equal(linalg.eigvals(x).dtype, dtype)
        x = np.array([[1, 0.5], [-1, 1]], dtype=dtype)
        assert_equal(linalg.eigvals(x).dtype, get_complex_dtype(dtype)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:test_linalg.py

示例6: test_types

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def test_types(self):
        def check(dtype):
            x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
            assert_equal(linalg.eigvals(x).dtype, dtype)
            x = np.array([[1, 0.5], [-1, 1]], dtype=dtype)
            assert_equal(linalg.eigvals(x).dtype, get_complex_dtype(dtype))
        for dtype in [single, double, csingle, cdouble]:
            yield check, dtype 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:10,代碼來源:test_linalg.py

示例7: eigenvalues

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def eigenvalues(a):
    return linalg.eigvals(a) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:4,代碼來源:linear_algebra.py

示例8: is_psd

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def is_psd(m):
    eigvals = linalg.eigvals(m)
    return np.isreal(eigvals).all() and (eigvals >= 0).all() 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:math.py

示例9: run_experiment

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def run_experiment(niter=100):
    K = 100
    results = []
    for _ in xrange(niter):
        mat = np.random.randn(K, K)
        max_eigenvalue = np.abs(eigvals(mat)).max()
        results.append(max_eigenvalue)
    return results 
開發者ID:Akagi201,項目名稱:learning-python,代碼行數:10,代碼來源:cprof_example.py

示例10: test_stability

# 需要導入模塊: from numpy import linalg [as 別名]
# 或者: from numpy.linalg import eigvals [as 別名]
def test_stability(self, Q):
        """
        Stability test for a given matrix Q.
        """
        sr = np.max(np.abs(eigvals(Q)))
        if not sr < 1 / self.β:
            msg = "Spectral radius condition failed with radius = %f" % sr
            raise ValueError(msg) 
開發者ID:QuantEcon,項目名稱:QuantEcon.lectures.code,代碼行數:10,代碼來源:asset_pricing.py


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