cirq.SimulatorStep.density_matrix¶
-
SimulatorStep.density_matrix(indices: Iterable[int] = None) → numpy.ndarray¶ Returns the density matrix of the wavefunction.
Calculate the density matrix for the system on the given qubit indices, with the qubits not in indices that are present in self.state traced out. If indices is None the full density matrix for self.state is returned, given self.state follows standard Kronecker convention of numpy.kron. For example: self.state = np.array([1/np.sqrt(2), 1/np.sqrt(2)], dtype=np.complex64) indices = None gives us
ho = egin{bmatrix}0.5 & 0.50.5 & 0.5\end{bmatrix}Args: indices: list containing indices for qubits that you would like to include in the density matrix (i.e.) qubits that WON'T be traced out. Returns: A numpy array representing the density matrix. Raises: ValueError: if the size of the state represents more than 25 qubits. IndexError: if the indices are out of range for the number of qubits corresponding to the state.