Skip to content

Commit 366f99c

Browse files
committed
documentation improvements to close #258
1 parent 8d07e1e commit 366f99c

File tree

4 files changed

+76
-151
lines changed

4 files changed

+76
-151
lines changed

docs/src/datastructures.md

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,26 @@ necessary.
1111

1212
```@raw html
1313
<div class="mermaid">
14-
flowchart TB
14+
flowchart TD
1515
A["<code>Tableau Data Structure Selection</code>"]
1616
class A startEnd
17-
18-
A -->|<code>Are the states pure?</code>| B{ }
17+
A --> B{"Is the state a stabilizer?"}
1918
class A,B startEnd
20-
21-
B -->|<code>Yes</code>| C["<code>Stabilizer</code>"]
22-
B -->|<code>No</code>| D{ }
23-
class B decision
24-
25-
D -->|<code>Are the states mixed?</code>| E{ }
26-
class D,E decision
27-
28-
C --> C_desc1["<code>Ensures pure stabilizer states</code>"]
29-
C --> C_desc2["<code>Requires user to check for consistency</code>"]
30-
C --> C_desc3["<code>Efficient project! operations</code>"]
31-
class C_desc1,C_desc2,C_desc3 description
32-
33-
C --> G["<code>Destabilizer</code>"]
34-
G --> G_desc1["<code>No stabilizer canonicalization needed</code>"]
35-
class G_desc1 description
36-
37-
E -->|<code>Yes</code>| F["<code>MixedStabilizer</code>"]
38-
F --> F_desc1["<code>Explicitly tracks rank of mixed states</code>"]
39-
F --> F_desc2["<code>Project! on non-Stabilizer commuting operators</code>"]
40-
class F_desc1,F_desc2 description
41-
42-
E -->|<code>No</code>| H["<code>MixedDestabilizer</code>"]
43-
H --> H_desc1["<code>Tracks destabilizer and logical operators</code>"]
44-
H --> H_desc2["<code>Efficient project! operations</code>"]
19+
B -->|Yes| C{"Pure state?"}
20+
B -->|No| D{"Pure state?"}
21+
class B,C,D decision
22+
C -->|Yes| E["<code>Stabilizer</code>"]
23+
E --> E_desc["<code>Pure stabilizer states<br/>Efficient 'project!' operations</code>"]
24+
class E_desc description
25+
C -->|No| F["<code>MixedStabilizer</code>"]
26+
F --> F_desc["<code>Tracks rank of mixed states<br/>'Project!' on non-Stabilizer commuting operators</code>"]
27+
class F_desc description
28+
D -->|Yes| G["<code>Destabilizer</code>"]
29+
G --> G_desc["<code>Pure stabilizer states<br/>Tracks destabilizers<br/>Efficient 'project!' operations</code>"]
30+
class G_desc description
31+
D -->|No| H["<code>MixedDestabilizer<code>"]
32+
H --> H_desc["<code>Tracks destabilizers<br/>Tracks 'logical' operators<br/>Efficient 'project!' operations</code>"]
33+
class H_desc description
4534
</div>
4635
```
4736

docs/src/mixed.md

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```@meta
44
DocTestSetup = quote
5-
using QuantumClifford: @S_str, Destabilizer, MixedDestabilizer, MixedStabilizer, stabilizerview, destabilizerview, logicalxview, logicalzview, @T_str, _T_str, canonicalize!, Tableau
5+
using QuantumClifford
66
end
77
```
88

@@ -18,7 +18,7 @@ generators.
1818
# Options for constructing with MixedDestabilizer
1919

2020
- Given a `Destabilizer` object (which presumesfull rank), convert it
21-
into a `MixedDestabilizer` object. This allows for the possibility of
21+
into a `MixedDestabilizer` object. This allows for the possibility of
2222
rank deficiency.
2323

2424
```jldoctest mix
@@ -66,8 +66,8 @@ julia> logicalzview(m)
6666
```
6767

