§
    º³Ùgº  ã            	       óR   — d Z ddlZddlmZ ddlmZ ddlmZ 	 dde	d	e
d
e	defd„ZdS )z&
Circuit synthesis for a QFT circuit.
é    N)ÚQuantumCircuit)Ú#_append_reverse_permutation_lnn_kmsé   )Ú_warn_if_precision_lossTÚ
num_qubitsÚdo_swapsÚapproximation_degreeÚreturnc                 óD  — t          | |z
  dz
  ¦  «         t          | ¦  «        }t          | ¦  «        D �]Ø}|                     | dz
  ¦  «         t          || dz
  ¦  «        D �]¨}||z
  dz   | |z
  dz   k     �r|                     t
          j        d||z
  dz   z  z  | |z
  |z   dz
  ¦  «         |                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         |                     t
          j         d||z
  dz   z  z  | |z
  |z   dz
  ¦  «         |                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         |                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         |                     t
          j        d||z
  dz   z  z  | |z
  |z   dz
  ¦  «         �Œ0|                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         |                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         |                     | |z
  |z   dz
  | |z
  |z   dz
  ¦  «         �Œª�ŒÚ|st          || ¦  «         |S )u»  Construct a circuit for the Quantum Fourier Transform using linear
    neighbor connectivity.

    The construction is based on Fig 2.b in Fowler et al. [1].

    .. note::

        With the default value of ``do_swaps = True``, this synthesis algorithm creates a
        circuit that faithfully implements the QFT operation. When ``do_swaps = False``,
        this synthesis algorithm creates a circuit that corresponds to "QFT-with-reversal":
        applying the QFT and reversing the order of its output qubits.

    Args:
        num_qubits: The number of qubits on which the Quantum Fourier Transform acts.
        approximation_degree: The degree of approximation (0 for no approximation).
            It is possible to implement the QFT approximately by ignoring
            controlled-phase rotations with the angle beneath a threshold. This is discussed
            in more detail in https://arxiv.org/abs/quant-ph/9601018 or
            https://arxiv.org/abs/quant-ph/0403071.
        do_swaps: Whether to synthesize the "QFT" or the "QFT-with-reversal" operation.

    Returns:
        A circuit implementing the QFT operation.

    References:
        1. A. G. Fowler, S. J. Devitt, and L. C. L. Hollenberg,
           *Implementation of Shor's algorithm on a linear nearest neighbour qubit array*,
           Quantum Info. Comput. 4, 4 (July 2004), 237â€“251.
           `arXiv:quant-ph/0402196 [quant-ph] <https://arxiv.org/abs/quant-ph/0402196>`_
    r   é   )	r   r   ÚrangeÚhÚpÚnpÚpiÚcxr   )r   r   r	   ÚqcÚiÚjs         ú\/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/qft/qft_decompose_lnn.pyÚsynth_qft_liner      sˆ  € õB ˜JÐ)=Ñ=ÀÑAÑBÔBÐBÝ	˜
Ñ	#Ô	#€Bå�:ÑÔð Fñ FˆØ
�ŠˆZ˜!‰^ÑÔÐå�q˜* q™.Ñ)Ô)ð 	Fñ 	FˆAØ�1‰u�q‰y˜:Ð(<Ñ<¸qÑ@Ò@Ñ@Ø—’•R”U˜Q 1 q¡5¨1¡9Ñ-Ñ-¨z¸A©~ÀÑ/AÀAÑ/EÑFÔFÐFØ—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEØ—’•b”e�V˜a A¨¡E¨A¡IÑ.Ñ.°
¸Q±ÀÑ0BÀQÑ0FÑGÔGÐGØ—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEØ—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEØ—’•R”U˜Q 1 q¡5¨1¡9Ñ-Ñ-¨z¸A©~ÀÑ/AÀAÑ/EÑFÔFÐFÑFà—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEØ—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEØ—’�j 1‘n qÑ(¨1Ñ,¨j¸1©n¸qÑ.@À1Ñ.DÑEÔEÐEÑEñ	Fð ð <õ 	,¨B°
Ñ;Ô;Ð;à€Ió    )Tr   )Ú__doc__Únumpyr   Úqiskit.circuitr   Ú4qiskit.synthesis.permutation.permutation_reverse_lnnr   Úqft_decompose_fullr   ÚintÚboolr   © r   r   ú<module>r!      s�   ððð ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )Ø dÐ dÐ dÐ dÐ dÐ dØ 7Ð 7Ð 7Ð 7Ð 7Ð 7ð IJð9ð 9Øð9Ø#ð9ØBEð9àð9ð 9ð 9ð 9ð 9ð 9r   