§
    ¹³Ùg¹j  ã                  ó,  — d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
Z
ddlZddlZddlZddlmZmZ e	def         Z G d	„ d
e¦  «        ZdZdd„Ze G d„ d¦  «        ¦   «         Ze G d„ d¦  «        ¦   «         Z G d„ d¦  «        Ze	eef         ZdS )zP
ParameterExpression Class to enable creating simple expressions of Parameters.
é    )Úannotations)Ú	dataclass)ÚIntEnum)ÚCallableÚUnionN)ÚCircuitErrorÚQiskitErrorÚParameterExpressionc                  ób   — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdS )Ú_OPCoder   é   é   é   é   é   é   é   é   é	   é
   é   é   é   é   é   é   é   é   é   é   N)Ú__name__Ú
__module__Ú__qualname__ÚADDÚSUBÚMULÚDIVÚPOWÚSINÚCOSÚTANÚASINÚACOSÚEXPÚLOGÚSIGNÚGRADÚCONJÚ
SUBSTITUTEÚABSÚATANÚRSUBÚRDIVÚRPOW© ó    úX/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/parameterexpression.pyr   r   $   sw   € € € € € Ø
€CØ
€CØ
€CØ
€CØ
€CØ
€CØ
€CØ
€CØ€DØ€DØ
€CØ
€CØ€DØ€DØ€DØ€JØ
€CØ€DØ€DØ€DØ€D€D€Dr:   r   )Ú__add__Ú__sub__Ú__mul__Ú__truediv__Ú__pow__ÚsinÚcosÚtanÚarcsinÚarccosÚexpÚlogÚsignÚgradientÚ	conjugateÚsubsÚabsÚarctanÚ__rsub__Ú__rtruediv__Ú__rpow__Úop_codec                ó   — t           |          S )z+Return the method name for a given op_code.)Ú_OP_CODE_MAP©rQ   s    r;   Úop_code_to_methodrU   U   s   € å˜Ô Ð r:   c                  ó2   — e Zd ZU ded<   ded<   dZded<   dS )Ú_INSTRUCTIONr   ÚopzParameterValueType | NoneÚlhsNÚrhs)r!   r"   r#   Ú__annotations__rZ   r9   r:   r;   rW   rW   Z   s8   € € € € € € à€K€K�KØ"Ð"Ð"Ñ"Ø%)€CÐ)Ð)Ð)Ñ)Ð)Ð)r:   rW   c                  ó2   — e Zd ZU ded<   ej        Zded<   dS )Ú_SUBSÚdictÚbindsr   rX   N)r!   r"   r#   r[   r   r3   rX   r9   r:   r;   r]   r]   a   s/   € € € € € € à€K€K�KØÔ$€BÐ$Ð$Ð$Ñ$Ð$Ð$r:   r]   c                  ó†  — e Zd ZdZg d¢ZddœdId„ZedJd
„¦   «         ZedKd„¦   «         ZdLd„Z	dMd„Z
	 dNdOd„Z	 dNdPd„Zd„ Zd„ ZdQd„Z	 	 dRdSd!„ZdTd#„Zd$„ Zd%„ Zd&„ Zd'„ Zd(„ Zd)„ Zd*„ Zd+„ Zd,„ Zd-„ Zd.„ Zd/„ Zd0„ Zd1„ Zd2„ Z d3„ Z!d4„ Z"d5„ Z#d6„ Z$d7„ Z%d8„ Z&d9„ Z'd:„ Z(d;„ Z)d<„ Z*d=„ Z+d>„ Z,d?„ Z-d@„ Z.dQdA„Z/dB„ Z0dC„ Z1dD„ Z2dE„ Z3dUdG„Z4dH„ Z5dS )Vr
   zGParameterExpression class to enable creating expressions of Parameters.)Ú_parameter_symbolsÚ_parameter_keysÚ_symbol_exprÚ	_name_mapÚ_qpy_replayÚ_standalone_paramN©re   Ú
