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 the

  • function. (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

CircuitOp.coeff

The scalar coefficient multiplying the Operator.

CircuitOp.num_qubits

The number of qubits over which the Operator is defined.

CircuitOp.primitive

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 +.

CircuitOp.adjoint()

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 one Parameter 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.

CircuitOp.exp_i()

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’s Parameters, which can be bound to values later (via bind_parameters).

CircuitOp.neg()

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 **.

CircuitOp.primitive_strings()

Return a set of strings describing the primitives contained in the Operator.

CircuitOp.reduce()

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 ^.

CircuitOp.to_circuit()

Returns a QuantumCircuit equivalent to this Operator.

CircuitOp.to_circuit_op()

Returns a CircuitOp equivalent to this Operator.

CircuitOp.to_instruction()

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.