Operator¶
- class Operator(data, input_dims=None, output_dims=None)[source]¶
Matrix operator class
This represents a matrix operator \(M\) that will
evolve()
aStatevector
\(|\psi\rangle\) by matrix-vector multiplication\[|\psi\rangle \mapsto M|\psi\rangle,\]and will
evolve()
aDensityMatrix
\(\rho\) by left and right multiplication\[\rho \mapsto M \rho M^\dagger.\]Initialize an operator object.
- Parameters
or (data (QuantumCircuit) – 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
The default absolute tolerance parameter for float comparisons.
Return data.
Return tuple (input_shape, output_shape).
Return the number of qubits if a N-qubit operator or None otherwise.
Return the qargs for the operator.
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.
Return the adjoint of the operator.
Operator.compose
(other[, qargs, front])Return the composed operator.
Return the conjugate of the operator.
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.
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.
Convert to a UnitaryGate instruction.
Convert operator to matrix operator class
Return the transpose of the operator.
Operator.__call__
(qargs)Return a clone with qargs set
Operator.__mul__
(other)