symbol_mapr^   c               ó¨   — || _         t          d„ | j         D ¦   «         ¦  «        | _        || _        d| _        d| _        |�	|| _        dS g | _        dS )a  Create a new :class:`ParameterExpression`.

        Not intended to be called directly, but to be instantiated via operations
        on other :class:`Parameter` or :class:`ParameterExpression` objects.

        Args:
            symbol_map (Dict[Parameter, [ParameterExpression, float, or int]]):
                Mapping of :class:`Parameter` instances to the :class:`sympy.Symbol`
                serving as their placeholder in expr.
            expr (sympy.Expr): Expression of :class:`sympy.Symbol` s.
        c              3  ó>   K  — | ]}|                      ¦   «         V — Œd S ©N)Ú	_hash_key©Ú.0Úps     r;   ú	<genexpr>z/ParameterExpression.__init__.<locals>.<genexpr>ƒ   s*   è è € Ð(XÐ(X¸1¨¯ª©¬Ð(XÐ(XÐ(XÐ(XÐ(XÐ(Xr:   NF)ra   Ú	frozensetrb   rc   rd   rf   re   )Úselfrh   Úexprre   s       r;   Ú__init__zParameterExpression.__init__s   sg   € ð #-ˆÔÝ(Ð(XÐ(XÀÔ@WÐ(XÑ(XÔ(XÑXÔXˆÔØ ˆÔØ&*ˆŒØ!&ˆÔØÐ"Ø*ˆDÔÐÐà!ˆDÔÐÐr:   ÚreturnÚsetc                ó4   — | j                              ¦   «         S )z:Returns a set of the unbound Parameters in the expression.)ra   Úkeys©rr   s    r;   Ú
parameterszParameterExpression.parametersŒ   s   € ð Ô&×+Ò+Ñ-Ô-Ð-r:   c                óJ   — | j         €d„ | j        D ¦   «         | _         | j         S )zEReturns a mapping of parameter names to Parameters in the expression.Nc                ó   — i | ]
}|j         |“ŒS r9   ©Únamerm   s     r;   ú
<dictcomp>z.ParameterExpression._names.<locals>.<dictcomp>•   s   € ÐIÐIÐI¨A˜aœf aÐIÐIÐIr:   )rd   ra   ry   s    r;   Ú_nameszParameterExpression._names‘   s,   € ð Œ>Ð!ØIÐI°Ô1HÐIÑIÔIˆDŒNØŒ~Ðr:   ú'ParameterExpression'c                ó6  — | j         rt          t          j        | ¦  «        }nt          t          j        d¦  «        }| j                             ¦   «         }|                     |¦  «         t          | j        t          j
        | j        ¦  «        |¬¦  «        }|S )zReturn the conjugate.Nrg   )rf   rW   r   r2   re   ÚcopyÚappendr
   ra   Ú	symenginerJ   rc   )rr   Únew_opÚ
new_replayÚ
conjugateds       r;   rJ   zParameterExpression.conjugate˜   sŽ   € àÔ!ð 	6Ý!¥'¤,°Ñ5Ô5ˆFˆFå!¥'¤,°Ñ5Ô5ˆFØÔ%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!Ý(ØÔ#¥YÔ%8¸Ô9JÑ%KÔ%KÐYcð
ñ 
ô 
ˆ
ð Ðr:   ÚvalueÚParameterValueTypec                óˆ   — t          |t          ¦  «        r|                      ||i¦  «        S |                      ||i¦  «        S )a…  
        Assign one parameter to a value, which can either be numeric or another parameter
        expression.

        Args:
            parameter (Parameter): A parameter in this expression whose value will be updated.
            value: The new value to bind to.

        Returns:
            A new expression parameterized by any parameters which were not bound by assignment.
        )Ú
isinstancer
   rK   Úbind)rr   Ú	parameterr‰   s      r;   ÚassignzParameterExpression.assign¥   sE   € õ �eÕ0Ñ1Ô1ð 	1Ø—9’9˜i¨Ð/Ñ0Ô0Ð0Ø�yŠy˜) UÐ+Ñ,Ô,Ð,r:   FÚparameter_valuesÚallow_unknown_parametersÚboolc                óÎ  ‡— |s'|                       |                     ¦   «         ¦  «         |                      |¦  «         t          |¦  «        }i }|                     ¦   «         D ]&\  }}| j                             |¦  «        x}�|||<   Œ'| j                             |¦  «        }| j	        |                     ¦   «         z
  Šˆfd„| j                             ¦   «         D ¦   «         }	t          |d¦  «        r|j        s|t          d¦  «        k    rt          d| › d|› d�¦  «        ‚| j                             ¦   «         }
|
                     |¦  «         t#          |	||
¬¦  «        S )	a–  Binds the provided set of parameters to their corresponding values.

        Args:
            parameter_values: Mapping of Parameter instances to the numeric value to which
                              they will be bound.
            allow_unknown_parameters: If ``False``, raises an error if ``parameter_values``
                contains Parameters in the keys outside those present in the expression.
                If ``True``, any such parameters are simply ignored.

        Raises:
            CircuitError:
                - If parameter_values contains Parameters outside those in self.
                - If a non-numeric value is passed in parameter_values.
            ZeroDivisionError:
                - If binding the provided values requires division by zero.

        Returns:
            A new expression parameterized by any parameters which were not bound by
            parameter_values.
        Nc                ó$   •— i | ]\  }}|‰v ¯	||“ŒS r9   r9   )rn   ro   ÚsÚfree_parameterss      €r;   r   z,ParameterExpression.bind.<locals>.<dictcomp>Þ   s0   ø€ ð "
ð "
ð "
Ù�Q˜ÀÀ_Ð@TÐ@TˆAˆqÐ@TÐ@TÐ@Tr:   Úis_infiniteÚinfzIBinding provided for expression results in division by zero (Expression: z, Bindings: z).rg   )Ú#_raise_if_passed_unknown_parametersrx   Ú_raise_if_passed_nanr]   Úitemsra   Úgetrc   rK   rz   Úhasattrr—   ÚfloatÚZeroDivisionErrorre   rƒ   r„   r
   )rr   r�   r‘   r†   Úsymbol_valuesrŽ   r‰   Ú
