§
    º³Ùg  ã                  óJ   — d Z ddlmZ ddlZddlmZ ddlmZm	Z	 dd
„Z
dd„ZdS )z@Synthesis algorithm for Permutation gates for full-connectivity.é    )ÚannotationsN)ÚQuantumCircuit)Ú_synth_permutation_basicÚ_synth_permutation_acgÚpatternúlist[int] | np.ndarray[int]Úreturnr   c                óH   — t          j        t          | ¦  «        d¬¦  «        S )aP  Synthesize a permutation circuit for a fully-connected
    architecture using sorting.

    More precisely, if the input permutation is a cycle of length ``m``,
    then this creates a quantum circuit with ``m-1`` SWAPs (and of depth ``m-1``);
    if the input  permutation consists of several disjoint cycles, then each cycle
    is essentially treated independently.

    Args:
        pattern: Permutation pattern, describing
            which qubits occupy the positions 0, 1, 2, etc. after applying the
            permutation. That is, ``pattern[k] = m`` when the permutation maps
            qubit ``m`` to position ``k``. As an example, the pattern ``[2, 4, 3, 0, 1]``
            means that qubit ``2`` goes to position ``0``, qubit ``4`` goes to
            position ``1``, etc.

    Returns:
        The synthesized quantum circuit.
    T©Úadd_regs)r   Ú_from_circuit_datar   ©r   s    úc/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/permutation/permutation_full.pyÚsynth_permutation_basicr      s$   € õ( Ô,Õ-EÀgÑ-NÔ-NÐY]Ð^Ñ^Ô^Ð^ó    c                óH   — t          j        t          | ¦  «        d¬¦  «        S )uA  Synthesize a permutation circuit for a fully-connected
    architecture using the Alon, Chung, Graham method.

    This produces a quantum circuit of depth 2 (measured in the number of SWAPs).

    This implementation is based on the Proposition 4.1 in reference [1] with
    the detailed proof given in Theorem 2 in reference [2]

    Args:
        pattern: Permutation pattern, describing
            which qubits occupy the positions 0, 1, 2, etc. after applying the
            permutation. That is, ``pattern[k] = m`` when the permutation maps
            qubit ``m`` to position ``k``. As an example, the pattern ``[2, 4, 3, 0, 1]``
            means that qubit ``2`` goes to position ``0``, qubit ``4`` goes to
            position ``1``, etc.

    Returns:
        The synthesized quantum circuit.

    References:
        1. N. Alon, F. R. K. Chung, and R. L. Graham.
           *Routing Permutations on Graphs Via Matchings.*,
           Proceedings of the Twenty-Fifth Annual ACM Symposium on Theory of Computing(1993).
           Pages 583â€“591.
           `(Extended abstract) 10.1145/167088.167239 <https://doi.org/10.1145/167088.167239>`_
        2. N. Alon, F. R. K. Chung, and R. L. Graham.
           *Routing Permutations on Graphs Via Matchings.*,
           `(Full paper) <https://www.cs.tau.ac.il/~nogaa/PDFS/r.pdf>`_
    Tr   )r   r   r   r   s    r   Úsynth_permutation_acgr   0   s$   € õ< Ô,Õ-CÀGÑ-LÔ-LÐW[Ð\Ñ\Ô\Ð\r   )r   r   r	   r   )Ú__doc__Ú
__future__r   ÚnumpyÚnpÚqiskit.circuit.quantumcircuitr   Ú(qiskit._accelerate.synthesis.permutationr   r   r   r   © r   r   ú<module>r      s¢   ðð GÐ Fà "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð ð ð_ð _ð _ð _ð.]ð ]ð ]ð ]ð ]ð ]r   