def test_power_inplace(self): """Test inplace power method.""" # 10% depolarizing channel rho = np.diag([1, 0]) p_id = 0.9 chan = Stinespring(self.depol_stine(1 - p_id)) # Compose 3 times p_id3 = p_id**3 targ3a = chan._evolve(chan._evolve(chan._evolve(rho))) targ3b = Stinespring(self.depol_stine(1 - p_id3))._evolve(rho) chan.power(3, inplace=True) self.assertAllClose(chan._evolve(rho), targ3a) self.assertAllClose(chan._evolve(rho), targ3b)
def test_power(self): """Test power method.""" # 10% depolarizing channel rho_init = DensityMatrix(np.diag([1, 0])) p_id = 0.9 chan1 = Stinespring(self.depol_stine(1 - p_id)) # Compose 3 times p_id3 = p_id**3 chan = chan1.power(3) rho_targ = rho_init @ chan1 @ chan1 @ chan1 self.assertEqual(rho_init @ chan, rho_targ) rho_targ = rho_init @ Stinespring(self.depol_stine(1 - p_id3)) self.assertEqual(rho_init @ chan, rho_targ)