param_exprÚbound_symbol_exprÚfree_parameter_symbolsr‡   r–   s              @r;   r�   zParameterExpression.bindµ   s¾  ø€ ð. (ð 	NØ×4Ò4Ð5E×5JÒ5JÑ5LÔ5LÑMÔMÐMØ×!Ò!Ð"2Ñ3Ô3Ð3åÐ'Ñ(Ô(ˆØˆØ 0× 6Ò 6Ñ 8Ô 8ð 	2ð 	2ÑˆI�uØ"Ô5×9Ò9¸)ÑDÔDÐD�
ÐQØ,1�˜jÑ)øà Ô-×2Ò2°=ÑAÔAÐð œ/Ð,<×,AÒ,AÑ,CÔ,CÑCˆð"
ð "
ð "
ð "
Ø!Ô4×:Ò:Ñ<Ô<ð"
ñ "
ô "
Ðõ
 Ð% }Ñ5Ô5ð	Ø:KÔ:Wð	à¥%¨¡,¤,Ò.Ð.Ý#ðGà $ðGð Gà2BðGð Gð Gñô ð ð Ô%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!å"Ø"Ð$5À:ð
ñ 
ô 
ð 	
r:   Úparameter_mapc                óÔ  ‡— |s'|                       ‰                     ¦   «         ¦  «         d„ ‰                     ¦   «         D ¦   «         }|                      |‰                     ¦   «         ¦  «         t	          ‰¦  «        }ˆfd„| j                             ¦   «         D ¦   «         }t          j        }i }‰                     ¦   «         D ]H\  }}	| j         	                    |¦  «        x}
�'|	j
        ||
<   |	j        D ]} ||j        ¦  «        ||<   ŒŒI| j
                             |¦  «        }| j                             ¦   «         }|                     |¦  «         t#          |||¬¦  «        S )aC  Returns a new Expression with replacement Parameters.

        Args:
            parameter_map: Mapping from Parameters in self to the ParameterExpression
                           instances with which they should be replaced.
            allow_unknown_parameters: If ``False``, raises an error if ``parameter_map``
                contains Parameters in the keys outside those present in the expression.
                If ``True``, any such parameters are simply ignored.

        Raises:
            CircuitError:
                - If parameter_map contains Parameters outside those in self.
                - If the replacement Parameters in parameter_map would result in
                  a name conflict in the generated expression.

        Returns:
            A new expression with the specified parameters replaced.
        c                ó2   — i | ]}|j         D ]
}|j        |“ŒŒS r9   )rz   r~   )rn   Úreplacement_exprro   s      r;   r   z,ParameterExpression.subs.<locals>.<dictcomp>
  sF   € ð 
ð 
ð 
à Ø%Ô0ð
ð 
ð ð ŒF�Að
ð 
ð 
ð 
r:   c                ó$   •— i | ]\  }}|‰v¯	||“ŒS r9   r9   )rn   ro   r•   r¤   s      €r;   r   z,ParameterExpression.subs.<locals>.<dictcomp>  s0   ø€ ð !
ð !
ð !
Ù�Q˜ÀÈÐ@VÐ@VˆAˆqÐ@VÐ@VÐ@Vr:   Nrg   )r™   rx   ÚvaluesÚ"_raise_if_parameter_names_conflictr]   ra   r›   r…   ÚSymbolrœ   rc   rz   r~   rK   re   rƒ   r„   r
   )rr   r¤   r‘   Úinbound_namesr†   Únew_parameter_symbolsÚsymbol_typerh   Ú	old_paramÚ	new_paramÚ
