
    z	i                        S r SSKJr  SSKJrJr  SSKJr   " S S\5      r " S S\5      r	 " S	 S
\5      r
 " S S\5      rg)z5Compute the sum of two equally sized qubit registers.    )annotations)QuantumCircuitGate)deprecate_funcc                  ^   ^  \ rS rSrSr\" SSSS9S
SU 4S jjj5       r\SS j5       rS	r	U =r
$ )Adder   aB  Compute the sum of two equally sized qubit registers.

For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an
adder performs the following operation

.. math::

    |a\rangle_n |b\rangle_n \mapsto |a\rangle_n |a + b\rangle_{n + 1}.

The quantum register :math:`|a\rangle_n` (and analogously :math:`|b\rangle_n`)

.. math::

    |a\rangle_n = |a_0\rangle \otimes \cdots \otimes |a_{n - 1}\rangle,

for :math:`a_i \in \{0, 1\}`, is associated with the integer value

.. math::

    a = 2^{0}a_{0} + 2^{1}a_{1} + \cdots + 2^{n - 1}a_{n - 1}.

z2.1)a8  Use the adder gates provided in qiskit.circuit.library.arithmetic instead. The gate type depends on the adder kind: fixed, half, full are represented by ModularAdderGate, HalfAdderGate, FullAdderGate, respectively. For different adder implementations, see https://quantum.cloud.ibm.com/docs/api/qiskit/synthesis.zin Qiskit 3.0)sinceadditional_msgremoval_timelinec                ,   > [         TU ]  US9  Xl        g)o
Args:
    num_state_qubits: The number of qubits in each of the registers.
    name: The name of the circuit.
)nameN)super__init___num_state_qubits)selfnum_state_qubitsr   	__class__s      h/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/arithmetic/adders/adder.pyr   Adder.__init__-   s      	d#!1    c                    U R                   $ zvThe number of state qubits, i.e. the number of bits in each input register.

Returns:
    The number of state qubits.
r   r   s    r   r   Adder.num_state_qubits@        %%%r   r   )r   )r   intr   strreturnNoner!   r   )__name__
__module____qualname____firstlineno____doc__r   r   propertyr   __static_attributes____classcell__r   s   @r   r   r      sG    . 
 )	2 2	2 & &r   r   c                  N   ^  \ rS rSrSrSSU 4S jjjr\S	S j5       rS rSr	U =r
$ )
HalfAdderGateJ   a]  Compute the sum of two equally-sized qubit registers, including a carry-out bit.

For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an
adder performs the following operation

.. math::

    |a\rangle_n |b\rangle_n \mapsto |a\rangle_n |a + b\rangle_{n + 1}.

The quantum register :math:`|a\rangle_n` (and analogously :math:`|b\rangle_n`)

.. math::

    |a\rangle_n = |a_0\rangle \otimes \cdots \otimes |a_{n - 1}\rangle,

for :math:`a_i \in \{0, 1\}`, is associated with the integer value

.. math::

    a = 2^{0}a_{0} + 2^{1}a_{1} + \cdots + 2^{n - 1}a_{n - 1}.

c                `   > US:  a  [        S5      e[        TU ]	  SSU-  S-   / US9  Xl        g)r      Need at least 1 state qubit.	HalfAdder   labelN
ValueErrorr   r   r   r   r   r6   r   s      r   r   HalfAdderGate.__init__b   @     a;<<a*:&:Q&>%P!1r   c                    U R                   $ r   r   r   s    r   r   HalfAdderGate.num_state_qubitsn   r   r   c                >    SSK Jn  U" U R                  5      U l        g)?Populates self.definition with some decomposition of this gate.r   )adder_ripple_r25N)qiskit.synthesis.arithmeticr@   r   
definition)r   r@   s     r   _defineHalfAdderGate._definew   s    @
 +4+@+@Ar   r   rB   Nr   r   r6   z
str | Noner!   r"   r#   r$   r%   r&   r'   r(   r   r)   r   rC   r*   r+   r,   s   @r   r.   r.   J   s2    .
2 
2 & &B Br   r.   c                  N   ^  \ rS rSrSrSSU 4S jjjr\S	S j5       rS rSr	U =r
$ )
ModularAdderGate   ab  Compute the sum modulo :math:`2^n` of two :math:`n`-sized qubit registers.

For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an
adder performs the following operation

.. math::

    |a\rangle_n |b\rangle_n \mapsto |a\rangle_n |a + b \text{ mod } 2^n\rangle_n.

The quantum register :math:`|a\rangle_n` (and analogously :math:`|b\rangle_n`)

.. math::

    |a\rangle_n = |a_0\rangle \otimes \cdots \otimes |a_{n - 1}\rangle,

for :math:`a_i \in \{0, 1\}`, is associated with the integer value

.. math::

    a = 2^{0}a_{0} + 2^{1}a_{1} + \cdots + 2^{n - 1}a_{n - 1}.

c                Z   > US:  a  [        S5      e[        TU ]	  SSU-  / US9  Xl        g)r   r1   r2   ModularAdderr4   r5   Nr7   r9   s      r   r   ModularAdderGate.__init__   s;     a;<<-=)=rO!1r   c                    U R                   $ r   r   r   s    r   r   !ModularAdderGate.num_state_qubits   r   r   c                >    SSK Jn  U" U R                  5      U l        g)r?   r   )adder_modular_v17N)rA   rR   r   rB   )r   rR   s     r   rC   ModularAdderGate._define   s    A
 ,D,A,ABr   rE   rF   rG   r#   rH   r,   s   @r   rJ   rJ      s2    .
2 
2 & &C Cr   rJ   c                  N   ^  \ rS rSrSrSSU 4S jjjr\S	S j5       rS rSr	U =r
$ )
FullAdderGate   a  Compute the sum of two :math:`n`-sized qubit registers, including carry-in and -out bits.

For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an
adder performs the following operation

.. math::

    |c_{\text{in}}\rangle_1 |a\rangle_n |b\rangle_n
    \mapsto |a\rangle_n |c_{\text{in}} + a + b \rangle_{n + 1}.

The quantum register :math:`|a\rangle_n` (and analogously :math:`|b\rangle_n`)

.. math::

    |a\rangle_n = |a_0\rangle \otimes \cdots \otimes |a_{n - 1}\rangle,

for :math:`a_i \in \{0, 1\}`, is associated with the integer value

.. math::

    a = 2^{0}a_{0} + 2^{1}a_{1} + \cdots + 2^{n - 1}a_{n - 1}.

c                `   > US:  a  [        S5      e[        TU ]	  SSU-  S-   / US9  Xl        g)r   r1   r2   	FullAdderr4   r5   Nr7   r9   s      r   r   FullAdderGate.__init__   r;   r   c                    U R                   $ r   r   r   s    r   r   FullAdderGate.num_state_qubits   r   r   c                <    SSK Jn  U" U R                  SS9U l        g)z<Populates self.definition with a decomposition of this gate.r   )adder_ripple_c04full)kindN)rA   r]   r   rB   )r   r]   s     r   rC   FullAdderGate._define   s    @ +4+@+@vNr   rE   rF   rG   r#   rH   r,   s   @r   rU   rU      s2    0
2 
2 & &O Or   rU   N)r(   
__future__r   qiskit.circuitr   r   qiskit.utils.deprecationr   r   r.   rJ   rU    r   r   <module>re      sL    < " / 32&N 2&j4BD 4Bn4Ct 4Cn3OD 3Or   