§
    º³Ùgß  ã                  óL   — d Z ddlmZ ddlZddlZddlmZ 	 	 	 	 	 ddd„Zd„ Z	dS )z&
Circuit synthesis for a QFT circuit.
é    )ÚannotationsN)ÚQuantumCircuitTFÚ
num_qubitsÚintÚdo_swapsÚboolÚapproximation_degreeÚinsert_barriersÚinverseÚnameú
str | NoneÚreturnr   c                ój  — t          | |z
  dz
  ¦  «         t          | |¬¦  «        }t          t          | ¦  «        ¦  «        D ]¦}|                     |¦  «         t          d|t          d|| |z
  dz
  z
  ¦  «        z
  ¦  «        }t          t          ||z
  |¦  «        ¦  «        D ].}	t          j        d|	|z
  z  z  }
|                     |
||	¦  «         Œ/|r| 	                    ¦   «          Œ§|r1t          | dz  ¦  «        D ]}| 
                    || |z
  dz
  ¦  «         Œ|r|                     ¦   «         }|S )a,  Construct a circuit for the Quantum Fourier Transform using all-to-all connectivity.

    .. note::

        With the default value of ``do_swaps = True``, this synthesis algorithm creates a
        circuit that faithfully implements the QFT operation. This circuit contains a sequence
        of swap gates at the end, corresponding to reversing the order of its output qubits.
        In some applications this reversal permutation can be avoided. Setting ``do_swaps = False``
        creates a circuit without this reversal permutation, at the expense that this circuit
        implements the "QFT-with-reversal" instead of QFT. Alternatively, the
        :class:`~.ElidePermutations` transpiler pass is able to remove these swap gates.

    Args:
        num_qubits: The number of qubits on which the Quantum Fourier Transform acts.
        do_swaps: Whether to synthesize the "QFT" or the "QFT-with-reversal" operation.
        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.
        insert_barriers: If ``True``, barriers are inserted for improved visualization.
        inverse: If ``True``, the inverse Quantum Fourier Transform is constructed.
        name: The name of the circuit.

    Returns:
        A circuit implementing the QFT operation.

    é   )r   r   g       @é   )Ú_warn_if_precision_lossr   ÚreversedÚrangeÚhÚmaxÚnpÚpiÚcpÚbarrierÚswapr   )r   r   r	   r
   r   r   ÚcircuitÚjÚnum_entanglementsÚkÚlamÚis               ú]/granary/edev/quantum/lib/python3.11/site-packages/qiskit/synthesis/qft/qft_decompose_full.pyÚsynth_qft_fullr#      s\  € õH ˜JÐ)=Ñ=ÀÑAÑBÔBÐBÝ˜Z¨dÐ3Ñ3Ô3€Gå•e˜JÑ'Ô'Ñ(Ô(ð 
ð 
ˆØ�	Š	�!‰ŒˆÝ  1¥s¨1Ð.BÀjÐSTÁnÐWXÑFXÑ.YÑ'ZÔ'ZÑ#ZÑ[Ô[ÐÝ�% Ð$5Ñ 5°qÑ9Ô9Ñ:Ô:ð 	"ð 	"ˆAõ ”%˜3 1 q¡5™>Ñ*ˆCØ�JŠJ�s˜A˜qÑ!Ô!Ð!Ð!àð 	Ø�OŠOÑÔÐøàð 0Ý�z Q‘Ñ'Ô'ð 	0ð 	0ˆAØ�LŠL˜˜J¨™N¨QÑ.Ñ/Ô/Ð/Ð/àð $Ø—/’/Ñ#Ô#ˆà€Nó    c                ó�   — | t          j        t          ¦  «        j         k    r"t	          j        d| › d�t          d¬¦  «         dS dS )aN  Issue a warning if constructing the circuit will lose precision.

    If we need an angle smaller than ``pi * 2**-1022``, we start to lose precision by going into
    the subnormal numbers.  We won't lose _all_ precision until an exponent of about 1075, but
    beyond 1022 we're using fractional bits to represent leading zeros.
    z8precision loss in QFT. The rotation needed to represent zI entanglements is smaller than the smallest normal floating-point number.é   )ÚcategoryÚ
stacklevelN)r   ÚfinfoÚfloatÚminexpÚwarningsÚwarnÚRuntimeWarning)Úmax_num_entanglementss    r"   r   r   S   sk   € ð ¥¤­¡¤Ô 6Ð6Ò6Ð6ÝŒðJØ1FðJð Jð Jõ $Øð	
ñ 	
ô 	
ð 	
ð 	
ð 	
ð 7Ð6r$   )Tr   FFN)r   r   r   r   r	   r   r
   r   r   r   r   r   r   r   )
Ú__doc__Ú
__future__r   r,   Únumpyr   Úqiskit.circuit.quantumcircuitr   r#   r   © r$   r"   ú<module>r5      sŽ   ððð ð #Ð "Ð "Ð "Ð "Ð "Ø €€€Ø Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ð
 Ø !Ø!ØØð:ð :ð :ð :ð :ðz
ð 
ð 
ð 
ð 
r$   