How to use the projectq.ops.C function in projectq

To help you get started, we’ve selected a few projectq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XanaduAI / pennylane / openqml-pq / openqml_pq / projectq.py View on Github external
def __new__(*par): # pylint: disable=no-method-argument
        #return pq.ops.C(pq.ops.XGate())
        return pq.ops.C(pq.ops.NOT)
github XanaduAI / pennylane-pq / pennylane_pq / pqops.py View on Github external
def __new__(*par): # pylint: disable=no-method-argument
        return pq.ops.C(pq.ops.XGate())
github ProjectQ-Framework / FermiLib / src / fermilib / circuits / _low_depth_trotter_simulation.py View on Github external
input_swaps = parallel_bubble_sort(list(itertools.product(input_order)),
                                       key, len(input_order))
    input_swaps = [swap[0] for swap_layer in input_swaps
                   for swap in swap_layer]

    output_swaps = parallel_bubble_sort(list(itertools.product(target_order)),
                                        key, len(input_order))
    output_swaps = [swap[0] for swap_layer in output_swaps
                    for swap in swap_layer]

    # Invert the output swaps to go from the input to the target.
    swaps = input_swaps + output_swaps[::-1]

    # Swap adjacent modes for all swaps in both rounds.
    for mode in swaps:
        C(Z) | (register[mode], register[mode + 1])
        Swap | (register[mode], register[mode + 1])
github quantumlib / OpenFermion-ProjectQ / openfermionprojectq / _ffft.py View on Github external
system_size)
        Ph(3 * numpy.pi / 4) | register[0]

    # To apply the FFFT along the second axis, we must fermionically
    # swap qubits into the correct positions. In 2D this is equivalent
    # to flipping all qubits across the "diagonal" of the grid.
    key_2d = (index_of_position_in_1d_array, (0, 1))
    arr = [(i, j) for i in range(system_size)
           for j in range(system_size)]
    swaps = parallel_bubble_sort(arr, key_2d, system_size)
    all_swaps = [swap for swap_layer in swaps for swap in swap_layer]

    # Fermionically swap into position to FFFT along the second axis.
    for swap in all_swaps:
        Swap | (register[swap[0]], register[swap[1]])
        C(Z) | (register[swap[0]], register[swap[1]])

    # Perform the FFFT along the second axis.
    for i in range(system_size):
        ffft(engine, register[system_size*i: system_size*i + system_size],
             system_size)
        Ph(3 * numpy.pi / 4) | register[0]

    # Undo the fermionic swap network to restore the original ordering.
    for swap in all_swaps[::-1]:
        Swap | (register[swap[0]], register[swap[1]])
        C(Z) | (register[swap[0]], register[swap[1]])
github XanaduAI / pennylane / openqml-pq / openqml_pq / projectq.py View on Github external
def __new__(*par): # pylint: disable=no-method-argument
        return pq.ops.C(pq.ops.ZGate())
github ProjectQ-Framework / FermiLib / src / fermilib / circuits / _unitary_cc.py View on Github external
qubit_graph.find_index(total_qubits[1].id))
    swap_path = [(graph_path[i], graph_path[i + 1])
                 for i in range(len(graph_path) - 2)]

    # SWAP qubit 1 into position adjacent to qubit 2
    for pair in swap_path:
        projectq.ops.Swap | (projectq.types.
                             WeakQubitRef(engine,
                                          qubit_graph.nodes[pair[0]].value),
                             projectq.types.
                             WeakQubitRef(engine,
                                          qubit_graph.nodes[pair[1]].value))

    # Perform original gate
    if len(cmd.control_qubits) > 0:
        projectq.ops.C(gate) | (projectq.types.
                                WeakQubitRef(engine,
                                             qubit_graph.
                                             nodes[graph_path[-2]].value),
                                total_qubits[1])
    else:
        gate | (projectq.types.
                WeakQubitRef(engine,
                             qubit_graph.nodes[graph_path[-2]].value),
                total_qubits[1])

    # Reverse the swaps to put qubits back in place
    for pair in reversed(swap_path):
        projectq.ops.Swap | (projectq.types.
                             WeakQubitRef(engine,
                                          qubit_graph.nodes[pair[0]].value),
                             projectq.types.
github XanaduAI / pennylane / openqml-pq / openqml_pq / ops.py View on Github external
def __new__(*par): # pylint: disable=no-method-argument
        #return pq.ops.C(pq.ops.XGate())
        return pq.ops.C(pq.ops.NOT)
github XanaduAI / pennylane / openqml-pq / openqml_pq / projectq.py View on Github external
def __new__(*par): # pylint: disable=no-method-argument
        return pq.ops.C(pq.ops.ZGate(), 2)
github Roger-luo / quantum-benchmarks / projectq / benchmarks.py View on Github external
def test_CY(benchmark, nqubits):
    benchmark.group = "C-Rx(0.5)"
    run_bench(benchmark, ops.C(ops.Rx(0.5)), (2, 3), nqubits)