6868
- Similar to the first option, but with the added capability to
69-
specify the "rank." This rank determines the number of rows
70-
associated with the `Stabilizer` and the number corresponding
69+
specify the "rank". This rank determines the number of rows
70+
associated with the `Stabilizer` and the number corresponding
7171
to the logical operators.
7272

7373
```jldoctest mix
@@ -80,10 +80,12 @@ julia> MixedDestabilizer(T"ZI IX XX ZZ", 2)
8080
+ ZZ
8181
```
8282

83-
If the macro string `@T_str` is not convenient, use the normal strings
83+
If the macro string `@T_str` is not convenient, use the normal strings
8484
`_T_str`.
8585

8686
```jldoctest mix
87+
julia> using QuantumClifford: _T_str # hide
88+
8789
julia> MixedDestabilizer(_T_str("ZI IX XX ZZ"), 2)
8890
𝒟ℯ𝓈𝓉𝒶𝒷
8991
+ Z_
@@ -93,10 +95,10 @@ julia> MixedDestabilizer(_T_str("ZI IX XX ZZ"), 2)
9395
+ ZZ
9496
```
9597

96-
- Given a `Stabilizer` object (whichmay have fewer rows than columns)
97-
, perform the necessary canonicalization to determine the
98-
corresponding destabilizer and logical operators, resulting in a
99-
complete MixedDestabilizer object.
98+
- Given a `Stabilizer` object (whichmay have fewer rows than columns),
99+
perform the necessary canonicalization to determine the corresponding
100+
destabilizer and logical operators, resulting in a complete
101+
MixedDestabilizer object.
100102

101103
```jldoctest mix
102104
julia> s = S"-XXX
@@ -116,9 +118,9 @@ julia> MixedDestabilizer(s, undoperm=false, reportperm=false)
116118
+ Z_Z
117119
```
118120

119-
When `undoperm` is set to `false`, the column permutations are not reversed.
120-
As a result, the qubits may be reindexed according to the permutations
121-
made during the canonicalization process.
121+
When `undoperm` is set to `false`, the column permutations are not
122+
reversed. As a result, the qubits may be reindexed according to
123+
the permutations made during the canonicalization process.
122124

123125
```jldoctest mix
124126
julia> MixedDestabilizer(s, undoperm=true, reportperm=false)
@@ -134,9 +136,9 @@ julia> MixedDestabilizer(s, undoperm=true, reportperm=false)
134136
+ ZZ_
135137
```
136138

137-
When `undoperm` is set to `true`, the column permutations performed during
138-
canonicalizationare automatically reversed before finalizing the
139-
`MixedDestabilizer`.
139+
When `undoperm` is set to `true`, the column permutations performed
140+
during canonicalizationare automatically reversed before finalizing
141+
the `MixedDestabilizer`.
140142

141143
```jldoctest mix
142144
julia> MixedDestabilizer(canonicalize!(s))
@@ -152,12 +154,14 @@ julia> MixedDestabilizer(canonicalize!(s))
152154
+ ZZ_
153155
```
154156

155-
- A low-level constructor that accepts a manually created `Tableau` object
156-
and rank. Note that the `Tableau` object is not currently public. It
157-
serves as the underlying data structure for all related objects but
158-
does not assume commutativity or other properties.
157+
- A low-level constructor that accepts a manually created `Tableau`
158+
object and rank. Note that the `Tableau` object is not currently
159+
public. It serves as the underlying data structure for all related
160+
objects but does not assume commutativity or other properties.
159161

