Skip to content

Two more small doc fixes #5711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 11, 2022
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/named_qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __repr__(self) -> str:

@staticmethod
def range(*args, prefix: str) -> List['NamedQubit']:
"""Returns a range of ``NamedQubit``\\s.
r"""Returns a range of `cirq.NamedQubit`s.

The range returned starts with the prefix, and followed by a qubit for
each number in the range, e.g.:
Expand Down
25 changes: 12 additions & 13 deletions cirq-core/cirq/sim/state_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,22 @@ def dirac_notation(self, decimals: int = 2) -> str:
def density_matrix_of(self, qubits: List['cirq.Qid'] = None) -> np.ndarray:
r"""Returns the density matrix of the state.

Calculate the density matrix for the system on the list, qubits.
Calculate the density matrix for the system on the qubits provided.
Any qubits not in the list that are present in self.state_vector() will
be traced out. If qubits is None the full density matrix for
be traced out. If qubits is None, the full density matrix for
self.state_vector() is returned, given self.state_vector() follows
standard Kronecker convention of numpy.kron.

For example:
self.state_vector() = np.array([1/np.sqrt(2), 1/np.sqrt(2)],
dtype=np.complex64)
qubits = None
gives us
$$
\rho = \begin{bmatrix}
0.5 & 0.5 \\
0.5 & 0.5
\end{bmatrix}
$$
For example, if `self.state_vector()` returns
`np.array([1/np.sqrt(2), 1/np.sqrt(2)], dtype=np.complex64)`,
then `density_matrix_of(qubits = None)` gives us

$$
\rho = \begin{bmatrix}
0.5 & 0.5 \\
0.5 & 0.5
\end{bmatrix}
$$

Args:
qubits: list containing qubit IDs that you would like
Expand Down