当前位置: 首页>>代码示例>>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;未经允许,请勿转载。