core.circuit.parameter#
Quantum Circuit Parameter Expressions Module
This module provides a framework for defining and manipulating parameter expressions in quantum circuits. It allows for the creation of complex mathematical expressions involving named parameters, constant values, and binary operations.
Key components: - ParameterExpression: Abstract base class for all expressions - Parameter: Represents a named parameter in a quantum circuit - Value: Represents a constant numeric value - BinaryOperator: Represents operations between two expressions - BinaryOpeKind: Enumeration of supported binary operations
This module is essential for building parameterized quantum circuits, enabling the definition of circuits with variable parameters that can be optimized or swept over during execution or simulation.
Classes#
Abstract base class for parameter expressions in quantum circuits. |
|
Represents a named parameter in a quantum circuit. |
|
Represents a constant numeric value in an expression. |
|
Enumeration of binary operation types. |
|
Represents a binary operation between two ParameterExpressions. |
Functions#
|
Substitute parameters in an expression with specific values. |
Module Contents#
- class ParameterExpression#
Bases:
abc.ABC
Abstract base class for parameter expressions in quantum circuits.
This class defines the basic operations (addition, multiplication, division) that can be performed on parameter expressions.
- class Parameter(name: str)#
Bases:
ParameterExpression
Represents a named parameter in a quantum circuit.
Initialize a Parameter with a name.
- Parameters:
name (str) – The name of the parameter.
- name: str#
- class Value(value)#
Bases:
ParameterExpression
Represents a constant numeric value in an expression.
Initialize a Value with a numeric constant.
- Parameters:
value (number) – The constant value.
- value#
- class BinaryOpeKind#
Bases:
enum.Enum
Enumeration of binary operation types.
- ADD = '+'#
- MUL = '*'#
- DIV = '/'#
- class BinaryOperator(left, right, kind)#
Bases:
ParameterExpression
Represents a binary operation between two ParameterExpressions.
Initialize a BinaryOperator.
- Parameters:
left (ParameterExpression) – The left operand.
right (ParameterExpression) – The right operand.
kind (BinaryOpeKind) – The type of binary operation.
- left: ParameterExpression#
- right: ParameterExpression#
- kind: BinaryOpeKind#
- substitute_param_expr(expression: ParameterExpression, mapping: Mapping[Parameter, float]) float #
Substitute parameters in an expression with specific values.
- Parameters:
expression (ParameterExpression) – The expression to substitute.
mapping (Mapping[Parameter, number]) – A mapping of parameters to values.
- Returns:
The result of substituting the parameters in the expression.
- Return type:
float