§
    º³Ùg†  ã                   óR   — d Z ddlmZ ddlmZ d„ Zd„ Zdededd	fd
„Z	dedefd„Zd	S )z:
Synthesis of a reverse permutation for LNN connectivity.
é    )ÚQuantumCircuit)Ú!synth_permutation_reverse_lnn_kmsc                 óè   — t          |dz  ¦  «        D ]!}|                      d|z  d|z  dz   ¦  «         Œ"t          |dz   dz  dz
  ¦  «        D ]$}|                      d|z  dz   d|z  dz   ¦  «         Œ%| S ©zA single layer of CX gates.é   é   ©ÚrangeÚcx©ÚqcÚnÚis      új/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/permutation/permutation_reverse_lnn.pyÚ_append_cx_stage1r      sŽ   € å�1˜‘6‰]Œ]ð  ð  ˆØ
�Šˆa�!‰e�Q˜‘U˜Q‘YÑÔÐÐÝ�A˜‘E˜a‘< !Ñ#Ñ$Ô$ð $ð $ˆØ
�Šˆa�!‰e�a‰i˜˜Q™ ™Ñ#Ô#Ð#Ð#Ø€Ió    c                 óè   — t          |dz  ¦  «        D ]!}|                      d|z  dz   d|z  ¦  «         Œ"t          |dz   dz  dz
  ¦  «        D ]$}|                      d|z  dz   d|z  dz   ¦  «         Œ%| S r   r	   r   s      r   Ú_append_cx_stage2r      sŽ   € å�1˜‘6‰]Œ]ð  ð  ˆØ
�Šˆa�!‰e�a‰i˜˜Q™ÑÔÐÐÝ�A˜‘E˜a‘< !Ñ#Ñ$Ô$ð $ð $ˆØ
�Šˆa�!‰e�a‰i˜˜Q™ ™Ñ#Ô#Ð#Ð#Ø€Ir   r   Ú
num_qubitsÚreturnNc                 ó¬   — t          |dz   dz  ¦  «        D ]"}t          | |¦  «         t          | |¦  «         Œ#|dz  dk    rt          | |¦  «         dS dS )a  
    Append reverse permutation to a QuantumCircuit for linear nearest-neighbor architectures
    using Kutin, Moulton, Smithline method.

    Synthesis algorithm for reverse permutation from [1], section 5.
    This algorithm synthesizes the reverse permutation on :math:`n` qubits over
    a linear nearest-neighbor architecture using CX gates with depth :math:`2 * n + 2`.

    Args:
        qc: The original quantum circuit.
        num_qubits: The number of qubits.

    Returns:
        The quantum circuit with appended reverse permutation.

    References:
        1. Kutin, S., Moulton, D. P., Smithline, L.,
           *Computation at a distance*, Chicago J. Theor. Comput. Sci., vol. 2007, (2007),
           `arXiv:quant-ph/0701194 <https://arxiv.org/abs/quant-ph/0701194>`_
    r   r   r   N)r
   r   r   )r   r   Ú_s      r   Ú#_append_reverse_permutation_lnn_kmsr   (   st   € õ, �J ‘N qÑ(Ñ)Ô)ð *ð *ˆÝ˜"˜jÑ)Ô)Ð)Ý˜"˜jÑ)Ô)Ð)Ð)Ø�Q‰˜1ÒÐÝ˜"˜jÑ)Ô)Ð)Ð)Ð)ð Ðr   c                 óH   — t          j        t          | ¦  «        d¬¦  «        S )aÇ  
    Synthesize reverse permutation for linear nearest-neighbor architectures using
    Kutin, Moulton, Smithline method.

    Synthesis algorithm for reverse permutation from [1], section 5.
    This algorithm synthesizes the reverse permutation on :math:`n` qubits over
    a linear nearest-neighbor architecture using CX gates with depth :math:`2 * n + 2`.

    Args:
        num_qubits: The number of qubits.

    Returns:
        The synthesized quantum circuit.

    References:
        1. Kutin, S., Moulton, D. P., Smithline, L.,
           *Computation at a distance*, Chicago J. Theor. Comput. Sci., vol. 2007, (2007),
           `arXiv:quant-ph/0701194 <https://arxiv.org/abs/quant-ph/0701194>`_
    T)Úadd_regs)r   Ú_from_circuit_dataÚ'synth_permutation_reverse_lnn_kms_inner)r   s    r   r   r   E   s+   € õ, Ô,Ý/°
Ñ;Ô;Àdðñ ô ð r   )
Ú__doc__Úqiskit.circuitr   Ú(qiskit._accelerate.synthesis.permutationr   r   r   r   Úintr   © r   r   ú<module>r#      sµ   ððð ð *Ð )Ð )Ð )Ð )Ð )ðð ð ð ð ð ð
ð ð ðð ð ð*¨Nð *Èð *ÐPTð *ð *ð *ð *ð:°#ð ¸.ð ð ð ð ð ð r   