§
    ¹³ÙgÏ  ã                  ó¢   — d Z ddlmZ ddlmZmZ ddlmZ  G d„ de¦  «        Z G d„ de¦  «        Z	 G d	„ d
e¦  «        Z
 G d„ de¦  «        ZdS )z5Compute the sum of two equally sized qubit registers.é    )Úannotations)ÚQuantumCircuitÚGate)Údeprecate_funcc                  óf   ‡ — e Zd ZdZ eddd¬¦  «        ddˆ fd„¦   «         Zedd„¦   «         Zˆ xZS )ÚAdderan  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1.3)a2  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://docs.quantum.ibm.com/api/qiskit/synthesis.T)ÚsinceÚadditional_msgÚpendingÚnum_state_qubitsÚintÚnameÚstrÚreturnÚNonec                óZ   •— t          ¦   «                              |¬¦  «         || _        dS )ú�
        Args:
            num_state_qubits: The number of qubits in each of the registers.
            name: The name of the circuit.
        )r   N)ÚsuperÚ__init__Ú_num_state_qubits)Úselfr   r   Ú	__class__s      €úd/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/arithmetic/adders/adder.pyr   zAdder.__init__-   s.   ø€ õ  	‰Œ×Ò˜dÐÑ#Ô#Ð#Ø!1ˆÔÐÐó    c                ó   — | j         S ©zŽThe 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   zAdder.num_state_qubits@   ó   € ð Ô%Ð%r   )r   )r   r   r   r   r   r   ©r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úpropertyr   Ú__classcell__©r   s   @r   r   r      s™   ø€ € € € € ðð ð. €^Øð
ð ð	ñ 	ô 	ð2ð 2ð 2ð 2ð 2ð 2ñ	ô 	ð2ð ð&ð &ð &ñ „Xð&ð &ð &ð &ð &r   r   c                  óD   ‡ — e Zd ZdZddˆ fd	„Zedd
„¦   «         Zd„ Zˆ xZS )ÚHalfAdderGatea‰  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}.

    Nr   r   Úlabelú
str | Noner   r   c                ó–   •— |dk     rt          d¦  «        ‚t          ¦   «                              dd|z  dz   g |¬¦  «         || _        dS )r   é   úNeed at least 1 state qubit.Ú	HalfAdderé   ©r*   N©Ú
ValueErrorr   r   r   ©r   r   r*   r   s      €r   r   zHalfAdderGate.__init__b   óY   ø€ ð ˜aÒÐÝÐ;Ñ<Ô<Ð<å‰Œ×Ò˜ aÐ*:Ñ&:¸QÑ&>ÀÈ%ÐÑPÔPÐPØ!1ˆÔÐÐr   c                ó   — | j         S r   r   r   s    r   r   zHalfAdderGate.num_state_qubitsn   r   r   c                ó@   — ddl m}  || j        d¬¦  «        | _        dS )ú?Populates self.definition with some decomposition of this gate.r   ©Úadder_qft_d00Úhalf©ÚkindN©Úqiskit.synthesis.arithmeticr:   r   Ú
definition©r   r:   s     r   Ú_definezHalfAdderGate._definew   s3   € à=Ð=Ð=Ð=Ð=Ð=ð
 (˜-¨Ô(=ÀFÐKÑKÔKˆŒˆˆr   ©N©r   r   r*   r+   r   r   r    ©	r!   r"   r#   r$   r   r%   r   rB   r&   r'   s   @r   r)   r)   J   s‚   ø€ € € € € ðð ð.
2ð 
2ð 
2ð 
2ð 
2ð 
2ð 
2ð ð&ð &ð &ñ „Xð&ðLð Lð Lð Lð Lð Lð Lr   r)   c                  óD   ‡ — e Zd ZdZddˆ fd	„Zedd
„¦   «         Zd„ Zˆ xZS )ÚModularAdderGateaŽ  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}.

    Nr   r   r*   r+   r   r   c                ó�   •— |dk     rt          d¦  «        ‚t          ¦   «                              dd|z  g |¬¦  «         || _        dS )r   r-   r.   ÚModularAdderr0   r1   Nr2   r4   s      €r   r   zModularAdderGate.__init__™   sT   ø€ ð ˜aÒÐÝÐ;Ñ<Ô<Ð<å‰Œ×Ò˜¨Ð-=Ñ)=¸rÈÐÑOÔOÐOØ!1ˆÔÐÐr   c                ó   — | j         S r   r   r   s    r   r   z!ModularAdderGate.num_state_qubits¥   r   r   c                ó@   — ddl m}  || j        d¬¦  «        | _        dS )r8   r   r9   Úfixedr<   Nr>   rA   s     r   rB   zModularAdderGate._define®   s3   € à=Ð=Ð=Ð=Ð=Ð=ð
 (˜-¨Ô(=ÀGÐLÑLÔLˆŒˆˆr   rC   rD   r    rE   r'   s   @r   rG   rG   �   s‚   ø€ € € € € ðð ð.
2ð 
2ð 
2ð 
2ð 
2ð 
2ð 
2ð ð&ð &ð &ñ „Xð&ðMð Mð Mð Mð Mð Mð Mr   rG   c                  óD   ‡ — e Zd ZdZddˆ fd	„Zedd
„¦   «         Zd„ Zˆ xZS )ÚFullAdderGateaÃ  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}.

    Nr   r   r*   r+   r   r   c                ó–   •— |dk     rt          d¦  «        ‚t          ¦   «                              dd|z  dz   g |¬¦  «         || _        dS )r   r-   r.   Ú	FullAdderr0   r1   Nr2   r4   s      €r   r   zFullAdderGate.__init__Ñ   r5   r   c                ó   — | j         S r   r   r   s    r   r   zFullAdderGate.num_state_qubitsÝ   r   r   c                ó@   — ddl m}  || j        d¬¦  «        | _        dS )z<Populates self.definition with a decomposition of this gate.r   )Úadder_ripple_c04Úfullr<   N)r?   rS   r   r@   )r   rS   s     r   rB   zFullAdderGate._defineæ   s4   € à@Ð@Ð@Ð@Ð@Ð@ð +Ð*¨4Ô+@ÀvÐNÑNÔNˆŒˆˆr   rC   rD   r    rE   r'   s   @r   rN   rN   ¸   s‚   ø€ € € € € ðð ð0
2ð 
2ð 
2ð 
2ð 
2ð 
2ð 
2ð ð&ð &ð &ñ „Xð&ðOð Oð Oð Oð Oð Oð Or   rN   N)r$   Ú
__future__r   Úqiskit.circuitr   r   Úqiskit.utils.deprecationr   r   r)   rG   rN   © r   r   ú<module>rY      s  ðð <Ð ;à "Ð "Ð "Ð "Ð "Ð "à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ð2&ð 2&ð 2&ð 2&ð 2&ˆNñ 2&ô 2&ð 2&ðj4Lð 4Lð 4Lð 4Lð 4L�Dñ 4Lô 4Lð 4Lðn4Mð 4Mð 4Mð 4Mð 4M�tñ 4Mô 4Mð 4Mðn3Oð 3Oð 3Oð 3Oð 3O�Dñ 3Oô 3Oð 3Oð 3Oð 3Or   