cirq.SimulationTrialResult.density_matrix¶
-
SimulationTrialResult.density_matrix(indices: Iterable[int] = None) → numpy.ndarray[source]¶ 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.final_state traced out. If indices is None the full density matrix for self.final_state is returned, given self.final_state follows the standard Kronecker convention of numpy.kron. For example: self.final_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.