예제 #1
0
    def test_spectral_decomposition(self, tol):
        """Test that the correct spectral decomposition is returned."""

        a, P = spectral_decomposition(H)

        # verify that H = \sum_k a_k P_k
        assert np.allclose(H, np.einsum("i,ijk->jk", a, P), atol=tol, rtol=0)
예제 #2
0
    def test_spectral_decomposition(self):
        """Test that the correct spectral decomposition is returned."""
        self.logTestName()

        a, P = spectral_decomposition(H)

        # verify that H = \sum_k a_k P_k
        self.assertAllAlmostEqual(H, np.einsum("i,ijk->jk", a, P), delta=self.tol)
    def test_spectral_decomposition_qubit(self, tol):
        """Test that the correct spectral decomposition is returned."""
        a, P = spectral_decomposition_qubit(H)

        # verify that H = \sum_k a_k P_k
        self.assertAllAlmostEqual(H, np.einsum('i,ijk->jk', a, P), delta=tol)