本文整理汇总了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))
示例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)
示例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)
示例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([])
示例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))
示例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
示例7: eigenvalues
# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import eigvals [as 别名]
def eigenvalues(a):
return linalg.eigvals(a)
示例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()
示例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
示例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)