160162
```jldoctest mix
163+
julia> using QuantumClifford: Tableau # hide
164+
161165
julia> MixedDestabilizer(Tableau(Bool[0 0; 0 1; 1 1; 1 0],
162166
Bool[1 0; 0 0; 0 0; 1 1]), 2)
163167
𝒟ℯ𝓈𝓉𝒶𝒷
@@ -170,9 +174,9 @@ julia> MixedDestabilizer(Tableau(Bool[0 0; 0 1; 1 1; 1 0],
170174

171175
# Options for constructing with MixedStabilizer
172176

173-
- Given a `Stabilizer` object (which presumesfull rank), convert it
174-
into a `MixedStabilizer` object. This allows for the possibility of
175-
rank deficiency.
177+
- Given a `Stabilizer` object (which presumesfull rank), convert
178+
it into a `MixedStabilizer` object. This allows for the
179+
possibility of rank deficiency.
176180

177181
```jldoctest mix
178182
julia> s = S"-XXX
@@ -189,10 +193,10 @@ julia> MixedStabilizer(s, 2)
189193
- Z_Z
190194
```
191195

192-
- Similar to the first option, but with the added capability to
193-
specify the "rank." This rank determines the number of rows
194-
associated with the `Stabilizer` and the number corresponding
195-
to the logical operators.
196+
- Similar to the first option, but with the added capability
197+
to specify the "rank." This rank determines the number of
198+
rows associated with the `Stabilizer` and the number
199+
corresponding to the logical operators.
196200

197201
```jldoctest mix
198202
julia> MixedStabilizer(S"-XXX -ZIZ IZZ")
@@ -207,7 +211,7 @@ julia> MixedStabilizer(S"-XXX -ZIZ IZZ", 2)
207211

208212
- A low-level constructor that accepts a manually created `Tableau`
209213
object and rank. Note that the `Tableau` object is not currently
210-
public. It serves as the underlying data structure for all related
214+
public. It serves as the underlying data structure for all related
211215
objects but does not assume commutativity or other properties.
212216

213217
```jldoctest mix

docs/src/stab-algebra-manual.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
```@meta
44
DocTestSetup = quote
5-
using QuantumClifford: @S_str, Stabilizer, Destabilizer, MixedDestabilizer, MixedStabilizer, stabilizerview, destabilizerview, logicalxview, logicalzview, @T_str, _T_str, @P_str, PauliOperator, ⊗, comm, prodphase, xview, xbit, getindex, setindex!, firstindex, lastindex, stab_to_gf2, canonicalize!, project!, Register, apply!, bitview, sMX, traceout!, generate!, tHadamard, tPhase, tCNOT, permute, apply!, CliffordOperator, sHadamard, sCNOT, phases, tId1, @C_str, tab, Tableau
5+
using QuantumClifford
66
end
77
```
88

@@ -146,6 +146,8 @@ number of different constructors.
146146
See also the [data structures discussion page](@ref Choosing-Appropriate-Data-Structure).
147147

148148
```jldoctest
149+
julia> using QuantumClifford: Tableau # hide
150+
149151
julia> S"-XX
150152
+ZZ"
151153
- XX
@@ -173,6 +175,16 @@ julia> Stabilizer([0x2, 0x0],
173175
0 0 1 1])
174176
- XX
175177
+ ZZ
178+
179+
julia> Stabilizer(T"-XX ZZ")
180+
- XX
181+
+ ZZ
182+
183+
julia> Stabilizer(Tableau([0x2, 0x0],
184+
Bool[1 1; 0 0],
185+
Bool[0 0; 1 1]))
186+
- XX
187+
+ ZZ
176188
```
177189

178190
Direct sums can be performed,
@@ -206,36 +218,6 @@ julia> s[[3,1],[2]]
206218
207219
julia> s[3][3]
208220
(false, true)
209-
210-
julia> getindex(s, 1)
211-
- XYZ
212-
213-
julia> getindex(s, 3, 1)
214-
(true, false)
215-
216-
julia> setindex!(s, P"Z", 1)
217-
+ Z__
218-
- Z_X
219-
+ X_Z
220-
221-
julia> setindex!(s, P"ZYX", 1)
222-
+ ZYX
223-
- Z_X
224-
+ X_Z
225-
226-
julia> setindex!(s, (true, true), 1, 1)
227-
+ YYX
228-
- Z_X
229-
+ X_Z
230-
231-
julia> firstindex(s)
232-
1
233-
234-
julia> lastindex(s)
235-
3
236-
237-
julia> lastindex(s, 2)
238-
3
239221
```
240222

