QuantumLegos.jl/dev/index.html
2024-05-07 02:53:05 +00:00

155 lines
35 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Home · QuantumLegos.jl</title><meta name="title" content="Home · QuantumLegos.jl"/><meta property="og:title" content="Home · QuantumLegos.jl"/><meta property="twitter:title" content="Home · QuantumLegos.jl"/><meta name="description" content="Documentation for QuantumLegos.jl."/><meta property="og:description" content="Documentation for QuantumLegos.jl."/><meta property="twitter:description" content="Documentation for QuantumLegos.jl."/><script data-outdated-warner src="assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="assets/documenter.js"></script><script src="search_index.js"></script><script src="siteinfo.js"></script><script src="../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href>QuantumLegos.jl</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li class="is-active"><a class="tocitem" href>Home</a><ul class="internal"><li class="toplevel"><a class="tocitem" href="#Example"><span>Example</span></a></li><li><a class="tocitem" href="#CheckMatrix-and-defining-Lego"><span>CheckMatrix and defining Lego</span></a></li><li><a class="tocitem" href="#Defining-and-Updating-State"><span>Defining and Updating State</span></a></li><li><a class="tocitem" href="#2-Lego-1-edge-state"><span>2 Lego 1 edge state</span></a></li><li class="toplevel"><a class="tocitem" href="#Internal(how-it-works)"><span>Internal(how it works)</span></a></li><li><a class="tocitem" href="#Notes-on-Overall-flow"><span>Notes on Overall flow</span></a></li><li class="toplevel"><a class="tocitem" href="#API"><span>API</span></a></li></ul></li><li><a class="tocitem" href="pauliops/">PauliOps</a></li><li><a class="tocitem" href="checkmatrix/">Details on check matrix operations</a></li><li><a class="tocitem" href="distance/">How to calculate code distance from the state.</a></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li class="is-active"><a href>Home</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Home</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/qwjyh/QuantumLegos.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/qwjyh/QuantumLegos.jl/blob/main/docs/src/index.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="QuantumLegos"><a class="docs-heading-anchor" href="#QuantumLegos">QuantumLegos</a><a id="QuantumLegos-1"></a><a class="docs-heading-anchor-permalink" href="#QuantumLegos" title="Permalink"></a></h1><p>Documentation for QuantumLegos.</p><p>All contents:</p><ul><li><a href="checkmatrix/#Details-on-check-matrix-operations">Details on check matrix operations</a></li><li class="no-marker"><ul><li><a href="checkmatrix/#Basic-features-of-check-matrix">Basic features of check matrix</a></li><li><a href="checkmatrix/#Construction-of-check-matrices-and-retrieving-features">Construction of check matrices and retrieving features</a></li><li><a href="checkmatrix/#Direct-sum">Direct sum</a></li><li><a href="checkmatrix/#Self-tracing">Self-tracing</a></li></ul></li><li><a href="distance/#How-to-calculate-code-distance-from-the-state.">How to calculate code distance from the state.</a></li><li class="no-marker"><ul><li><a href="distance/#Definition-of-code-distance.">Definition of code distance.</a></li><li><a href="distance/#Classification-of-the-stabilizers.">Classification of the stabilizers.</a></li><li><a href="distance/#Calculating-code-distance-from-the-check-matrix.">Calculating code distance from the check matrix.</a></li><li><a href="distance/#Examples">Examples</a></li></ul></li><li><a href="#QuantumLegos">QuantumLegos</a></li><li><a href="#Example">Example</a></li><li class="no-marker"><ul><li><a href="#CheckMatrix-and-defining-Lego">CheckMatrix and defining Lego</a></li><li><a href="#Defining-and-Updating-State">Defining and Updating State</a></li><li><a href="#2-Lego-1-edge-state">2 Lego 1 edge state</a></li></ul></li><li><a href="#Internal(how-it-works)">Internal(how it works)</a></li><li class="no-marker"><ul><li><a href="#Notes-on-Overall-flow">Notes on Overall flow</a></li></ul></li><li><a href="#API">API</a></li><li><a href="pauliops/#PauliOps">PauliOps</a></li><li class="no-marker"><ul><li><a href="pauliops/#Example">Example</a></li><li><a href="pauliops/#API">API</a></li></ul></li></ul><h1 id="Example"><a class="docs-heading-anchor" href="#Example">Example</a><a id="Example-1"></a><a class="docs-heading-anchor-permalink" href="#Example" title="Permalink"></a></h1><h2 id="CheckMatrix-and-defining-Lego"><a class="docs-heading-anchor" href="#CheckMatrix-and-defining-Lego">CheckMatrix and defining Lego</a><a id="CheckMatrix-and-defining-Lego-1"></a><a class="docs-heading-anchor-permalink" href="#CheckMatrix-and-defining-Lego" title="Permalink"></a></h2><pre><code class="language-julia-repl hljs">julia&gt; using QuantumLegos
julia&gt; stabilizers = pauliop.([&quot;IIXXXX&quot;, &quot;IIZZZZ&quot;, &quot;ZIZZII&quot;, &quot;IZZIZI&quot;, &quot;IXXXII&quot;, &quot;XIXIXI&quot;])
6-element Vector{StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}}:
pauliop(&quot;IIXXXX&quot;)
pauliop(&quot;IIZZZZ&quot;)
pauliop(&quot;ZIZZII&quot;)
pauliop(&quot;IZZIZI&quot;)
pauliop(&quot;IXXXII&quot;)
pauliop(&quot;XIXIXI&quot;)
julia&gt; cmat = checkmatrix(stabilizers)
CheckMatrix with 6 generators, 6 legs:
0 0 1 1 1 1 | 0 0 0 0 0 0
0 0 0 0 0 0 | 0 0 1 1 1 1
0 0 0 0 0 0 | 1 0 1 1 0 0
0 0 0 0 0 0 | 0 1 1 0 1 0
0 1 1 1 0 0 | 0 0 0 0 0 0
1 0 1 0 1 0 | 0 0 0 0 0 0
julia&gt; cmat.nlegs
6
julia&gt; cmat.ngens
6
julia&gt; cmat.cmat
6×12 Matrix{Bool}:
0 0 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1
0 0 0 0 0 0 1 0 1 1 0 0
0 0 0 0 0 0 0 1 1 0 1 0
0 1 1 1 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 0 0 0 0
julia&gt; # define lego
julia&gt; lego = Lego(stabilizers)
Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])
julia&gt; lego.stabgens |&gt; checkmatrix
CheckMatrix with 6 generators, 6 legs:
0 0 1 1 1 1 | 0 0 0 0 0 0
0 0 0 0 0 0 | 0 0 1 1 1 1
0 0 0 0 0 0 | 1 0 1 1 0 0
0 0 0 0 0 0 | 0 1 1 0 1 0
0 1 1 1 0 0 | 0 0 0 0 0 0
1 0 1 0 1 0 | 0 0 0 0 0 0
</code></pre><ul><li><a href="pauliops/#QuantumLegos.PauliOps.pauliop-Tuple{AbstractString}"><code>pauliop</code></a></li><li><a href="checkmatrix/#QuantumLegos.checkmatrix"><code>checkmatrix</code></a> and <a href="checkmatrix/#QuantumLegos.CheckMatrix"><code>CheckMatrix</code></a></li><li><a href="#QuantumLegos.Lego"><code>Lego</code></a></li></ul><h2 id="Defining-and-Updating-State"><a class="docs-heading-anchor" href="#Defining-and-Updating-State">Defining and Updating State</a><a id="Defining-and-Updating-State-1"></a><a class="docs-heading-anchor-permalink" href="#Defining-and-Updating-State" title="Permalink"></a></h2><pre><code class="language-julia-repl hljs">julia&gt; using QuantumLegos
julia&gt; stabilizers = pauliop.([&quot;IIXXXX&quot;, &quot;IIZZZZ&quot;, &quot;ZIZZII&quot;, &quot;IZZIZI&quot;, &quot;IXXXII&quot;, &quot;XIXIXI&quot;])
6-element Vector{StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}}:
pauliop(&quot;IIXXXX&quot;)
pauliop(&quot;IIZZZZ&quot;)
pauliop(&quot;ZIZZII&quot;)
pauliop(&quot;IZZIZI&quot;)
pauliop(&quot;IXXXII&quot;)
pauliop(&quot;XIXIXI&quot;)
julia&gt; lego = Lego(stabilizers)
Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])
julia&gt; # state with 1 lego, 0 leg
julia&gt; st = State([lego, ], Tuple{LegoLeg, LegoLeg}[])
State(Lego[Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])], Tuple{LegoLeg, LegoLeg}[], CheckMatrix(Bool[0 0 … 0 0; 0 0 … 1 1; … ; 0 1 … 0 0; 1 0 … 0 0], 6, 6))
julia&gt; st.cmat.cmat
6×12 Matrix{Bool}:
0 0 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1
0 0 0 0 0 0 1 0 1 1 0 0
0 0 0 0 0 0 0 1 1 0 1 0
0 1 1 1 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 0 0 0 0
julia&gt; add_lego!(st, lego)
State(Lego[Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)]), Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])], Tuple{LegoLeg, LegoLeg}[], CheckMatrix(Bool[0 0 … 0 0; 0 0 … 0 0; … ; 0 0 … 0 0; 0 0 … 0 0], 12, 12))
julia&gt; st.cmat.cmat
12×24 Matrix{Bool}:
0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0
0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
julia&gt; # state with 2 legos, 0 leg
julia&gt; st2 = State([lego, lego], Tuple{LegoLeg, LegoLeg}[])
State(Lego[Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)]), Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])], Tuple{LegoLeg, LegoLeg}[], CheckMatrix(Bool[0 0 … 0 0; 0 0 … 0 0; … ; 0 0 … 0 0; 0 0 … 0 0], 12, 12))
julia&gt; st == st2
true</code></pre><h2 id="2-Lego-1-edge-state"><a class="docs-heading-anchor" href="#2-Lego-1-edge-state">2 Lego 1 edge state</a><a id="2-Lego-1-edge-state-1"></a><a class="docs-heading-anchor-permalink" href="#2-Lego-1-edge-state" title="Permalink"></a></h2><pre><code class="language-julia-repl hljs">julia&gt; using QuantumLegos
julia&gt; stabilizers = pauliop.([&quot;IIXXXX&quot;, &quot;IIZZZZ&quot;, &quot;ZIZZII&quot;, &quot;IZZIZI&quot;, &quot;IXXXII&quot;, &quot;XIXIXI&quot;])
6-element Vector{StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}}:
pauliop(&quot;IIXXXX&quot;)
pauliop(&quot;IIZZZZ&quot;)
pauliop(&quot;ZIZZII&quot;)
pauliop(&quot;IZZIZI&quot;)
pauliop(&quot;IXXXII&quot;)
pauliop(&quot;XIXIXI&quot;)
julia&gt; lego = Lego(stabilizers)
Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])
julia&gt; state = State([lego, lego], edge.([((1, 3), (2, 3))]))
State(Lego[Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)]), Lego{6}(6, StaticArraysCore.SVector{6, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;IIXXXX&quot;), pauliop(&quot;IIZZZZ&quot;), pauliop(&quot;ZIZZII&quot;), pauliop(&quot;IZZIZI&quot;), pauliop(&quot;IXXXII&quot;), pauliop(&quot;XIXIXI&quot;)])], Tuple{LegoLeg, LegoLeg}[(LegoLeg(1, 3), LegoLeg(2, 3))], CheckMatrix(Bool[1 0 … 0 0; 0 1 … 0 0; … ; 0 0 … 1 1; 0 0 … 0 1], 10, 10))
julia&gt; state.cmat
CheckMatrix with 10 generators, 10 legs:
1 0 1 0 1 0 0 0 0 0 | 0 0 0 0 0 0 0 0 0 0
0 1 0 1 1 0 0 0 0 0 | 0 0 0 0 0 0 0 0 0 0
0 0 1 1 1 0 0 1 1 1 | 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 1 0 1 | 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 1 1 | 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 | 1 0 0 1 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 | 0 1 1 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 | 0 0 1 1 1 0 0 1 1 1
0 0 0 0 0 0 0 0 0 0 | 0 0 0 0 0 1 0 0 1 1
0 0 0 0 0 0 0 0 0 0 | 0 0 0 0 0 0 1 1 0 1
julia&gt; pg = state.cmat |&gt; generators |&gt; GeneratedPauliGroup
GeneratedPauliGroup{10}(StaticArraysCore.SVector{10, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;XIXIXIIIII&quot;), pauliop(&quot;IXIXXIIIII&quot;), pauliop(&quot;IIXXXIIXXX&quot;), pauliop(&quot;IIIIIXIXIX&quot;), pauliop(&quot;IIIIIIXIXX&quot;), pauliop(&quot;ZIIZZIIIII&quot;), pauliop(&quot;IZZIZIIIII&quot;), pauliop(&quot;IIZZZIIZZZ&quot;), pauliop(&quot;IIIIIZIIZZ&quot;), pauliop(&quot;IIIIIIZZIZ&quot;)], IterTools.Subsets{Vector{StaticArraysCore.SVector{N, QuantumLegos.PauliOps.SinglePauliOp} where N}}(StaticArraysCore.SVector{N, QuantumLegos.PauliOps.SinglePauliOp} where N[pauliop(&quot;XIXIXIIIII&quot;), pauliop(&quot;IXIXXIIIII&quot;), pauliop(&quot;IIXXXIIXXX&quot;), pauliop(&quot;IIIIIXIXIX&quot;), pauliop(&quot;IIIIIIXIXX&quot;), pauliop(&quot;ZIIZZIIIII&quot;), pauliop(&quot;IZZIZIIIII&quot;), pauliop(&quot;IIZZZIIZZZ&quot;), pauliop(&quot;IIIIIZIIZZ&quot;), pauliop(&quot;IIIIIIZZIZ&quot;)]))
julia&gt; pauliop(&quot;XIIXIXIIXI&quot;) in pg
true
</code></pre><h1 id="Internal(how-it-works)"><a class="docs-heading-anchor" href="#Internal(how-it-works)">Internal(how it works)</a><a id="Internal(how-it-works)-1"></a><a class="docs-heading-anchor-permalink" href="#Internal(how-it-works)" title="Permalink"></a></h1><h2 id="Notes-on-Overall-flow"><a class="docs-heading-anchor" href="#Notes-on-Overall-flow">Notes on Overall flow</a><a id="Notes-on-Overall-flow-1"></a><a class="docs-heading-anchor-permalink" href="#Notes-on-Overall-flow" title="Permalink"></a></h2><p>Details on <sup class="footnote-reference"><a id="citeref-1" href="#footnote-1">[1]</a></sup></p><ul><li>state is translated to a single check matrix<ul><li>the size is ≤ <span>$N \times 2N$</span> where <span>$N$</span> is maximum number of lego logs.</li></ul></li><li>any contraction can be performed on this single check matrix</li><li>if the check matrix can be represented as direct sum of matrices with <span>$k N$</span> columns where <span>$k ∈ $</span>, then they are not contracted</li></ul><h3 id="Construction-of-State"><a class="docs-heading-anchor" href="#Construction-of-State">Construction of State</a><a id="Construction-of-State-1"></a><a class="docs-heading-anchor-permalink" href="#Construction-of-State" title="Permalink"></a></h3><p>Construction of <code>State</code> is completed by calling <code>State</code> constructor recursively.</p><ol><li>Construct <code>State</code> without edge. Just adding legos. Checkmatrix is just a direct sum of each lego&#39;s checkmatrix</li><li>Concatenate each edges. During this operation, self tracing of checkmatrix is evaluated.</li></ol><p>Each constructor calls action function (which is a map from <code>State</code> to <code>State</code>). Therefore, action functions can be used both for direct construction of <code>State</code> and action application to <code>State</code> during the game.</p><h1 id="API"><a class="docs-heading-anchor" href="#API">API</a><a id="API-1"></a><a class="docs-heading-anchor-permalink" href="#API" title="Permalink"></a></h1><ul><li><a href="pauliops/#QuantumLegos.PauliOps"><code>QuantumLegos.PauliOps</code></a></li><li><a href="checkmatrix/#QuantumLegos.CheckMatrix"><code>QuantumLegos.CheckMatrix</code></a></li><li><a href="#QuantumLegos.Lego"><code>QuantumLegos.Lego</code></a></li><li><a href="#QuantumLegos.LegoLeg"><code>QuantumLegos.LegoLeg</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.GeneratedPauliGroup"><code>QuantumLegos.PauliOps.GeneratedPauliGroup</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.PauliOp"><code>QuantumLegos.PauliOps.PauliOp</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.SinglePauliOp"><code>QuantumLegos.PauliOps.SinglePauliOp</code></a></li><li><a href="#QuantumLegos.State"><code>QuantumLegos.State</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.pauliop-Tuple{AbstractString}"><code>QuantumLegos.PauliOps.pauliop</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.single_pauliop-Tuple{Char}"><code>QuantumLegos.PauliOps.single_pauliop</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.weight"><code>QuantumLegos.PauliOps.weight</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.xweight"><code>QuantumLegos.PauliOps.xweight</code></a></li><li><a href="pauliops/#QuantumLegos.PauliOps.zweight"><code>QuantumLegos.PauliOps.zweight</code></a></li><li><a href="#QuantumLegos._naive_distance-Tuple{State}"><code>QuantumLegos._naive_distance</code></a></li><li><a href="#QuantumLegos.add_edge!-Tuple{State, LegoLeg, LegoLeg}"><code>QuantumLegos.add_edge!</code></a></li><li><a href="#QuantumLegos.add_lego!-Tuple{State, Lego}"><code>QuantumLegos.add_lego!</code></a></li><li><a href="checkmatrix/#QuantumLegos.align_row!"><code>QuantumLegos.align_row!</code></a></li><li><a href="checkmatrix/#QuantumLegos.checkmatrix"><code>QuantumLegos.checkmatrix</code></a></li><li><a href="#QuantumLegos.cmat_index-Tuple{State, LegoLeg}"><code>QuantumLegos.cmat_index</code></a></li><li><a href="checkmatrix/#QuantumLegos.direct_sum"><code>QuantumLegos.direct_sum</code></a></li><li><a href="#QuantumLegos.distance-Tuple{State}"><code>QuantumLegos.distance</code></a></li><li><a href="#QuantumLegos.edge-Union{Tuple{T}, NTuple{4, T}} where T&lt;:Integer"><code>QuantumLegos.edge</code></a></li><li><a href="#QuantumLegos.edge-Union{Tuple{Tuple{T, T}}, Tuple{T}} where T&lt;:Tuple{Integer, Integer}"><code>QuantumLegos.edge</code></a></li><li><a href="#QuantumLegos.edge-Union{Tuple{NTuple{4, T}}, Tuple{T}} where T&lt;:Integer"><code>QuantumLegos.edge</code></a></li><li><a href="#QuantumLegos.edge"><code>QuantumLegos.edge</code></a></li><li><a href="checkmatrix/#QuantumLegos.eliminate_column!"><code>QuantumLegos.eliminate_column!</code></a></li><li><a href="checkmatrix/#QuantumLegos.eliminate_dependent_row!"><code>QuantumLegos.eliminate_dependent_row!</code></a></li><li><a href="checkmatrix/#QuantumLegos.generators"><code>QuantumLegos.generators</code></a></li><li><a href="#QuantumLegos.is_connected_to_firstlego-Tuple{State}"><code>QuantumLegos.is_connected_to_firstlego</code></a></li><li><a href="checkmatrix/#QuantumLegos.ref!"><code>QuantumLegos.ref!</code></a></li><li><a href="checkmatrix/#QuantumLegos.self_trace!"><code>QuantumLegos.self_trace!</code></a></li><li><a href="checkmatrix/#QuantumLegos.xpart"><code>QuantumLegos.xpart</code></a></li><li><a href="checkmatrix/#QuantumLegos.zpart"><code>QuantumLegos.zpart</code></a></li></ul><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.Lego" href="#QuantumLegos.Lego"><code>QuantumLegos.Lego</code></a><span class="docstring-category">Type</span></header><section><div><p>Quantum lego with <code>N</code> legs.</p><p><strong>Fields</strong></p><ul><li><code>nlegs::Int64</code>: number of legs, equals <code>N</code></li><li><code>stabgens::SVector{N, PauliOp{N}}</code>: stabilizer generators. vector of <a href="pauliops/#QuantumLegos.PauliOps.PauliOp"><code>PauliOp</code></a></li></ul><p><strong>Constructor</strong></p><pre><code class="nohighlight hljs">Lego([nlegs::Integer], stabgens::AbstractVector{PauliOp{N}})</code></pre><p>Constructor for <a href="#QuantumLegos.Lego"><code>Lego</code></a>. <code>nlegs</code> is optional (default is length of the first stabilizer generator).</p><p><strong>Example</strong></p><pre><code class="language-julia-repl hljs">julia&gt; stabgens = pauliop.([&quot;II&quot;, &quot;XX&quot;])
2-element Vector{StaticArraysCore.SVector{2, QuantumLegos.PauliOps.SinglePauliOp}}:
pauliop(&quot;II&quot;)
pauliop(&quot;XX&quot;)
julia&gt; Lego(stabgens)
Lego{2}(2, StaticArraysCore.SVector{2, QuantumLegos.PauliOps.SinglePauliOp}[pauliop(&quot;II&quot;), pauliop(&quot;XX&quot;)])</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L8-L31">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.LegoLeg" href="#QuantumLegos.LegoLeg"><code>QuantumLegos.LegoLeg</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">mutable struct State</code></pre><p>To be used in <a href="#QuantumLegos.State"><code>State</code></a>.</p><p><strong>Fields</strong></p><ul><li><code>lego_id::Int64</code>: index in <code>legos</code> in <code>State</code></li><li><code>edge_id::Int64</code>: index in <code>Lego</code> in <code>legos</code> in <code>State</code>. No validation check included in <code>LegoLeg</code>.</li></ul><p><strong>Example</strong></p><pre><code class="language-julia-repl hljs">julia&gt; x = LegoLeg.([(2, 1), (1, 1), (1, 0)])
3-element Vector{LegoLeg}:
LegoLeg(2, 1)
LegoLeg(1, 1)
LegoLeg(1, 0)
julia&gt; sort(x)
3-element Vector{LegoLeg}:
LegoLeg(1, 0)
LegoLeg(1, 1)
LegoLeg(2, 1)</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L50-L73">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.State" href="#QuantumLegos.State"><code>QuantumLegos.State</code></a><span class="docstring-category">Type</span></header><section><div><pre><code class="language-julia hljs">mutable struct State</code></pre><p>State (in p.4)</p><p><strong>Fields</strong></p><ul><li><code>legos</code>: <code>Vector{Lego}</code></li><li><code>edges</code>: Vector of ((<code>lego_i, leg_n</code>), (<code>lego_j, leg_m</code>)). Each element is sorted (i.e. <code>lego_i &lt; lego_j</code> or <code>lego_i == lego_j &amp;&amp; leg_n &lt; leg_m</code>). This feature is used in <a href="#QuantumLegos.is_connected_to_firstlego-Tuple{State}"><code>is_connected_to_firstlego</code></a>.</li><li><code>cmat::CheckMatrix</code>: CheckMatrix</li></ul><p><strong>Constructor</strong></p><pre><code class="nohighlight hljs">State(legos::Vector{Lego{N}}, edges::Vector{Tuple{LegoLeg, LegoLeg}})</code></pre><p><strong>Methods with</strong></p><ul><li><a href="#QuantumLegos.add_lego!-Tuple{State, Lego}"><code>add_lego!</code></a></li><li><a href="#QuantumLegos.add_edge!-Tuple{State, LegoLeg, LegoLeg}"><code>add_edge!</code></a></li></ul><p><strong>Example</strong></p><p>TODO</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L115-L136">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos._naive_distance-Tuple{State}" href="#QuantumLegos._naive_distance-Tuple{State}"><code>QuantumLegos._naive_distance</code></a><span class="docstring-category">Method</span></header><section><div><p>Calculate distance. Use minimum distance of all generated normalizers.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L261-L264">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.add_edge!-Tuple{State, LegoLeg, LegoLeg}" href="#QuantumLegos.add_edge!-Tuple{State, LegoLeg, LegoLeg}"><code>QuantumLegos.add_edge!</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">add_edge!(state::State, leg_1::LegoLeg, leg_2::LegoLeg)::State</code></pre><p>Add a new edge between <code>leg_1</code> and <code>leg_2</code>, updating <code>state</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L209-L213">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.add_lego!-Tuple{State, Lego}" href="#QuantumLegos.add_lego!-Tuple{State, Lego}"><code>QuantumLegos.add_lego!</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">add_lego!(state::State, lego::Lego) -&gt; State</code></pre><p>Add a new lego, updating <code>state</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L171-L175">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.cmat_index-Tuple{State, LegoLeg}" href="#QuantumLegos.cmat_index-Tuple{State, LegoLeg}"><code>QuantumLegos.cmat_index</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">cmat_index(state::State, leg::LegoLeg)::Int64</code></pre><p>Get column index corresponds to <code>leg</code> in check matrix of <code>state</code>. If given <code>leg</code> is already connected, it throws <code>ArgumentError</code>. If given <code>lego_id</code> of <code>leg</code> is out of <code>state.legos</code>, throws <code>ArgumentError</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L183-L189">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.distance-Tuple{State}" href="#QuantumLegos.distance-Tuple{State}"><code>QuantumLegos.distance</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">distance(state::State) -&gt; Int</code></pre><p>Calculate code distance when the first leg of <code>state</code> is assigned as logical.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L253-L257">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.edge" href="#QuantumLegos.edge"><code>QuantumLegos.edge</code></a><span class="docstring-category">Function</span></header><section><div><p>Helper function to create <code>Tuple{LegoLeg, LegoLeg}</code> to represent edge.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L81-L83">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.edge-Union{Tuple{NTuple{4, T}}, Tuple{T}} where T&lt;:Integer" href="#QuantumLegos.edge-Union{Tuple{NTuple{4, T}}, Tuple{T}} where T&lt;:Integer"><code>QuantumLegos.edge</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">edge(t::Tuple{T, T, T, T}) where {T &lt;: Integer}</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L93-L95">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.edge-Union{Tuple{Tuple{T, T}}, Tuple{T}} where T&lt;:Tuple{Integer, Integer}" href="#QuantumLegos.edge-Union{Tuple{Tuple{T, T}}, Tuple{T}} where T&lt;:Tuple{Integer, Integer}"><code>QuantumLegos.edge</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">edge(t::Tuple{T, T}) where {T &lt;: Tuple{Integer, Integer}}</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L86-L88">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.edge-Union{Tuple{T}, NTuple{4, T}} where T&lt;:Integer" href="#QuantumLegos.edge-Union{Tuple{T}, NTuple{4, T}} where T&lt;:Integer"><code>QuantumLegos.edge</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">edge(x::T, y::T, z::T, w::T) where {T &lt;: Integer}</code></pre></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L100-L102">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="QuantumLegos.is_connected_to_firstlego-Tuple{State}" href="#QuantumLegos.is_connected_to_firstlego-Tuple{State}"><code>QuantumLegos.is_connected_to_firstlego</code></a><span class="docstring-category">Method</span></header><section><div><pre><code class="language-julia hljs">is_connected_to_firstlego(state::State)::BitVector</code></pre><p>Returns vector which stores whether each lego is connected to the first lego.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/qwjyh/QuantumLegos.jl/blob/fda016f02dad2c2600c16e88335a3733b9e1c284/src/game.jl#L228-L232">source</a></section></article><section class="footnotes is-size-7"><ul><li class="footnote" id="footnote-1"><a class="tag is-link" href="#citeref-1">1</a><a href="https://doi.org/10.1007/JHEP05(2021)127">C. Cao and B. Lackey, Approximate Bacon-Shor code and holography, J. High Energ. Phys., vol. 2021, no. 5, p. 127, May 2021, doi: 10.1007/JHEP05(2021)127.</a></li></ul></section></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="pauliops/">PauliOps »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <span class="colophon-date" title="Tuesday 7 May 2024 02:53">Tuesday 7 May 2024</span>. Using Julia version 1.10.3.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html>