MatrixOp

class MatrixOp(primitive=None, coeff=1.0)[source]

Class for Operators represented by matrices, backed by Terra’s Operator module.

Parameters
  • primitive (Union[list, ndarray, spmatrix, Operator, None]) – The matrix-like object which defines the behavior of the underlying function.

  • coeff (Union[int, float, complex, ParameterExpression, None]) – A coefficient multiplying the primitive

Raises
  • TypeError – invalid parameters.

  • ValueError – invalid parameters.

Attributes

MatrixOp.coeff

The scalar coefficient multiplying the Operator.

MatrixOp.num_qubits

The number of qubits over which the Operator is defined.

MatrixOp.primitive

The primitive defining the underlying function of the Operator.

Methods

MatrixOp.__mul__(other)

Overload * for Operator scalar multiplication.

MatrixOp.add(other)

Return Operator addition of self and other, overloaded by +.

MatrixOp.adjoint()

Return a new Operator equal to the Operator’s adjoint (conjugate transpose), overloaded by ~.

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

MatrixOp.bind_parameters(param_dict)

Same as assign_parameters, but maintained for consistency with QuantumCircuit in Terra (which has both assign_parameters and bind_parameters).

MatrixOp.compose(other)

Return Operator Composition between self and other (linear algebra-style: A@B(x) = A(B(x))), overloaded by @.

MatrixOp.equals(other)

Evaluate Equality between Operators, overloaded by ==.

MatrixOp.eval([front])

Evaluate the Operator’s underlying function, either on a binary string or another Operator.

MatrixOp.exp_i()

Return a CircuitOp equivalent to e^-iH for this operator H

MatrixOp.log_i([massive])

Return a MatrixOp equivalent to log(H)/-i for this operator H.

MatrixOp.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).

MatrixOp.neg()

Return the Operator’s negation, effectively just multiplying by -1.0, overloaded by -.

MatrixOp.power(exponent)

Return Operator composed with self multiple times, overloaded by **.

MatrixOp.primitive_strings()

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

MatrixOp.reduce()

Try collapsing the Operator structure, usually after some type of conversion, e.g.

MatrixOp.tensor(other)

Return tensor product between self and other, overloaded by ^.

MatrixOp.tensorpower(other)

Return tensor product with self multiple times, overloaded by ^.

MatrixOp.to_circuit()

Returns a QuantumCircuit equivalent to this Operator.

MatrixOp.to_circuit_op()

Returns a CircuitOp equivalent to this Operator.

MatrixOp.to_instruction()

Returns an Instruction equivalent to this Operator.

MatrixOp.to_legacy_op([massive])

Attempt to return the Legacy Operator representation of the Operator.

MatrixOp.to_matrix([massive])

Return NumPy representation of the Operator.

MatrixOp.to_matrix_op([massive])

Returns a MatrixOp equivalent to this Operator.

MatrixOp.to_pauli_op([massive])

Returns a sum of PauliOp s equivalent to this Operator.

MatrixOp.__mul__(other)

Overload * for Operator scalar multiplication.