ParameterExpression#
- class qiskit.circuit.ParameterExpression(symbol_map, expr)[ソース]#
ベースクラス:
object
ParameterExpression class to enable creating expressions of Parameters.
Create a new
ParameterExpression
.Not intended to be called directly, but to be instantiated via operations on other
Parameter
orParameterExpression
objects.- パラメータ:
symbol_map (Dict[Parameter, [ParameterExpression, float, or int]]) – Mapping of
Parameter
instances to thesympy.Symbol
serving as their placeholder in expr.expr (sympy.Expr) – Expression of
sympy.Symbol
s.
Attributes
- parameters#
Returns a set of the unbound Parameters in the expression.
Methods
- assign(parameter, value)[ソース]#
Assign one parameter to a value, which can either be numeric or another parameter expression.
- パラメータ:
parameter (Parameter) – A parameter in this expression whose value will be updated.
value (ParameterExpression | float) – The new value to bind to.
- 戻り値:
A new expression parameterized by any parameters which were not bound by assignment.
- 戻り値の型:
- bind(parameter_values, allow_unknown_parameters=False)[ソース]#
Binds the provided set of parameters to their corresponding values.
- パラメータ:
parameter_values (dict) – Mapping of Parameter instances to the numeric value to which they will be bound.
allow_unknown_parameters (bool) – If
False
, raises an error ifparameter_values
contains Parameters in the keys outside those present in the expression. IfTrue
, any such parameters are simply ignored.
- 例外:
If parameter_values contains Parameters outside those in self. - If a non-numeric value is passed in parameter_values.
If binding the provided values requires division by zero.
- 戻り値:
A new expression parameterized by any parameters which were not bound by parameter_values.
- 戻り値の型:
- gradient(param)[ソース]#
Get the derivative of a parameter expression w.r.t. a specified parameter expression.
- パラメータ:
param (Parameter) – Parameter w.r.t. which we want to take the derivative
- 戻り値:
ParameterExpression representing the gradient of param_expr w.r.t. param or complex or float number
- 戻り値の型:
- subs(parameter_map, allow_unknown_parameters=False)[ソース]#
Returns a new Expression with replacement Parameters.
- パラメータ:
parameter_map (dict) – Mapping from Parameters in self to the ParameterExpression instances with which they should be replaced.
allow_unknown_parameters (bool) – If
False
, raises an error ifparameter_map
contains Parameters in the keys outside those present in the expression. IfTrue
, any such parameters are simply ignored.
- 例外:
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.
- 戻り値:
A new expression with the specified parameters replaced.
- 戻り値の型:
- sympify()[ソース]#
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.注釈
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.