
    z	i                    h    S r SSKJr  SSKrSSKrSSKJr       S             SS jjrS r	g)	z&
Circuit synthesis for a QFT circuit.
    )annotationsN)QuantumCircuitc                >   [        X-
  S-
  5        [        U 5      n[        [        U 5      5       H  nUR	                  U5        [        SU[        SX U-
  S-
  -
  5      -
  5      n[        [        Xx-
  U5      5       H-  n	[        R                  SX-
  -  -  n
UR                  XU	5        M/     U(       d  M  UR                  5         M     U(       a,  [        U S-  5       H  nUR                  XU-
  S-
  5        M     U(       a  UR                  5       nUb  XVl        U$ )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   g       @   )_warn_if_precision_lossr   reversedrangehmaxnppicpbarrierswapinversename)
num_qubitsdo_swapsapproximation_degreeinsert_barriersr   r   circuitjnum_entanglementsklamis               a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/synthesis/qft/qft_decompose_full.pysynth_qft_fullr      s   H J=ABZ(GeJ'(		!1s1.BSTnWXFX.Y'Z#Z[% 5q9:A %%315>*CJJsq!	 ; ?OO ) zQ'ALLNQ./ ( //# N    c                    U [         R                  " [        5      R                  * :  a  [        R
                  " SU  S3[        SS9  gg)a>  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   X   sN      6 66611F0G HJJ $	
 7r    )Tr   FFN)r   intr   boolr   r,   r   r-   r   r-   r   z
str | Nonereturnr   )
__doc__
__future__r   r(   numpyr   qiskit.circuit.quantumcircuitr   r   r    r    r   <module>r4      sv    #   8
  !!??? ? 	?
 ? ? ?D
r    