View source on GitHub |
Returns the density matrix of the state vector.
cirq.density_matrix_from_state_vector(
state_vector: np.ndarray,
indices: Optional[Iterable[int]] = None,
qid_shape: Optional[Tuple[int, ...]] = None
) -> np.ndarray
Calculate the density matrix for the system on the given qubit indices,
with the qubits not in indices that are present in state vector traced out.
If indices is None the full density matrix for state_vector
is returned.
We assume state_vector
follows the standard Kronecker convention of
numpy.kron (big-endian).
For example:
state_vector = np.array([1/np.sqrt(2), 1/np.sqrt(2)], dtype=np.complex64) indices = None gives us
$$
\rho = \begin{bmatrix}
0.5 & 0.5 \\
0.5 & 0.5
\end{bmatrix}
$$
Returns | |
---|---|
A numpy array representing the density matrix. |