def test_onenormest_matrix_power(self): np.random.seed(1234) n = 40 nsamples = 10 for i in range(nsamples): A = scipy.linalg.inv(np.random.randn(n, n)) for p in range(4): if not p: M = np.identity(n) else: M = np.dot(M, A) estimated = _onenormest_matrix_power(A, p) exact = np.linalg.norm(M, 1) assert_(less_than_or_close(estimated, exact)) assert_(less_than_or_close(exact, 3*estimated))
def test_onenormest_matrix_power(self): np.random.seed(1234) n = 40 nsamples = 10 for i in range(nsamples): A = scipy.linalg.inv(np.random.randn(n, n)) for p in range(4): if not p: M = np.identity(n) else: M = np.dot(M, A) estimated = _onenormest_matrix_power(A, p) exact = np.linalg.norm(M, 1) assert_(less_than_or_close(estimated, exact)) assert_(less_than_or_close(exact, 3 * estimated))