241223
Consistency at creation is not verified so nonsensical stabilizers can be
@@ -708,18 +690,29 @@ julia> d = Destabilizer(s)
708690
```
709691

710692
- A low-level constructor that accepts a manually created `Tableau`
711-
object. Note thatthe `Tableau` object is not currently public. It serves
712-
as the underlying data structure for all related objects but does not
713-
assume commutativity or other properties.
693+
object. Note thatthe `Tableau` object is not currently public. It
694+
serves as the underlying data structure for all related objects
695+
but does not assume commutativity or other properties.
714696

715697
```jldoctest destab
716-
julia> d₁ = Destabilizer(Tableau(Bool[0 0; 0 1; 1 1; 0 0], Bool[1 0; 0 0; 0 0; 0 1]))
698+
julia> using QuantumClifford: Tableau # hide
699+
700+
julia> d₁ = Destabilizer(Tableau(Bool[0 0; 0 1; 1 1; 0 0],
701+
Bool[1 0; 0 0; 0 0; 0 1]))
717702
𝒟ℯ𝓈𝓉𝒶𝒷
718703
+ Z_
719704
+ _X
720705
𝒮𝓉𝒶𝒷
721706
+ XX
722707
+ _Z
708+
709+
julia> d₂ = Destabilizer(T"ZX ZI -ZZ -XY")
710+
𝒟ℯ𝓈𝓉𝒶𝒷
711+
+ ZX
712+
+ Z_
713+
𝒮𝓉𝒶𝒷
714+
- ZZ
715+
- XY
723716
```
724717

725718
They have convenience methods to extract only the stabilizer and destabilizer

src/QuantumClifford.jl

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -355,67 +355,6 @@ julia> s[1,1] = (true, false); s
355355
+ __
356356
```
357357
358-
Stabilizer can be copied and assigned.
359-
360-
```jldoctest stabilizer
361-
julia> s = S"-XXX
362-
+ZZI
363-
-IZZ";
364-
365-
julia> s1 = copy(s)
366-
- XXX
367-
+ ZZ_
368-
- _ZZ
369-
```
370-
371-
`Length` and `size` of stabilizer can be determined.
372-
373-
```jldoctest stabilizer
374-
julia> length(s)
375-
3
376-
377-
julia> size(s)
378-
(3, 3)
379-
```
380-
381-
Indexing operations on stabilizer via `setindex!` and `getindex`.
382-
383-
```jldoctest stabilizer
384-
julia> s = S"-XYZ
385-
-ZIX
386-
+XIZ";
387-
388-
julia> getindex(s, 1)
389-
- XYZ
390-
391-
julia> getindex(s, 3, 1)
392-
(true, false)
393-
394-
julia> setindex!(s, P"Z", 1)
395-
+ Z__
396-
- Z_X
397-
+ X_Z
398-
399-
julia> setindex!(s, P"ZYX", 1)
400-
+ ZYX
401-
- Z_X
402-
+ X_Z
403-
404-
julia> setindex!(s, (true, true), 1, 1)
405-
+ YYX
406-
- Z_X
407-
+ X_Z
408-
409-
julia> firstindex(s)
410-
1
411-
412-
julia> lastindex(s)
413-
3
414-
415-
julia> lastindex(s, 2)
416-
3
417-
```
418-
419358
There are no automatic checks for correctness (i.e. independence of all rows,
420359
commutativity of all rows, hermiticity of all rows). The rank (number of rows)
421360
is permitted to be less than the number of qubits (number of columns):

0 commit comments

Comments
 (0)