old_symbolro   Úsubstituted_symbol_exprr‡   s    `            r;   rK   zParameterExpression.subsò   sª  ø€ ð* (ð 	KØ×4Ò4°]×5GÒ5GÑ5IÔ5IÑJÔJÐJð
ð 
à$1×$8Ò$8Ñ$:Ô$:ð
ñ 
ô 
ˆð
 	×/Ò/°¸}×?QÒ?QÑ?SÔ?SÑTÔTÐTÝ�}Ñ%Ô%ˆð!
ð !
ð !
ð !
Ø!Ô4×:Ò:Ñ<Ô<ð!
ñ !
ô !
Ðõ  Ô&ˆð ˆ
Ø$1×$7Ò$7Ñ$9Ô$9ð 	Cð 	CÑ ˆI�yØ"Ô5×9Ò9¸)ÑDÔDÐD�
ÐQØ)2Ô)?�
˜:Ñ&Ø"Ô-ð Cð C�AØ/:¨{¸1¼6Ñ/BÔ/BÐ)¨!Ñ,Ð,øà"&Ô"3×"8Ò"8¸Ñ"DÔ"DÐØÔ%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!å"Ø!Ð#:È
ð
ñ 
ô 
ð 	
r:   c                óX   — || j         z
  }|rt          dd„ |D ¦   «         › d�¦  «        ‚d S )NzCannot bind Parameters (c                ó,   — g | ]}t          |¦  «        ‘ŒS r9   )Ústrrm   s     r;   ú
<listcomp>zKParameterExpression._raise_if_passed_unknown_parameters.<locals>.<listcomp>-  s   € Ð+OÐ+OÐ+O°q­C°©F¬FÐ+OÐ+OÐ+Or:   z) not present in expression.)rz   r   )rr   rz   Úunknown_parameterss      r;   r™   z7ParameterExpression._raise_if_passed_unknown_parameters)  sY   € Ø'¨$¬/Ñ9ÐØð 	ÝðÐ+OÐ+OÐ<NÐ+OÑ+OÔ+Oð ð ð ñô ð ð	ð 	r:   c                ól   — d„ |                      ¦   «         D ¦   «         }|rt          d|› d�¦  «        ‚d S )Nc                óN   — i | ]"\  }}t          |t          j        ¦  «        °||“Œ#S r9   )rŒ   ÚnumbersÚNumber)rn   ro   Úvs      r;   r   z<ParameterExpression._raise_if_passed_nan.<locals>.<dictcomp>2  s?   € ð  
ð  
ð  
Ù�Q˜½ZÈÍ7Ì>Ñ=ZÔ=Zð 
Øˆqð 
ð  
ð  
r:   z+Expression cannot bind non-numeric values (ú))r›   r   )rr   r�   Únan_parameter_valuess      r;   rš   z(ParameterExpression._raise_if_passed_nan1  sb   € ð 
ð  
Ø-×3Ò3Ñ5Ô5ð 
ñ  
ô  
Ðð  ð 	ÝØUÐ>RÐUÐUÐUñô ð ð	ð 	r:   c                ó  — |€t          ¦   «         }i }nd„ |D ¦   «         }|}g }|                     ¦   «         D ]8\  }}|| j        v r*||vr&|| j        |         k    r|                     |¦  «         Œ9|rt	          d|› �¦  «        ‚d S )Nc                ó   — i | ]
}|j         |“ŒS r9   r}   rm   s     r;   r   zJParameterExpression._raise_if_parameter_names_conflict.<locals>.<dictcomp>?  s   € ÐEÐEÐE¨A˜aœf aÐEÐEÐEr:   z1Name conflict applying operation for parameters: )rv   r›   r€   r„   r   )rr   Úinbound_parametersÚoutbound_parametersÚoutbound_namesr¬   Úconflicting_namesr~   Úparams           r;   rª   z6ParameterExpression._raise_if_parameter_names_conflict:  sÅ   € ØÐ&Ý"%¡%¤%ÐØˆNˆNàEÐEÐ1DÐEÑEÔEˆNà*ˆØÐØ(×.Ò.Ñ0Ô0ð 	3ð 	3‰KˆD�%Ø�t”{Ð"Ð" t°>Ð'AÐ'AØ˜DœK¨Ô-Ò-Ð-Ø%×,Ò,¨TÑ2Ô2Ð2øØð 	ÝØWÐDUÐWÐWñô ð ð	ð 	r:   Ú	operationr   ÚotherÚ	reflectedrQ   r   c                ó
  — | j         }t          |t          ¦  «        r2|                      |j        ¦  «         i | j        ¥|j        ¥}|j         }nQt          |t          j        ¦  «        r0t          j	        |¦  «        r| j         
                    ¦   «         }|}nt          S |r‡ |||¦  «        }|t          j        t          j        t          j        hv r+| j        rt#          || |¦  «        }	nst#          |d|¦  «        }	na| j        rt#          ||| ¦  «        }	nHt#          ||d¦  «        }	n6 |||¦  «        }| j        rt#          || |¦  «        }	nt#          |d|¦  «        }	| j         
                    ¦   «         }
|
                     |	¦  «         t          |||
¬¦  «        }| j         
                    ¦   «         |_        t          |t          ¦  «        r1|j                             |j         
                    ¦   «         ¦  «         |S )ab  Base method implementing math operations between Parameters and
        either a constant or a second ParameterExpression.

        Args:
            operation: An operator, such as add, sub, mul, and truediv.
            other: The second argument to be used with self in operation.
            reflected: Optional - The default ordering is "self operator other".
                       If reflected is True, this is switched to "other operator self".
                       For use in e.g. __radd__, ...

        Raises:
            CircuitError:
                - If parameter_map contains Parameters outside those in self.
                - If the replacement Parameters in parameter_map would result in
                  a name conflict in the generated expression.

        Returns:
            A new expression describing the result of the operation.
        Nrg   )rc   rŒ   r
   rª   r€   ra   rº   r»   ÚnumpyÚisfiniterƒ   ÚNotImplementedr   r6   r7   r8   rf   rW   re   r„   rd   Úupdate)rr   rÆ   rÇ   rÈ   rQ   Ú	self_exprÚparameter_symbolsÚ
other_exprrs   r†   r‡   Úout_exprs               r;   Ú_apply_operationz$ParameterExpression._apply_operationL  s   € ð4 Ô%ˆ	Ý�eÕ0Ñ1Ô1ð 	"Ø×3Ò3°E´LÑAÔAÐAØ W 4Ô#:Ð W¸eÔ>VÐ WÐØÔ+ˆJˆJÝ˜�wœ~Ñ.Ô.ð 	"µ5´>À%Ñ3HÔ3Hð 	"Ø $Ô 7× <Ò <Ñ >Ô >ÐØˆJˆJå!Ð!àð 	<Ø�9˜Z¨Ñ3Ô3ˆDØ�7œ<­¬µw´|ÐDÐDÐDØÔ)ð @Ý)¨'°4¸Ñ?Ô?�F�Få)¨'°4¸Ñ?Ô?�F�FàÔ)ð @Ý)¨'°5¸$Ñ?Ô?�F�Få)¨'°5¸$Ñ?Ô?�F�Fà�9˜Y¨
Ñ3Ô3ˆDØÔ%ð <Ý% g¨t°UÑ;Ô;��å% g¨t°UÑ;Ô;�ØÔ%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!å&Ð'8¸$ÈJÐWÑWÔWˆØ!œ[×-Ò-Ñ/Ô/ˆÔÝ�eÕ0Ñ1Ô1ð 	8ØŒO×"Ò" 5¤<×#4Ò#4Ñ#6Ô#6Ñ7Ô7Ð7àˆr:   ú%Union['ParameterExpression', complex]c                ó`  — || j                              ¦   «         vrdS | j        rt          t          j        | |¦  «        }nt          t          j        d|¦  «        }| j                             ¦   «         }|                     |¦  «         | j         |         }t          j
        | j        |¦  «        }i }| j                              ¦   «         D ]\  }}||j        v r|||<   Œt          |¦  «        dk    rt          |||¬¦  «        S t!          |¦  «        }	|	j        dk    r|	S t%          |¦  «        S )aP  Get the derivative of a parameter expression w.r.t. a specified parameter expression.

        Args:
            param (Parameter): Parameter w.r.t. which we want to take the derivative

        Returns:
            ParameterExpression representing the gradient of param_expr w.r.t. param
            or complex or float number
        ç        Nr   )rs   re   )ra   rx   rf   rW   r   r1   re   rƒ   r„   r…   Ú
