§
    ¹³ÙgŸ  ã                   ó\   — d Z ddlmZmZ ddlmZ  G d„ de¦  «        Z G d„ d¦  «        Zd	S )
zAParameter Vector Class to simplify management of parameter lists.é    )Úuuid4ÚUUIDé   )Ú	Parameterc                   óh   ‡ — e Zd ZdZdZd	ˆ fd„	Zed„ ¦   «         Zed„ ¦   «         Zˆ fd„Z	ˆ fd„Z
ˆ xZS )
ÚParameterVectorElementa   An element of a :class:`ParameterVector`.

    .. note::
        There is very little reason to ever construct this class directly.  Objects of this type are
        automatically constructed efficiently as part of creating a :class:`ParameterVector`.
    )Ú_vectorÚ_indexNc                 ó€   •— t          ¦   «                              |j        › d|› d�|¬¦  «         || _        || _        d S )Nú[ú])Úuuid)ÚsuperÚ__init__Únamer	   r
   )ÚselfÚvectorÚindexr   Ú	__class__s       €úT/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/parametervector.pyr   zParameterVectorElement.__init__   sE   ø€ Ý‰Œ×Ò˜FœKÐ2Ð2¨%Ð2Ð2Ð2¸ÐÑ>Ô>Ð>ØˆŒØˆŒˆˆó    c                 ó   — | j         S )z3Get the index of this element in the parent vector.)r
   ©r   s    r   r   zParameterVectorElement.index#   s   € ð Œ{Ðr   c                 ó   — | j         S )zGet the parent vector instance.)r	   r   s    r   r   zParameterVectorElement.vector(   s   € ð Œ|Ðr   c                 ób   •— t          ¦   «                              ¦   «         | j        | j        fz   S ©N)r   Ú__getstate__r	   r
   )r   r   s    €r   r   z#ParameterVectorElement.__getstate__-   s'   ø€ Ý‰wŒw×#Ò#Ñ%Ô%¨¬°t´{Ð(CÑCÐCr   c                 ór   •— |�^ }}}t          ¦   «                              |¦  «         || _        || _        d S r   )r   Ú__setstate__r	   r
   )r   ÚstateÚsuper_stater   r   r   s        €r   r   z#ParameterVectorElement.__setstate__0   s9   ø€ Ø&+Ñ#ˆ�f˜eÝ‰Œ×Ò˜[Ñ)Ô)Ð)ØˆŒØˆŒˆˆr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
___slots__r   Úpropertyr   r   r   r   Ú__classcell__)r   s   @r   r   r      s»   ø€ € € € € ðð ð '€Jðð ð ð ð ð ð
 ðð ñ „Xðð ðð ñ „XððDð Dð Dð Dð Dðð ð ð ð ð ð ð ð r   r   c                   ót   — e Zd ZdZdZdd„Zed„ ¦   «         Zed„ ¦   «         Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ ZdS )ÚParameterVectora<  A container of many related :class:`Parameter` objects.

    This class is faster to construct than constructing many :class:`Parameter` objects
    individually, and the individual names of the parameters will all share a common stem (the name
    of the vector).  For a vector called ``v`` with length 3, the individual elements will have
    names ``v[0]``, ``v[1]`` and ``v[2]``.

    The elements of a vector are sorted by the name of the vector, then the numeric value of their
    index.

    This class fulfill the :class:`collections.abc.Sequence` interface.
    )Ú_nameÚ_paramsÚ
_root_uuidr   c                 ó˜   ‡ ‡— |‰ _         t          ¦   «         ‰ _        ‰ j        j        Šˆˆ fd„t	          |¦  «        D ¦   «         ‰ _        d S )Nc           
      óT   •— g | ]$}t          ‰|t          ‰|z   ¬ ¦  «        ¦  «        ‘Œ%S ©)Úint©r   r   ©Ú.0ÚiÚroot_uuid_intr   s     €€r   ú
