def test_single_qubit_op_to_framed_phase_form_output_on_example_case(): u, t, g = cirq.single_qubit_op_to_framed_phase_form( cirq.unitary(cirq.Y**0.25)) cirq.testing.assert_allclose_up_to_global_phase(u, cirq.unitary(cirq.X**0.5), atol=1e-7) assert abs(t - (1 + 1j) * math.sqrt(0.5)) < 0.00001 assert abs(g - 1) < 0.00001
def test_single_qubit_op_to_framed_phase_form_equivalent_on_known_and_random( mat): u, t, g = cirq.single_qubit_op_to_framed_phase_form(mat) z = np.diag([g, g * t]) assert np.allclose(mat, np.conj(u.T).dot(z).dot(u))
def test_single_qubit_op_to_framed_phase_form_equivalent_on_known_and_random( mat): u, t, g = cirq.single_qubit_op_to_framed_phase_form(mat) z = np.diag([g, g * t]) assert np.allclose(mat, np.conj(u.T).dot(z).dot(u))
def test_single_qubit_op_to_framed_phase_form_output_on_example_case(): u, t, g = cirq.single_qubit_op_to_framed_phase_form( (cirq.Y**0.25).matrix()) assert cirq.allclose_up_to_global_phase(u, (cirq.X**0.5).matrix()) assert abs(t - (1 + 1j) * math.sqrt(0.5)) < 0.00001 assert abs(g - 1) < 0.00001
def test_single_qubit_op_to_framed_phase_form_output_on_example_case(): u, t, g = cirq.single_qubit_op_to_framed_phase_form( (cirq.Y**0.25).matrix()) assert cirq.allclose_up_to_global_phase(u, (cirq.X**0.5).matrix()) assert abs(t - (1 + 1j) * math.sqrt(0.5)) < 0.00001 assert abs(g - 1) < 0.00001