Derivativerc   r›   Úfree_symbolsÚlenr
   ÚcomplexÚimagrž   )
rr   rÅ   r†   Ú
qpy_replayÚkeyÚ	expr_gradrÏ   rŽ   ÚsymbolÚexpr_grad_cplxs
             r;   rI   zParameterExpression.gradient�  sA  € ð ˜Ô/×4Ò4Ñ6Ô6Ð6Ð6à�3àÔ!ð 	=Ý!¥'¤,°°eÑ<Ô<ˆFˆFå!¥'¤,°°eÑ<Ô<ˆFØÔ%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!ð Ô% eÔ,ˆÝÔ(¨Ô):¸CÑ@Ô@ˆ	ð
 ÐØ!%Ô!8×!>Ò!>Ñ!@Ô!@ð 	6ð 	6ÑˆI�vØ˜Ô/Ð/Ð/Ø/5Ð! )Ñ,øåÐ Ñ!Ô! AÒ%Ð%Ý&Ð'8¸yÐV`ÐaÑaÔaÐaå  Ñ+Ô+ˆØÔ !Ò#Ð#Ø!Ð!å˜Ñ#Ô#Ð#r:   c                óZ   — |                       t          j        |t          j        ¬¦  «        S ©NrT   ©rÒ   ÚoperatorÚaddr   r$   ©rr   rÇ   s     r;   r<   zParameterExpression.__add__¸  ó!   € Ø×$Ò$¥X¤\°5Å'Ä+Ð$ÑNÔNÐNr:   c                ó\   — |                       t          j        |dt          j        ¬¦  «        S ©NT)rÈ   rQ   râ   rå   s     r;   Ú__radd__zParameterExpression.__radd__»  ó%   € Ø×$Ò$¥X¤\°5ÀDÕRYÔR]Ð$Ñ^Ô^Ð^r:   c                óZ   — |                       t          j        |t          j        ¬¦  «        S rá   )rÒ   rã   Úsubr   r%   rå   s     r;   r=   zParameterExpression.__sub__¾  ræ   r:   c                ó\   — |                       t          j        |dt          j        ¬¦  «        S rè   )rÒ   rã   rì   r   r6   rå   s     r;   rN   zParameterExpression.__rsub__Á  s%   € Ø×$Ò$¥X¤\°5ÀDÕRYÔR^Ð$Ñ_Ô_Ð_r:   c                óZ   — |                       t          j        |t          j        ¬¦  «        S rá   ©rÒ   rã   Úmulr   r&   rå   s     r;   r>   zParameterExpression.__mul__Ä  ræ   r:   c                óZ   — |                       t          j        dt          j        ¬¦  «        S )Nr   rT   rï   ry   s    r;   Ú__pos__zParameterExpression.__pos__Ç  s!   € Ø×$Ò$¥X¤\°1½g¼kÐ$ÑJÔJÐJr:   c                óZ   — |                       t          j        dt          j        ¬¦  «        S )NéÿÿÿÿrT   rï   ry   s    r;   Ú__neg__zParameterExpression.__neg__Ê  s!   € Ø×$Ò$¥X¤\°2½w¼{Ð$ÑKÔKÐKr:   c                ó\   — |                       t          j        |dt          j        ¬¦  «        S rè   rï   rå   s     r;   Ú__rmul__zParameterExpression.__rmul__Í  rê   r:   c                ó„   — |dk    rt          d¦  «        ‚|                      t          j        |t          j        ¬¦  «        S )Nr   z*Division of a ParameterExpression by zero.rT   )rŸ   rÒ   rã   Útruedivr   r'   rå   s     r;   r?   zParameterExpression.__truediv__Ð  s:   € Ø�AŠ:ˆ:Ý#Ð$PÑQÔQÐQØ×$Ò$¥XÔ%5°uÅgÄkÐ$ÑRÔRÐRr:   c                ó\   — |                       t          j        |dt          j        ¬¦  «        S rè   )rÒ   rã   rù   r   r7   rå   s     r;   rO   z ParameterExpression.__rtruediv__Õ  s&   € Ø×$Ò$¥XÔ%5°uÈÕV]ÔVbÐ$ÑcÔcÐcr:   c                óP   — |                       t          |t          j        ¬¦  «        S rá   )rÒ   Úpowr   r(   rå   s     r;   r@   zParameterExpression.__pow__Ø  s   € Ø×$Ò$¥S¨%½¼Ð$ÑEÔEÐEr:   c                óR   — |                       t          |dt          j        ¬¦  «        S rè   )rÒ   rü   r   r8   rå   s     r;   rP   zParameterExpression.__rpow__Û  s!   € Ø×$Ò$¥S¨%¸4ÍÌÐ$ÑVÔVÐVr:   c                óø   — | j         rt          || ¦  «        }nt          |d ¦  «        }| j                             ¦   «         }|                     |¦  «         t          | j         || j        ¦  «        |¬¦  «        S )Nrg   )rf   rW   re   rƒ   r„   r
   ra   rc   )rr   ÚufuncrQ   r†   r‡   s        r;   Ú_callzParameterExpression._callÞ  sƒ   € ØÔ!ð 	1Ý! '¨4Ñ0Ô0ˆFˆFå! '¨4Ñ0Ô0ˆFØÔ%×*Ò*Ñ,Ô,ˆ