<listcomp>z,ParameterVector.__init__.<locals>.<listcomp>K   sC   ø€ ð 
ð 
ð 
ØMNÕ" 4¨­D°]ÀQÑ5FÐ,GÑ,GÔ,GÑHÔHð
ð 
ð 
r   )r+   r   r-   r1   Úranger,   )r   r   Úlengthr6   s   `  @r   r   zParameterVector.__init__G   s\   øø€ ØˆŒ
Ý™'œ'ˆŒØœÔ+ˆð
ð 
ð 
ð 
ð 
ÝRWÐX^ÑR_ÔR_ð
ñ 
ô 
ˆŒˆˆr   c                 ó   — | j         S )z)The name of the :class:`ParameterVector`.)r+   r   s    r   r   zParameterVector.nameO   s   € ð ŒzÐr   c                 ó   — | j         S )zoA list of the contained :class:`ParameterVectorElement` instances.

        It is not safe to mutate this list.)r,   r   s    r   ÚparamszParameterVector.paramsT   s   € ð
 Œ|Ðr   c                 ó6   — | j                              |¦  «        S )z£Find the index of a :class:`ParameterVectorElement` within the list.

        It is typically much faster to use the :attr:`ParameterVectorElement.index` property.)r,   r   )r   Úvalues     r   r   zParameterVector.index[   s   € ð Œ|×!Ò! %Ñ(Ô(Ð(r   c                 ó   — | j         |         S r   )r<   )r   Úkeys     r   Ú__getitem__zParameterVector.__getitem__a   s   € ØŒ{˜3ÔÐr   c                 ó*   — t          | j        ¦  «        S r   )Úiterr<   r   s    r   Ú__iter__zParameterVector.__iter__d   s   € Ý�D”KÑ Ô Ð r   c                 ó*   — t          | j        ¦  «        S r   )Úlenr,   r   s    r   Ú__len__zParameterVector.__len__g   s   € Ý�4”<Ñ Ô Ð r   c                 ó8   — | j         › dd„ | j        D ¦   «         › �S )Nz, c                 ó,   — g | ]}t          |¦  «        ‘ŒS © )Ústr)r4   Úitems     r   r7   z+ParameterVector.__str__.<locals>.<listcomp>k   s   € ÐBÐBÐB¨d¥ D¡	¤	ÐBÐBÐBr   )r   r<   r   s    r   Ú__str__zParameterVector.__str__j   s)   € Ø”)ÐDÐDÐBÐB°d´kÐBÑBÔBÐDÐDÐDr   c                 ój   — | j         j        › dt          | j        ¦  «        › dt	          | ¦  «        › d�S )Nz(name=z	, length=ú))r   r"   Úreprr   rF   r   s    r   Ú__repr__zParameterVector.__repr__m   s4   € Ø”.Ô)ÐWÐWµ°d´i±´ÐWÐWÍ3ÈtÉ9Ì9ÐWÐWÐWÐWr   c                 óø   ‡ ‡— |t          ‰ j        ¦  «        k    rU‰ j        j        Š‰ j                             ˆˆ fd„t          t          ‰ j        ¦  «        |¦  «        D ¦   «         ¦  «         dS ‰ j        |d…= dS )a3  Resize the parameter vector.  If necessary, new elements are generated.

        Note that the UUID of each :class:`.Parameter` element will be generated
        deterministically given the root UUID of the ``ParameterVector`` and the index
        of the element.  In particular, if a ``ParameterVector`` is resized to
        be smaller and then later resized to be larger, the UUID of the later
        generated element at a given index will be the same as the UUID of the
        previous element at that index.
        This is to ensure that the parameter instances do not change.

        >>> from qiskit.circuit import ParameterVector
        >>> pv = ParameterVector("theta", 20)
        >>> elt_19 = pv[19]
        >>> rv.resize(10)
        >>> rv.resize(20)
        >>> pv[19] == elt_19
        True
        c           
      óT   •— g | ]$}t          ‰|t          ‰|z   ¬ ¦  «        ¦  «        ‘Œ%S r0   r2   r3   s     €€r   r7   z*ParameterVector.resize.<locals>.<listcomp>†   sE   ø€ ð ð ð àõ +¨4°µD¸]ÈQÑ=NÐ4OÑ4OÔ4OÑPÔPðð ð r   N)rF   r,   r-   r1   Úextendr8   )r   r9   r6   s   ` @r   ÚresizezParameterVector.resizep   sž   øø€ ð& •C˜œÑ%Ô%Ò%Ð%Ø œOÔ/ˆMØŒL×Òðð ð ð ð å"¥3 t¤|Ñ#4Ô#4°fÑ=Ô=ðñ ô ñô ð ð ð ð ”˜V˜W˜WÐ%Ð%Ð%r   N)r   )r"   r#   r$   r%   Ú	__slots__r   r'   r   r<   r   rA   rD   rG   rM   rQ   rU   rJ   r   r   r*   r*   7   sÞ   € € € € € ðð ð 3€Ið
ð 
ð 
ð 
ð ðð ñ „Xðð ðð ñ „Xðð)ð )ð )ð ð  ð  ð!ð !ð !ð!ð !ð !ðEð Eð EðXð Xð Xð&ð &ð &ð &ð &r   r*   N)r%   r   r   r   Ú	parameterr   r   r*   rJ   r   r   ú<module>rX      sŸ   ðð HÐ Gà Ð Ð Ð Ð Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  ð ð  ð  ð  ð  ˜Yñ  ô  ð  ðFU&ð U&ð U&ð U&ð U&ñ U&ô U&ð U&ð U&ð U&r   