def test_rv_r_equiv(self): """Test R(v) gate is equivalent to R gate.""" theta = np.pi / 5 phi = np.pi / 3 rgate = RGate(theta, phi) axis = np.array([np.cos(phi), np.sin(phi), 0]) # RGate axis rotvec = theta * axis rv = RVGate(*rotvec) self.assertTrue(np.array_equal(rgate.to_matrix(), rv.to_matrix()))
def test_rv_r_equiv(self): """Test R(v) gate is equivalent to R gate.""" theta = np.pi / 5 phi = np.pi / 3 rgate = RGate(theta, phi) axis = np.array([np.cos(phi), np.sin(phi), 0]) # RGate axis rotvec = theta * axis rv = RVGate(*rotvec) rg_matrix = rgate.to_matrix() rv_matrix = rv.to_matrix() np.testing.assert_array_max_ulp(rg_matrix.real, rv_matrix.real, 4) np.testing.assert_array_max_ulp(rg_matrix.imag, rv_matrix.imag, 4)
def test_rv_zero(self): """Test R(v) gate with zero vector returns identity """ rv = RVGate(0, 0, 0) self.assertTrue( np.array_equal(rv.to_matrix(), np.array([[1, 0], [0, 1]])))