Ejemplo n.º 1
0
 def test_svd(self):
     for M in self.Mlist:
         MU, MD, MV = hp.svd(M)
         # ensure that MD is a diagonal matrix
         np.testing.assert_almost_equal(MD, np.diag(np.diag(MD)))
         reconstructedM = hp.reconstruct(MU, MD, MV)
         np.testing.assert_almost_equal(M, reconstructedM)
Ejemplo n.º 2
0
    def evaluate(self, size):
        """ Evaluate with a give size matrix.

        Args:
          size: Matrix size.
        """
        ms = [helpers.rand(size, size) for _ in range(3)]
        ans = functools.reduce(lambda u, v: u.dot(v), ms)
        self.assertTrue(np.allclose(helpers.reconstruct(*ms), ans))