Ø×Ò˜&Ñ!Ô!Ð!Ý"ØÔ# U U¨4Ô+<Ñ%=Ô%=È:ð
ñ 
ô 
ð 	
r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zSine of a ParameterExpressionrT   )r   r…   rA   r   r)   ry   s    r;   rA   zParameterExpression.siné  ó   € à�zŠz�)œ-µ´ˆzÑ=Ô=Ð=r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zCosine of a ParameterExpressionrT   )r   r…   rB   r   r*   ry   s    r;   rB   zParameterExpression.cosí  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )z Tangent of a ParameterExpressionrT   )r   r…   rC   r   r+   ry   s    r;   rC   zParameterExpression.tanñ  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zArcsin of a ParameterExpressionrT   )r   r…   Úasinr   r,   ry   s    r;   rD   zParameterExpression.arcsinõ  ó   € à�zŠz�)œ.µ'´,ˆzÑ?Ô?Ð?r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zArccos of a ParameterExpressionrT   )r   r…   Úacosr   r-   ry   s    r;   rE   zParameterExpression.arccosù  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zArctan of a ParameterExpressionrT   )r   r…   Úatanr   r5   ry   s    r;   rM   zParameterExpression.arctaný  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )z$Exponential of a ParameterExpressionrT   )r   r…   rF   r   r.   ry   s    r;   rF   zParameterExpression.exp  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )z"Logarithm of a ParameterExpressionrT   )r   r…   rG   r   r/   ry   s    r;   rG   zParameterExpression.log  r  r:   c                óX   — |                       t          j        t          j        ¬¦  «        S )zSign of a ParameterExpressionrT   )r   r…   rH   r   r0   ry   s    r;   rH   zParameterExpression.sign	  r  r:   c                ó@   — | j         j        › dt          | ¦  «        › d�S )Nú(r½   )Ú	__class__r!   rµ   ry   s    r;   Ú__repr__zParameterExpression.__repr__  s$   € Ø”.Ô)Ð8Ð8­C°©I¬IÐ8Ð8Ð8Ð8r:   c                ó¤   — ddl m}m} t          | j        t
          j        ¦  «        st          d¦  «        ‚ | || j        ¦  «        d¬¦  «        S )Nr   )ÚsympifyÚsstrúInvalid ParameterExpressionF)Ú	full_prec)Úsympyr  r  rŒ   rc   r…   ÚBasicr	   )rr   r  r  s      r;   Ú__str__zParameterExpression.__str__  sb   € Ø'Ð'Ð'Ð'Ð'Ð'Ð'Ð'å˜$Ô+­Y¬_Ñ=Ô=ð 	=ÝÐ;Ñ<Ô<Ð<àˆt�G�G˜DÔ-Ñ.Ô.¸%Ð@Ñ@Ô@Ð@r:   c                ó¾   — 	 t          | j        ¦  «        S # t          t          f$ r5}| j        rt          d| j        › d�¦  «        d ‚t          d¦  «        |‚d }~ww xY w)Nú-ParameterExpression with unbound parameters (z) cannot be cast to a complex.z$could not cast expression to complex)rÙ   rc   Ú	TypeErrorÚRuntimeErrorrz   ©rr   Úexcs     r;   Ú__complex__zParameterExpression.__complex__  s�   € ð		MÝ˜4Ô,Ñ-Ô-Ð-øå�<Ð(ð 	Mð 	Mð 	MØŒð Ýð3ÀDÄOð 3ð 3ð 3ñô ð ðõ ÐBÑCÔCÈÐLøøøøð	Møøøs   ‚ –A§0AÁAc                ó
  — 	 t          | j        ¦  «        S # t          t          f$ r[}| j        rt          d| j        › d�¦  «        d ‚t          | ¦  «        }|j        dk    r|j        cY d }~S t          d¦  «        |‚d }~ww xY w)Nr  z) cannot be cast to a float.rÕ   z"could not cast expression to float)rž   rc   r  r  rz   rÙ   rÚ   Úreal)rr   r   Úcvals      r;   Ú	__float__zParameterExpression.__float__$  s¼   € ð	KÝ˜Ô*Ñ+Ô+Ð+øå�<Ð(ð 	Kð 	Kð 	KØŒð Ýð1ÀDÄOð 1ð 1ð 1ñô ð ðõ ˜4‘=”=ˆDØŒy˜CÒÐØ”yÐ Ð Ð Ð Ð Ð ÝÐ@ÑAÔAÀsÐJøøøøð	Køøøs!   ‚ –B§A A=Á'BÁ-A=Á=Bc                ó°   — 	 t          | j        ¦  «        S # t          $ r5}| j        rt	          d| j        › d�¦  «        d ‚t	          d¦  «        |‚d }~ww xY w)Nr  z) cannot be cast to an int.z could not cast expression to int)Úintrc   r  rz   r  r  s     r;   Ú__int__zParameterExpression.__int__8  sˆ   € ð		IÝ�tÔ(Ñ)Ô)Ð)øåð 	Ið 	Ið 	IØŒð Ýð0ÀDÄOð 0ð 0ð 0ñô ð ðõ Ð>Ñ?Ô?ÀSÐHøøøøð	Iøøøs   ‚ –
