
    z	i                        S r SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJrJr   " S S	\5      r    SS
 jr S     SS jjrg)z)Instantaneous quantum polynomial circuit.    )annotations)SequenceN)QuantumCircuit)deprecate_func)py_iqppy_random_iqpc                  F   ^  \ rS rSrSr\" SSSS9S	U 4S jj5       rSrU =r$ )
IQP   a  Instantaneous quantum polynomial (IQP) circuit.

The circuit consists of a column of Hadamard gates,
a column of powers of T gates,
a sequence of powers of CS gates (up to
:math:`\frac{n^2-n}{2}` of them),
and a final column of Hadamard gates, as introduced in [1].

The circuit is parameterized by an n x n interactions matrix.
The powers of each T gate are given by the diagonal elements
of the interactions matrix. The powers of the CS gates are
given by the upper triangle of the interactions matrix.

Reference Circuit:

.. plot::
   :alt: Diagram illustrating the previously described circuit.

   from qiskit.circuit.library import IQP
   A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
   circuit = IQP(A)
   circuit.draw('mpl')

Expanded Circuit:

.. plot::
    :alt: Diagram illustrating the previously described circuit.

    from qiskit.circuit.library import IQP
    from qiskit.visualization.library import _generate_circuit_library_visualization
    A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
    circuit = IQP(A)
    _generate_circuit_library_visualization(circuit.decompose())

References:

[1] M. J. Bremner et al. Average-case complexity versus approximate
simulation of commuting quantum computations,
Phys. Rev. Lett. 117, 080501 (2016).
`arXiv:1504.07999 <https://arxiv.org/abs/1504.07999>`_
z2.1z4Use the qiskit.circuit.library.iqp function instead.zin Qiskit 3.0)sinceadditional_msgremoval_timelinec                   > [        U5      n[        TU ]  " UR                  SUR                  06  U R                  UR                  5       U R                  SS9  g)zCreate IQP circuit.

Args:
    interactions: input n-by-n symmetric matrix.

Raises:
    CircuitError: if the inputs is not as symmetric matrix.
nameT)qubitsinplaceN)iqpsuper__init__qregsr   composeto_gater   )selfinteractionscircuit	__class__s      T/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/iqp.pyr   IQP.__init__C   sF     l#'--;gll;W__&t{{DI     )r   zlist | np.ndarrayreturnNone)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classcell__)r   s   @r   r
   r
      s-    (T M(
J
Jr   r
   c                8   [        U 5      n[        R                  " U 5      R                  [        R                  5      n US:  a/  U b,  [        R
                  " U 5      nSUR                  SS5      -   nOSn[        R                  " [        U 5      SS9nX4l
        U$ )a  Instantaneous quantum polynomial time (IQP) circuit.

The circuit consists of a column of Hadamard gates, a column of powers of T gates,
a sequence of powers of CS gates (up to :math:`\frac{n^2-n}{2}` of them), and a final column of
Hadamard gates, as introduced in [1].

The circuit is parameterized by an :math:`n \times n` interactions matrix. The powers of each
T gate are given by the diagonal elements of the interactions matrix. The powers of the CS gates
are given by the upper triangle of the interactions matrix.

Reference Circuit:

.. plot::
   :alt: Diagram illustrating the previously described circuit.

   from qiskit.circuit.library import iqp
   A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
   circuit = iqp(A)
   circuit.draw("mpl")

Expanded Circuit:

    .. plot::
       :alt: Diagram illustrating the previously described circuit.

       from qiskit.circuit.library import iqp
       from qiskit.visualization.library import _generate_circuit_library_visualization
       A = [[6, 5, 3], [5, 4, 5], [3, 5, 1]]
       circuit = iqp(A)
       _generate_circuit_library_visualization(circuit)

References:

[1] M. J. Bremner et al. Average-case complexity versus approximate
simulation of commuting quantum computations,
Phys. Rev. Lett. 117, 080501 (2016).
`arXiv:1504.07999 <https://arxiv.org/abs/1504.07999>`_

Args:
    interactions: The interactions as symmetric square matrix. If ``None``, then the
        ``num_qubits`` argument must be set and a random IQP circuit will be generated.

Returns:
    An IQP circuit.
   ziqp:
;r   Tlegacy_qubits)lennpasarrayastypeint64	array_strreplacer   _from_circuit_datar   r   )r   
num_qubitslabelr   r   s        r   r   r   V   s    b \"J::l+22288<L A~,2\*dC00//|0DTXYGLNr   c                P    [         R                  " [        X5      SS9nSUl        U$ )a  A random instantaneous quantum polynomial time (IQP) circuit.

See :func:`iqp` for more details on the IQP circuit.

Example:

.. plot::
   :alt: Circuit diagram output by the previous code.
   :include-source:

   from qiskit.circuit.library import random_iqp

   circuit = random_iqp(3)
   circuit.draw("mpl")

Args:
    num_qubits: The number of qubits in the circuit.
    seed: A seed for the random number generator, in case the interactions matrix is
        randomly generated.

Returns:
    An IQP circuit.
Tr.   r   )r   r7   r   r   )r8   seedr   s      r   
random_iqpr<      s(    8 //j0O_cdGGLNr   )r   zSequence[Sequence[int]]r!   r   )N)r8   intr;   z
int | Noner!   r   )r'   
__future__r   collections.abcr   numpyr1   qiskit.circuitr   qiskit.utils.deprecationr   "qiskit._accelerate.circuit_libraryr   r   r
   r   r<   r    r   r   <module>rD      se    0 " $  ) 3 D;J. ;J|=)==D 
 r   