Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ``NamedQubit``s.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on with the double-backquote here? Why not:

r"""Returns a range of `cirq.NamedQubit`s."""

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


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