def test_from_matrix(self): mat = numpy.matrix(numpy.ones((3, 3))) check = RMat(mat, max_rank=1) self.assertAlmostEqual(check.norm(), numpy.linalg.norm(mat)) check = RMat(mat, max_rank=4) self.assertAlmostEqual(check.norm(), numpy.linalg.norm(mat))
def test_norm(self): left = numpy.matrix([[1], [2], [3]]) right = numpy.matrix([[2], [3], [4]]) rmat = RMat(left, right, 1) self.assertEqual(rmat.norm(), abs(rmat))