Skip to content

How to format big spares matrices in docs #5359

Open
@dabacon

Description

@dabacon

As part of #5344 @viathor brought up possibly formatting our sparse matrices in docstring (and hence API docs) with blanks instead of 0s.

So for example we currently format a CNOT as

\begin{bmatrix}
    1 & 0 & 0 & 0 \\
    0 & 1 & 0 & 0 \\
    0 & 0 & 0 & 1 \\
    0 & 0 & 1 & 0
\end{bmatrix}

but we could instead use

\begin{bmatrix}
    1 & & & \\
    & 1 & & \\
    & & 0 & 1 \\
    & & 1 & 0
\end{bmatrix}

or even

\begin{bmatrix}
    1 & & & \\
    & 1 & & \\
    & & & 1 \\
    & & 1 &
\end{bmatrix}

The sparser version does render better in the doc string, and it does render fairly nicely on the documentation site. But I worry a bit that it is confusing to users. I think for people just starting in quantum it might be super confusing.

Current status (after #5344) is that the sparse representation is only used for 3 qubit gates or greater.

Should we use the sparse representation for 2 qubit gates (I think for 1 qubit gates, keeping the zeros parses fine)

Metadata

Metadata

Assignees

Labels

area/docsarea/docstringskind/healthFor CI/testing/release process/refactoring/technical debt itemstriage/needs-feasibility[Feature requests] Needs design work to prove feasibility before accepting

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions