
    z	i                    J    S r SSKJr  SSKJr  SSKrSSKJr   " S S\5      r	g)	z
This is the Parametric Circuit class: anything that you need for a circuit
to be parametrized and used for approximate compiling optimization.
    )annotations)OptionalN   )ApproximateCircuitc                  h   ^  \ rS rSrSr  S         SU 4S jjjr\S	S j5       rS
S jrSr	U =r
$ )CNOTUnitCircuit   zIA class that represents an approximate circuit based on CNOT unit blocks.c                   > [         TU ]  XS9  UR                  S:w  d  UR                  S   S:w  a  [	        S5      eX l        UR                  S   U l        X0l        SU l        g)a  
Args:
    num_qubits: the number of qubits in this circuit.
    cnots: an array of dimensions ``(2, L)`` indicating where the CNOT units will be placed.
    tol: angle parameter less or equal this (small) value is considered equal zero and
        corresponding gate is not inserted into the output circuit (because it becomes
        identity one in this case).
    name: name of this circuit

Raises:
    ValueError: if an unsupported parameter is passed.
)
num_qubitsname   r   z=CNOT structure must be defined as an array of the size (2, N)r   N)	super__init__ndimshape
ValueError_cnots
_num_cnots_tol_thetas)selfr   cnotstolr   	__class__s        h/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/synthesis/unitary/aqc/cnot_unit_circuit.pyr   CNOTUnitCircuit.__init__   s]    & 	J:::?ekk!n1\]]++a.	 +/    c                    U R                   $ )z
Returns a vector of rotation angles used by CNOT units in this circuit.

Returns:
    Parameters of the rotation gates in this circuit.
)r   )r   s    r   thetasCNOTUnitCircuit.thetas:   s     ||r   c                   U R                   nXl        U R                  n[        U5       H  nSU R                  -  SU-  -   nX$-
  S-
  n[
        R                  " USU-      5      U R                  :  a  U R                  USU-      U5        [
        R                  " USU-      5      U R                  :  a  U R                  USU-      U5        [
        R                  " USU-      5      U R                  :  d  M  U R                  USU-      U5        M     [        U R                  5       GHQ  nSU-  nUS-
  [        USU4   5      -
  nUS-
  [        USU4   5      -
  nU R                  Xx5        [
        R                  " USU-      5      U R                  :  a  U R                  USU-      U5        [
        R                  " USU-      5      U R                  :  a  U R                  USU-      U5        [
        R                  " USU-      5      U R                  :  a  U R                  USU-      U5        [
        R                  " USU-      5      U R                  :  d  GM9  U R                  USU-      U5        GMT     g)z
Constructs a Qiskit quantum circuit out of the parameters (angles) of this circuit. If a
    parameter value is less in absolute value than the specified tolerance then the
    corresponding rotation gate will be skipped in the circuit.
      r   r   r   N)r   r   r   ranger   npabsr   rzryintcxrx)	r   r   nr   kpcq1q2s	            r   buildCNOTUnitCircuit.buildD   s    OOqADOO#a!e+A	AvvfQUm$tyy0q1uq)vvfQUm$tyy0q1uq)vvfQUm$tyy0q1uq)  t'AAAQU1a4[))BQU1a4[))BGGBOvvfQUm$tyy0q1ur*vvfQUm$tyy0q1ur*vvfQUm$tyy0q1ur*vvfQUm$tyy0q1ur* (r   )r   r   r   r   )g        N)
r   r)   r   
np.ndarrayr   zOptional[float]r   zOptional[str]returnNone)r5   r4   )r   r4   r5   r6   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r2   __static_attributes____classcell__)r   s   @r   r   r      sf    S  #"// / 	/
 / 
/ />  #+ #+r   r   )
r;   
__future__r   typingr   numpyr%   approximater   r    r   r   <module>rD      s'    #   +O+( O+r   