A 0AÁAc                óˆ   — | j         s!t          |                      ¦   «         ¦  «        S t          | j        | j        f¦  «        S rk   )ra   ÚhashÚnumericrb   rc   ry   s    r;   Ú__hash__zParameterExpression.__hash__D  s<   € ØÔ&ð 	(å˜Ÿš™œÑ'Ô'Ð'Ý�TÔ)¨4Ô+<Ð=Ñ>Ô>Ð>r:   c                ó   — | S rk   r9   ry   s    r;   Ú__copy__zParameterExpression.__copy__J  ó   € Øˆr:   c                ó   — | S rk   r9   )rr   Úmemos     r;   Ú__deepcopy__z ParameterExpression.__deepcopy__M  r/  r:   c                óV   — |                       t          j        t          j        ¦  «        S ©z!Absolute of a ParameterExpression)r   r…   ÚAbsr   r4   ry   s    r;   Ú__abs__zParameterExpression.__abs__P  s   € à�zŠz�)œ-­¬Ñ5Ô5Ð5r:   c                ó*   — |                       ¦   «         S r4  )r6  ry   s    r;   rL   zParameterExpression.absT  s   € à�|Š|‰~Œ~Ðr:   c                ó²  — t          |t          ¦  «        rw| j        |j        k    rdS ddlm} t          | j        t          j        ¦  «        st          d¦  «        ‚ || j        ¦  «         	                     ||j        ¦  «        ¦  «        S t          |t          j        ¦  «        r0t          | j        ¦  «        dk    ot          | j        ¦  «        |k    S dS )ab  Check if this parameter expression is equal to another parameter expression
           or a fixed value (only if this is a bound expression).
        Args:
            other (ParameterExpression or a number):
                Parameter expression or numeric constant used for comparison
        Returns:
            bool: result of the comparison
        Fr   )r  r  )rŒ   r
   rz   r  r  rc   r…   r  r	   Úequalsrº   r»   rØ   rÙ   )rr   rÇ   r  s      r;   Ú__eq__zParameterExpression.__eq__X  sØ   € õ �eÕ0Ñ1Ô1ð 		UØŒ %Ô"2Ò2Ð2Ø�uØ%Ð%Ð%Ð%Ð%Ð%å˜dÔ/µ´ÑAÔAð AÝ!Ð"?Ñ@Ô@Ð@Ø�7˜4Ô,Ñ-Ô-×4Ò4°W°W¸UÔ=OÑ5PÔ5PÑQÔQÐQÝ˜�wœ~Ñ.Ô.ð 	UÝ�t”Ñ'Ô'¨1Ò,ÐTµ¸Ô9JÑ1KÔ1KÈuÒ1TÐTØˆur:   c                ór   — | j         j        s | j         j        �| j         j        dk    rdS dS | j         j        S )z%Return whether the expression is realNrÕ   TF)rc   Úis_realrÚ   ry   s    r;   r<  zParameterExpression.is_realm  sD   € àÔ Ô(ð 	¨TÔ->Ô-FÐ-Rð Ô Ô%¨Ò,Ð,Ø�tØ�5ØÔ Ô(Ð(r:   úint | float | complexc                óH  — | j         rt          d| j        › d�¦  «        ‚| j        j        rt          | j        ¦  «        S 	 | j                             d¬¦  «        }n8# t          $ r+ t          | j        ¦  «        }|j	        dk    r|j
        n|cY S w xY wt          |¦  «        S )a‚  Return a Python number representing this object, using the most restrictive of
        :class:`int`, :class:`float` and :class:`complex` that is valid for this object.

        In general, an :class:`int` is only returned if the expression only involved symbolic
        integers.  If floating-point values were used during the evaluation, the return value will
        be a :class:`float` regardless of whether the represented value is an integer.  This is
        because floating-point values "infect" symbolic computations by their inexact nature, and
        symbolic libraries will use inexact floating-point semantics not exact real-number semantics
        when they are involved.  If you want to assert that all floating-point calculations *were*
        carried out at infinite precision (i.e. :class:`float` could represent every intermediate
        value exactly), you can use :meth:`float.is_integer` to check if the return float represents
        an integer and cast it using :class:`int` if so.  This would be an unusual pattern;
        typically one requires this by only ever using explicitly :class:`~numbers.Rational` objects
        while working with symbolic expressions.

        This is more reliable and performant than using :meth:`is_real` followed by calling
        :class:`float` or :class:`complex`, as in some cases :meth:`is_real` needs to force a
        floating-point evaluation to determine an accurate result to work around bugs in the
        upstream symbolic libraries.

        Returns:
            A Python number representing the object.

        Raises:
            TypeError: if there are unbound parameters.
        z$Expression with unbound parameters 'z' is not numericT)r#  rÕ   )ra   r  rz   rc   Ú
