def test_inv(self): # source data arrays = [ np.array([[2.]]), np.array([[0., 2.], [3., 0.]]), np.array([[1., -2.], [-4., 9.]]), np.array([[10., 11.], [100., 111.]]), # near singular np.array([[1., 2., -3.], [1., -2., 3.], [-1., 2., 3.]]) ] # test that A * inv(A) = I within machine precision for A in arrays: iA = linalg.inv(A) E = np.eye(A.shape[0]) E1 = np.dot(A, iA) E2 = np.dot(iA, A) self.assertApproxEqual(E1, E) self.assertApproxEqual(E2, E)
def test_inv(self): # source data arrays = [ np.array([[ 2.]]), np.array([[ 0., 2.], [ 3., 0.]]), np.array([[ 1., -2.], [-4., 9.]]), np.array([[10., 11.], [100., 111.]]), # near singular np.array([[1., 2., -3.], [1., -2., 3.], [-1., 2., 3.]]) ] # test that A * inv(A) = I within machine precision for A in arrays: iA = linalg.inv(A) E = np.eye(A.shape[0]) E1 = np.dot(A, iA) E2 = np.dot(iA, A) self.assertApproxEqual(E1, E) self.assertApproxEqual(E2, E)
def test_inv_func(self): """Work-around so that this function can be annotated in .pxd""" # source data arrays = [ np.array([[2.0]]), np.array([[0.0, 2.0], [3.0, 0.0]]), np.array([[1.0, -2.0], [-4.0, 9.0]]), np.array([[10.0, 11.0], [100.0, 111.0]]), # near singular np.array([[1.0, 2.0, -3.0], [1.0, -2.0, 3.0], [-1.0, 2.0, 3.0]]), ] # test that A * inv(A) = I within machine precision for A in arrays: iA = linalg.inv(A) E = np.eye(A.shape[0]) E1 = np.dot(A, iA) E2 = np.dot(iA, A) self.assertApproxEqual(E1, E) self.assertApproxEqual(E2, E)
def test_inv_func(self): """Work-around so that this function can be annotated in .pxd""" # source data arrays = [ np.array([[2.]]), np.array([[0., 2.], [3., 0.]]), np.array([[1., -2.], [-4., 9.]]), np.array([[10., 11.], [100., 111.]]), # near singular np.array([[1., 2., -3.], [1., -2., 3.], [-1., 2., 3.]]) ] # test that A * inv(A) = I within machine precision for A in arrays: iA = linalg.inv(A) E = np.eye(A.shape[0]) E1 = np.dot(A, iA) E2 = np.dot(iA, A) self.assertApproxEqual(E1, E) self.assertApproxEqual(E2, E)