def test_schur(self): for M in self.symmMlist: MU, MD, MV = hp.schur(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)
def evaluate(self, size): """ Evaluate with a give size matrix. Args: size: Matrix size. """ m = helpers.rand(size, size) PU, PD, PV = helpers.schur(m) self.assertTrue(np.allclose(np.dot(PU, np.dot(PD, PV)), m))
def test_mat_funcs(self): for P in self.Plist: PU, PD, PV = hp.schur(P) # ensure that PD is a diagonal matrix self.assertTrue(np.array_equal(PD, np.diag(np.diag(PD))), repr(PD)) # raise Exception(PU*PD*PV, np.dot(PU, np.dot(PD, PV))) self.assertTrue(np.allclose(PU * PD * PV, np.dot(PU, np.dot(PD, PV)))) for P in self.Plist: self.assertEqual(hp.mindiag(P), min( P[i, i] for i in range(min(P.shape)))) self.assertEqual(hp.maxdiag(P), max( P[i, i] for i in range(min(P.shape))))