DensityMatrix¶
- class DensityMatrix(data, dims=None)[source]¶
DensityMatrix class
Initialize a density matrix object.
- Parameters
data (matrix_like or vector_like) – a density matrix or statevector. If a vector the density matrix is constructed as the projector of that vector.
dims (int or tuple or list) – Optional. The subsystem dimension of the state (See additional information).
- Raises
QiskitError – if input data is not valid.
- Additional Information:
The
dims
kwarg can be None, an integer, or an iterable of integers.Iterable
– the subsystem dimensions are the values in the list with the total number of subsystems given by the length of the list.Int
orNone
– the leading dimension of the input matrix specifies the total dimension of the density matrix. If it is a power of two the state will be initialized as an N-qubit state. If it is not a power of two the state will have a single d-dimensional subsystem.
Attributes
The absolute tolerance parameter for float comparisons.
Return data.
Return total state dimension.
Return the number of qubits if a N-qubit state or None otherwise.
The relative tolerance parameter for float comparisons.
Methods
DensityMatrix.__mul__
(other)DensityMatrix.add
(other)Return the linear combination self + other.
Return the conjugate of the density matrix.
Make a copy of current operator.
DensityMatrix.dims
([qargs])Return tuple of input dimension for specified subsystems.
DensityMatrix.evolve
(other[, qargs])Evolve a quantum state by an operator.
DensityMatrix.expand
(other)Return the tensor product state other ⊗ self.
DensityMatrix.from_instruction
(instruction)Return the output density matrix of an instruction.
DensityMatrix.from_int
(i, dims)Return a computational basis state density matrix.
DensityMatrix.from_label
(label)Return a tensor product of Pauli X,Y,Z eigenstates.
DensityMatrix.is_valid
([atol, rtol])Return True if trace 1 and positive semidefinite.
DensityMatrix.measure
([qargs])Measure subsystems and return outcome and post-measure state.
DensityMatrix.multiply
(other)Return the scalar multipled state other * self.
DensityMatrix.probabilities
([qargs, decimals])Return the subsystem measurement probability vector.
DensityMatrix.probabilities_dict
([qargs, …])Return the subsystem measurement probability dictionary.
Return the purity of the quantum state.
DensityMatrix.reset
([qargs])Reset state or subsystems to the 0-state.
DensityMatrix.sample_counts
(shots[, qargs])Sample a dict of qubit measurement outcomes in the computational basis.
DensityMatrix.sample_memory
(shots[, qargs])Sample a list of qubit measurement outcomes in the computational basis.
DensityMatrix.seed
([value])Set the seed for the quantum state RNG.
DensityMatrix.set_atol
(value)Set the class default absolute tolerance parameter for float comparisons.
DensityMatrix.set_rtol
(value)Set the class default relative tolerance parameter for float comparisons.
DensityMatrix.subtract
(other)Return the linear operator self - other.
DensityMatrix.tensor
(other)Return the tensor product state self ⊗ other.
Returns the density matrix as a counts dict of probabilities.
DensityMatrix.to_dict
([decimals])Convert the density matrix to dictionary form.
Convert to Operator
Return the trace of the density matrix.
DensityMatrix.__mul__
(other)