Exemplo n.º 1
0
def test_F0Gate_text_diagram():
    qubits = LineQubit.range(2)
    circuit = cirq.Circuit(_F0Gate().on(*qubits))

    assert circuit.to_text_diagram(use_unicode_characters=False).strip() == """
0: ---F0---
      |
1: ---F0---
    """.strip()
Exemplo n.º 2
0
def test_F0Gate_text_unicode_diagram():
    qubits = LineQubit.range(2)
    circuit = cirq.Circuit(_F0Gate().on(*qubits))

    assert circuit.to_text_diagram().strip() == """
0: ───F₀───
      │
1: ───F₀───
    """.strip()
Exemplo n.º 3
0
def test_F0Gate_transform(amplitudes):
    qubits = LineQubit.range(2)
    initial_state = _single_fermionic_modes_state(amplitudes)
    expected_state = _single_fermionic_modes_state(
        _fourier_transform_single_fermionic_modes(amplitudes))

    circuit = cirq.Circuit(_F0Gate().on(*qubits))
    state = circuit.final_wavefunction(initial_state)

    assert np.allclose(state, expected_state, rtol=0.0)
Exemplo n.º 4
0
def test_F0Gate_transform(amplitudes):
    qubits = LineQubit.range(2)
    initial_state = _single_fermionic_modes_state(amplitudes)
    expected_state = _single_fermionic_modes_state(
        _fourier_transform_single_fermionic_modes(amplitudes))

    circuit = cirq.Circuit.from_ops(_F0Gate().on(*qubits))
    state = circuit.apply_unitary_effect_to_state(initial_state)

    assert np.allclose(state, expected_state, rtol=0.0)