ComposedOp¶
- class ComposedOp(oplist, coeff=1.0, abelian=False)[source]¶
A class for lazily representing compositions of Operators. Often Operators cannot be efficiently composed with one another, but may be manipulated further so that they can be composed later. This class holds logic to indicate that the Operators in
oplist
are meant to be composed, and therefore if they reach a point in which they can be, such as after conversion to QuantumCircuits or matrices, they can be reduced by composition.- Parameters
oplist (
List
[OperatorBase
]) – The Operators being composed.coeff (
Union
[int
,float
,complex
,ParameterExpression
]) – A coefficient multiplying the operatorabelian (
bool
) – Indicates whether the Operators inoplist
are known to mutually commute.
Attributes
Whether the Operators in
oplist
are known to commute with one another.The scalar coefficient multiplying the Operator.
The function defining how to combine
oplist
(or Numbers, or NumPy arrays) to produce the Operator’s underlying function.Indicates whether the ListOp or subclass is distributive under composition.
The number of qubits over which the Operator is defined.
The list of
OperatorBases
defining the underlying function of this Operator.Methods
ComposedOp.__getitem__
(offset)Allows array-indexing style access to the Operators in
oplist
.Length of
oplist
.ComposedOp.__mul__
(other)Overload
*
for Operator scalar multiplication.ComposedOp.add
(other)Return Operator addition of self and other, overloaded by
+
.Return a new Operator equal to the Operator’s adjoint (conjugate transpose), overloaded by
~
.ComposedOp.assign_parameters
(param_dict)Binds scalar values to any Terra
Parameters
in the coefficients or primitives of the Operator, or substitutes oneParameter
for another.ComposedOp.bind_parameters
(param_dict)Same as assign_parameters, but maintained for consistency with QuantumCircuit in Terra (which has both assign_parameters and bind_parameters).
ComposedOp.compose
(other)Return Operator Composition between self and other (linear algebra-style: A@B(x) = A(B(x))), overloaded by
@
.ComposedOp.equals
(other)Evaluate Equality between Operators, overloaded by
==
.ComposedOp.eval
([front])Evaluate the Operator’s underlying function, either on a binary string or another Operator.
Return an
OperatorBase
equivalent to an exponentiation of self * -i, e^(-i*op).ComposedOp.log_i
([massive])Return a
MatrixOp
equivalent to log(H)/-i for this operator H.ComposedOp.mul
(scalar)Returns the scalar multiplication of the Operator, overloaded by
*
, including support for Terra’sParameters
, which can be bound to values later (viabind_parameters
).Return the Operator’s negation, effectively just multiplying by -1.0, overloaded by
-
.Reduce without attempting to expand all distributive compositions.
ComposedOp.power
(exponent)Return Operator composed with self multiple times, overloaded by
**
.Return a set of strings describing the primitives contained in the Operator.
Try collapsing the Operator structure, usually after some type of conversion, e.g.
ComposedOp.tensor
(other)Return tensor product between self and other, overloaded by
^
.ComposedOp.tensorpower
(other)Return tensor product with self multiple times, overloaded by
^
.Returns an equivalent Operator composed of only QuantumCircuit-based primitives, such as
CircuitOp
andCircuitStateFn
.ComposedOp.to_legacy_op
([massive])Attempt to return the Legacy Operator representation of the Operator.
ComposedOp.to_matrix
([massive])Return NumPy representation of the Operator.
ComposedOp.to_matrix_op
([massive])Returns an equivalent Operator composed of only NumPy-based primitives, such as
MatrixOp
andVectorStateFn
.ComposedOp.to_pauli_op
([massive])Returns an equivalent Operator composed of only Pauli-based primitives, such as
PauliOp
.Returns SciPy sparse matrix representation of the Operator.
ComposedOp.traverse
(convert_fn[, coeff])Apply the convert_fn to each node in the oplist.
Length of
oplist
.ComposedOp.__mul__
(other)Overload
*
for Operator scalar multiplication.ComposedOp.__getitem__
(offset)Allows array-indexing style access to the Operators in
oplist
.