Skip to content

Commit

Permalink
Two more small doc fixes (#5711)
Browse files Browse the repository at this point in the history
- Fix NamedQubit reference
- Fix state vector latex
  • Loading branch information
dstrain115 authored Jul 11, 2022
1 parent de76121 commit 1e2ec4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
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

0 comments on commit 1e2ec4f

Please sign in to comment.