is_integerr'  Úevalfr  rÙ   rÚ   r#  rž   )rr   Ú	real_exprÚouts      r;   r+  zParameterExpression.numericz  sË   € ð6 Ô"ð 	ÝØX°t´ÐXÐXÐXñô ð ð ÔÔ'ð 	*å�tÔ(Ñ)Ô)Ð)ð	8ØÔ)×/Ò/°TÐ/Ñ:Ô:ˆIˆIøÝð 	8ð 	8ð 	8õ ˜$Ô+Ñ,Ô,ˆCØ"œx¨3š˜�3”8�8°CÐ7Ð7Ð7ð		8øøøõ
 �YÑÔÐs   ÁA Á2BÂBc                ó   — | j         S )a   Return symbolic expression as a raw Sympy or Symengine object.

        Symengine is used preferentially; if both are available, the result will always be a
        ``symengine`` object.  Symengine is a separate library but has integration with Sympy.

        .. note::

            This is for interoperability only.  Qiskit will not accept or work with raw Sympy or
            Symegine expressions in its parameters, because they do not contain the tracking
            information used in circuit-parameter binding and assignment.
        )rc   ry   s    r;   r  zParameterExpression.sympify¨  s   € ð Ô Ð r:   )rh   r^   )ru   rv   )ru   r^   )ru   r�   )r‰   rŠ   ru   r�   )F)r�   r^   r‘   r’   ru   r�   )r¤   r^   r‘   r’   ru   r�   rk   )FN)
rÆ   r   rÇ   rŠ   rÈ   r’   rQ   r   ru   r�   )ru   rÓ   )ru   r=  )6r!   r"   r#   Ú__doc__Ú	__slots__rt   Úpropertyrz   r€   rJ   r�   r�   rK   r™   rš   rª   rÒ   rI   r<   ré   r=   rN   r>   rò   rõ   r÷   r?   rO   r@   rP   r   rA   rB   rC   rD   rE   rM   rF   rG   rH   r  r  r!  r%  r(  r,  r.  r2  r6  rL   r:  r<  r+  r  r9   r:   r;   r
   r
   g   sÅ  € € € € € ØQÐQðð ð €Ið ?Cð "ð "ð "ð "ð "ð "ð2 ð.ð .ð .ñ „Xð.ð ðð ð ñ „Xððð ð ð ð-ð -ð -ð -ð" HMð;
ð ;
ð ;
ð ;
ð ;
ð| EJð5
ð 5
ð 5
ð 5
ð 5
ðnð ð ðð ð ðð ð ð ð,  Øð?ð ?ð ?ð ?ð ?ðB)$ð )$ð )$ð )$ðVOð Oð Oð_ð _ð _ðOð Oð Oð`ð `ð `ðOð Oð OðKð Kð KðLð Lð Lð_ð _ð _ðSð Sð Sð
dð dð dðFð Fð FðWð Wð Wð	
ð 	
ð 	
ð>ð >ð >ð>ð >ð >ð>ð >ð >ð@ð @ð @ð@ð @ð @ð@ð @ð @ð>ð >ð >ð>ð >ð >ð@ð @ð @ð9ð 9ð 9ðAð Að Að
Mð 
Mð 
MðKð Kð Kð(
Ið 
Ið 
Ið?ð ?ð ?ðð ð ðð ð ð ð6ð 6ð 6ðð ð ðð ð ð*)ð )ð )ð, ð , ð , ð , ð\!ð !ð !ð !ð !r:   )rQ   r   )rD  Ú
__future__r   Údataclassesr   Úenumr   Útypingr   r   rº   rã   rÊ   r…   Úqiskit.circuit.exceptionsr   r	   rž   rŠ   r   rS   rU   rW   r]   r
   r9   r:   r;   ú<module>rL     s¨  ððð ð #Ð "Ð "Ð "Ð "Ð "à !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€à €€€Ø Ð Ð Ð à ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?ð
 Ð0°%Ð7Ô8Ð ðð ð ð ð ˆgñ ô ð ð0€ð2!ð !ð !ð !ð
 ð*ð *ð *ð *ð *ñ *ô *ñ „ð*ð ð%ð %ð %ð %ð %ñ %ô %ñ „ð%ð
M	!ð M	!ð M	!ð M	!ð M	!ñ M	!ô M	!ð M	!ðd Ð.°Ð5Ô6Ð Ð Ð r:   