我们从Python开源项目中,提取了以下37个代码示例,用于说明如何使用numpy.linalg.cond()。
def aryule(c, k): """Solve Yule-Walker equation. Args: c (numpy array): Coefficients (i.e. autocorrelation) k (int): Assuming the AR(k) model Returns: numpy array: k model parameters Some formulations solve: C a = -c, but we actually solve C a = c. """ a = np.zeros(k) # ignore a singular matrix C = toeplitz(c[:k]) if not np.all(C == 0.0) and np.isfinite(ln.cond(C)): a = np.dot(ln.inv(C), c[1:]) return a
def do(self, a, b): c = asarray(a) # a might be a matrix s = linalg.svd(c, compute_uv=False) old_assert_almost_equal( s[..., 0] / s[..., -1], linalg.cond(a), decimal=5)
def test_stacked_arrays_explicitly(self): A = np.array([[1., 2., 1.], [0, -2., 0], [6., 2., 3.]]) assert_equal(linalg.cond(A), linalg.cond(A[None, ...])[0])
def do(self, a, b): c = asarray(a) # a might be a matrix s = linalg.svd(c, compute_uv=False) old_assert_almost_equal( s[..., 0] / s[..., -1], linalg.cond(a, 2), decimal=5)
def test_stacked_arrays_explicitly(self): A = np.array([[1., 2., 1.], [0, -2., 0], [6., 2., 3.]]) assert_equal(linalg.cond(A, 2), linalg.cond(A[None, ...], 2)[0])
def test(self): A = array([[1., 0, 0], [0, -2., 0], [0, 0, 3.]]) assert_almost_equal(linalg.cond(A, inf), 3.)