Operator

class Operator(data, input_dims=None, output_dims=None)[source]

Matrix operator class

This represents a matrix operator \(M\) that will evolve() a Statevector \(|\psi\rangle\) by matrix-vector multiplication

\[|\psi\rangle \mapsto M|\psi\rangle,\]

and will evolve() a DensityMatrix \(\rho\) by left and right multiplication

\[\rho \mapsto M \rho M^\dagger.\]

Initialize an operator object.

Parameters
  • (QuantumCircuit or (data) – Instruction or BaseOperator or matrix): data to initialize operator.

  • input_dims (tuple) – the input subsystem dimensions. [Default: None]

  • output_dims (tuple) – the output subsystem dimensions. [Default: None]

Raises

QiskitError – if input data cannot be initialized as an operator.

Additional Information:

If the input or output dimensions are None, they will be automatically determined from the input data. If the input data is a Numpy array of shape (2**N, 2**N) qubit systems will be used. If the input operator is not an N-qubit operator, it will assign a single subsystem with dimension specified by the shape of the input.

Attributes

Operator.atol

The default absolute tolerance parameter for float comparisons.

Operator.data

Return data.

Operator.dim

Return tuple (input_shape, output_shape).

Operator.num_qubits

Return the number of qubits if a N-qubit operator or None otherwise.

Operator.qargs

Return the qargs for the operator.

Operator.rtol

The relative tolerance parameter for float comparisons.

Methods

Operator.__call__(qargs)

Return a clone with qargs set

Operator.__mul__(other)

Operator.add(other)

Return the linear operator self + other.

Operator.adjoint()

Return the adjoint of the operator.

Operator.compose(other[, qargs, front])

Return the composed operator.

Operator.conjugate()

Return the conjugate of the operator.

Operator.copy()

Make a deep copy of current operator.

Operator.dot(other[, qargs])

Return the right multiplied operator self * other.

Operator.equiv(other[, rtol, atol])

Return True if operators are equivalent up to global phase.

Operator.expand(other)

Return the tensor product operator other ⊗ self.

Operator.from_label(label)

Return a tensor product of single-qubit operators.

Operator.input_dims([qargs])

Return tuple of input dimension for specified subsystems.

Operator.is_unitary([atol, rtol])

Return True if operator is a unitary matrix.

Operator.multiply(other)

Return the linear operator other * self.

Operator.output_dims([qargs])

Return tuple of output dimension for specified subsystems.

Operator.power(n)

Return the matrix power of the operator.

Operator.reshape([input_dims, output_dims])

Return a shallow copy with reshaped input and output subsystem dimensions.

Operator.set_atol(value)

Set the class default absolute tolerance parameter for float comparisons.

Operator.set_rtol(value)

Set the class default relative tolerance parameter for float comparisons.

Operator.subtract(other)

Return the linear operator self - other.

Operator.tensor(other)

Return the tensor product operator self ⊗ other.

Operator.to_instruction()

Convert to a UnitaryGate instruction.

Operator.to_operator()

Convert operator to matrix operator class

Operator.transpose()

Return the transpose of the operator.

Operator.__call__(qargs)

Return a clone with qargs set

Operator.__mul__(other)