예제 #1
0
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
예제 #2
0
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))
예제 #3
0
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))
예제 #4
0
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
예제 #5
0
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