qiskit.circuit.ParameterExpression
class ParameterExpression(symbol_map, expr)
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
or ParameterExpression
objects.
Parameters
- 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.
__init__
__init__(symbol_map, expr)
Create a new ParameterExpression
.
Not intended to be called directly, but to be instantiated via operations on other Parameter
or ParameterExpression
objects.
Parameters
- 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.
Methods
__init__ (symbol_map, expr) | Create a new ParameterExpression . |
arccos () | Arccos of a ParameterExpression |
arcsin () | Arcsin of a ParameterExpression |
arctan () | Arctan of a ParameterExpression |
assign (parameter, value) | Assign one parameter to a value, which can either be numeric or another parameter expression. |
bind (parameter_values) | Binds the provided set of parameters to their corresponding values. |
conjugate () | Return the conjugate. |
cos () | Cosine of a ParameterExpression |
exp () | Exponential of a ParameterExpression |
gradient (param) | Get the derivative of a parameter expression w.r.t. |
is_real () | Return whether the expression is real |
log () | Logarithm of a ParameterExpression |
sin () | Sine of a ParameterExpression |
subs (parameter_map) | Returns a new Expression with replacement Parameters. |
tan () | Tangent of a ParameterExpression |
Attributes
parameters | Returns a set of the unbound Parameters in the expression. |
arccos
arccos()
Arccos of a ParameterExpression
arcsin
arcsin()
Arcsin of a ParameterExpression
arctan
arctan()
Arctan of a ParameterExpression
assign
assign(parameter, value)
Assign one parameter to a value, which can either be numeric or another parameter expression.
Parameters
- parameter (Parameter) – A parameter in this expression whose value will be updated.
- value (
Union
[ParameterExpression
,float
]) – The new value to bind to.
Return type
ParameterExpression
Returns
A new expression parameterized by any parameters which were not bound by assignment.
bind
bind(parameter_values)
Binds the provided set of parameters to their corresponding values.
Parameters
parameter_values (Dict
) – Mapping of Parameter instances to the numeric value to which they will be bound.
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.
Return type
ParameterExpression
Returns
A new expression parameterized by any parameters which were not bound by parameter_values.
conjugate
conjugate()
Return the conjugate.
Return type
ParameterExpression
cos
cos()
Cosine of a ParameterExpression
exp
exp()
Exponential of a ParameterExpression
gradient
gradient(param)
Get the derivative of a parameter expression w.r.t. a specified parameter expression.
Parameters
param (Parameter) – Parameter w.r.t. which we want to take the derivative
Return type
Union
[ParameterExpression
, float
]
Returns
ParameterExpression representing the gradient of param_expr w.r.t. param
is_real
is_real()
Return whether the expression is real
log
log()
Logarithm of a ParameterExpression
parameters
Returns a set of the unbound Parameters in the expression.
Return type
Set
sin
sin()
Sine of a ParameterExpression
subs
subs(parameter_map)
Returns a new Expression with replacement Parameters.
Parameters
parameter_map (Dict
) – Mapping from Parameters in self to the ParameterExpression instances with which they should be replaced.
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.
Return type
ParameterExpression
Returns
A new expression with the specified parameters replaced.
tan
tan()
Tangent of a ParameterExpression