def test_mpo_zeros_like(self): A = MPO_rand(10, 7, phys_dim=3, normalize=False) Z = MPO_zeros_like(A) assert A @ Z == 0.0 x1 = A.trace() x2 = (A + Z).trace() assert_allclose(x1, x2)
def test_mpo_zeros_like(self, cyclic): A = MPO_rand(10, 7, phys_dim=3, normalize=False, cyclic=cyclic) Z = MPO_zeros_like(A) assert A @ Z == 0.0 assert Z.cyclic == cyclic x1 = A.trace() x2 = (A + Z).trace() assert_allclose(x1, x2)
def test_subtract_mpo(self, cyclic): a, b = MPO_rand(13, 7, cyclic=cyclic), MPO_rand(13, 7, cyclic=cyclic) x1 = a.trace() - b.trace() assert_allclose(x1, (a - b).trace()) a -= b assert_allclose(x1, a.trace())