CircuitOp¶
- class CircuitOp(primitive=None, coeff=1.0)[source]¶
Class for Operators backed by Terra’s
QuantumCircuit
module.- Parameters
primitive (
Union
[Instruction
,QuantumCircuit
,None
]) – The QuantumCircuit which defines thefunction. (behavior of the underlying) –
coeff (
Union
[int
,float
,complex
,ParameterExpression
,None
]) – A coefficient multiplying the primitive
- Raises
TypeError – Unsupported primitive, or primitive has ClassicalRegisters.
Attributes
The scalar coefficient multiplying the Operator.
The number of qubits over which the Operator is defined.
The primitive defining the underlying function of the Operator.
Methods
CircuitOp.__mul__
(other)Overload
*
for Operator scalar multiplication.CircuitOp.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
~
.CircuitOp.assign_parameters
(param_dict)Binds scalar values to any Terra
Parameters
in the coefficients or primitives of the Operator, or substitutes oneParameter
for another.CircuitOp.bind_parameters
(param_dict)Same as assign_parameters, but maintained for consistency with QuantumCircuit in Terra (which has both assign_parameters and bind_parameters).
CircuitOp.compose
(other)Return Operator Composition between self and other (linear algebra-style: A@B(x) = A(B(x))), overloaded by
@
.CircuitOp.equals
(other)Evaluate Equality between Operators, overloaded by
==
.CircuitOp.eval
([front])Evaluate the Operator’s underlying function, either on a binary string or another Operator.
Return Operator exponentiation, equaling e^(-i * op)
CircuitOp.log_i
([massive])Return a
MatrixOp
equivalent to log(H)/-i for this operator H.CircuitOp.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
-
.CircuitOp.permute
(permutation)Permute the qubits of the circuit.
CircuitOp.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.
CircuitOp.tensor
(other)Return tensor product between self and other, overloaded by
^
.CircuitOp.tensorpower
(other)Return tensor product with self multiple times, overloaded by
^
.Returns a
QuantumCircuit
equivalent to this Operator.Returns a
CircuitOp
equivalent to this Operator.Returns an
Instruction
equivalent to this Operator.CircuitOp.to_legacy_op
([massive])Attempt to return the Legacy Operator representation of the Operator.
CircuitOp.to_matrix
([massive])Return NumPy representation of the Operator.
CircuitOp.to_matrix_op
([massive])Returns a
MatrixOp
equivalent to this Operator.CircuitOp.to_pauli_op
([massive])Returns a sum of
PauliOp
s equivalent to this Operator.CircuitOp.__mul__
(other)Overload
*
for Operator scalar multiplication.