<htmllang="en"><head><metacharset="UTF-8"/><metaname="viewport"content="width=device-width, initial-scale=1.0"/><title>Details on check matrix operations · QuantumLegos.jl</title><metaname="title"content="Details on check matrix operations · QuantumLegos.jl"/><metaproperty="og:title"content="Details on check matrix operations · QuantumLegos.jl"/><metaproperty="twitter:title"content="Details on check matrix operations · QuantumLegos.jl"/><metaname="description"content="Documentation for QuantumLegos.jl."/><metaproperty="og:description"content="Documentation for QuantumLegos.jl."/><metaproperty="twitter:description"content="Documentation for QuantumLegos.jl."/><scriptdata-outdated-warnersrc="../assets/warner.js"></script><linkhref="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css"rel="stylesheet"type="text/css"/><linkhref="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css"rel="stylesheet"type="text/css"/><script>documenterBaseURL=".."</script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"data-main="../assets/documenter.js"></script><scriptsrc="../search_index.js"></script><scriptsrc="../siteinfo.js"></script><scriptsrc="../../versions.js"></script><linkclass="docs-theme-link"rel="stylesheet"type="text/css"href="../assets/themes/documenter-dark.css"data-theme-name="documenter-dark"data-theme-primary-dark/><linkclass="docs-theme-link"rel="stylesheet"type="text/css"href="../assets/themes/documenter-light.css"data-theme-name="documenter-light"data-theme-primary/><scriptsrc="../assets/themeswap.js"></script></head><body><divid="documenter"><navclass="docs-sidebar"><divclass="docs-package-name"><spanclass="docs-autofit"><ahref="../">QuantumLegos.jl</a></span></div><buttonclass="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><ulclass="docs-menu"><li><aclass="tocitem"href="../">Home</a></li><li><aclass="tocitem"href="../pauliops/">PauliOps</a></li><liclass="is-active"><aclass="tocitem"href>Details on check matrix operations</a><ulclass="internal"><li><aclass="tocitem"href="#Basic-features-of-check-matrix"><span>Basic features of check matrix</span></a></li><li><aclass="tocitem"href="#Construction-of-check-matrices-and-retrieving-features"><span>Construction of check matrices and retrieving features</span></a></li><li><aclass="tocitem"href="#Direct-sum"><span>Direct sum</span></a></li><li><aclass="tocitem"href="#Self-tracing"><span>Self-tracing</span></a></li></ul></li><li><aclass="tocitem"href="../distance/">How to calculate code distance from the state.</a></li></ul><divclass="docs-version-selector field has-addons"><divclass="control"><spanclass="docs-label button is-static is-size-7">Version</span></div><divclass="docs-selector control is-expanded"><divclass="select is-fullwidth is-size-7"><selectid="documenter-version-selector"></select></div></div></div></nav><divclass="docs-main"><headerclass="docs-navbar"><aclass="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop"id="documenter-sidebar-button"href="#"></a><navclass="breadcrumb"><ulclass="is-hidden-mobile"><liclass="is-active"><ahref>Details on check matrix operations</a></li></ul><ulclass="is-hidden-tablet"><liclass="is-active"><ahref>Details on check matrix operations</a></li></ul></nav><divclass="docs-right"><aclass="docs-navbar-link"href="https://github.com/qwjyh/QuantumLegos.jl"title="Viewtherepo
\end{pmatrix}\]</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L151-L165">source</a></section></article><h2id="Self-tracing"><aclass="docs-heading-anchor"href="#Self-tracing">Self-tracing</a><aid="Self-tracing-1"></a><aclass="docs-heading-anchor-permalink"href="#Self-tracing"title="Permalink"></a></h2><h3id="self-tracing"><aclass="docs-heading-anchor"href="#self-tracing">self-tracing</a><aid="self-tracing-1"></a><aclass="docs-heading-anchor-permalink"href="#self-tracing"title="Permalink"></a></h3><articleclass="docstring"><header><aclass="docstring-article-toggle-button fa-solid fa-chevron-down"href="javascript:;"title="Collapse docstring"></a><aclass="docstring-binding"id="QuantumLegos.self_trace!"href="#QuantumLegos.self_trace!"><code>QuantumLegos.self_trace!</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia hljs">self_trace!(cmat::CheckMatrix, col_1::Integer, col_2::Integer)</code></pre><p>Take a self-trace of checkmatrix <code>cmat</code> with column <code>col_1</code> and <code>col_2</code>.</p><p><strong>Example</strong></p><p>TODO</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L424-L431">source</a></section></article><p>During self-tracing, pre-formatting and post-formatting described below is performed.</p><h3id="pre-formatting"><aclass="docs-heading-anchor"href="#pre-formatting">pre-formatting</a><aid="pre-formatting-1"></a><aclass="docs-heading-anchor-permalink"href="#pre-formatting"title="Permalink"></a></h3><articleclass="docstring"><header><aclass="docstring-article-toggle-button fa-solid fa-chevron-down"href="javascript:;"title="Collapse docstring"></a><aclass="docstring-binding"id="QuantumLegos.eliminate_column!"href="#QuantumLegos.eliminate_column!"><code>QuantumLegos.eliminate_column!</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia hljs">eliminate_column!(
)::Union{Nothing, Int64} where {T <: Integer}</code></pre><p>Perform Gauss Elimination on <code>col</code>. Keep only one <code>1</code> on <code>col</code> and remove from other rows by performing multiplication. Choose row not in <code>avoid_row</code>. If all rows with 1 on <code>col</code> are in <code>avoid_row</code>, then the last row of them is chose to keep 1. If all rows on <code>col</code> is 0, return nothing.</p><p><strong>Return</strong></p><p>Row index which have 1 on <code>col</code>. If all row on <code>col</code> is 0, return nothing.</p><p><strong>Example</strong></p><pre><codeclass="language-julia-repl hljs">julia> ex_cmat = CheckMatrix(Bool[1 0 1 0; 1 1 1 1])
avoid_row::AbstractVector{T}) where {T <: Union{Nothing, Integer}}</code></pre><p><code>avoid_row</code> can include <code>Nothing</code>, which is ignored in actual evaluation.</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L246-L251">source</a></section></article><articleclass="docstring"><header><aclass="docstring-article-toggle-button fa-solid fa-chevron-down"href="javascript:;"title="Collapse docstring"></a><aclass="docstring-binding"id="QuantumLegos.align_row!"href="#QuantumLegos.align_row!"><code>QuantumLegos.align_row!</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia hljs">align_row!(m::AbstractMatrix, row::Integer, occupied::Vector{Union{Nothing, Integer}}) -> Integer
align_row!(m::AbstractMatrix, row::Nothing, occupied::Vector{Union{Nothing, Integer}}) -> Nothing</code></pre><p>Swap row at <code>row</code> in <code>m</code> and row at next to the maximum in <code>occupied</code>. <code>occupied</code> is supposed to be a list of returns from <ahref="#QuantumLegos.eliminate_column!"><code>eliminate_column!</code></a>. If <code>row</code> is in <code>occupied</code>, do nothing and returns <code>row</code>. If <code>row</code> is <code>nothing</code>, return <code>nothing</code>.</p><p><strong>Arguments</strong></p><ul><li><code>m::AbstractMatrix</code>: mutated</li><li><code>row::Union{Nothing, Integer}</code>: row to be aligned</li><li><code>occupied::Vector{Union{Nothing, Integer}}</code>: indices of already occupied rows. <code>row</code> will be next to these rows.</li></ul><p><strong>Return</strong></p><ul><li>Row index where <code>row</code> is moved.</li></ul></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L265-L281">source</a></section></article><p><ahref="#QuantumLegos.align_row!"><code>QuantumLegos.align_row!</code></a></p><p>By this process, all columns to be traced have <code>1</code>s on only 1st to 4th rows. So during <ahref="#QuantumLegos.self_trace!"><code>QuantumLegos.self_trace!</code></a>, all stabilizers generated from top three rows are calculated and perform operator matching.</p><h3id="post-formatting"><aclass="docs-heading-anchor"href="#post-formatting">post-formatting</a><aid="post-formatting-1"></a><aclass="docs-heading-anchor-permalink"href="#post-formatting"title="Permalink"></a></h3><p>Remove rows which are linear combinations of other rows.</p><articleclass="docstring"><header><aclass="docstring-article-toggle-button fa-solid fa-chevron-down"href="javascript:;"title="Collapse docstring"></a><aclass="docstring-binding"id="QuantumLegos.ref!"href="#QuantumLegos.ref!"><code>QuantumLegos.ref!</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia hljs">ref!(cmat::CheckMatrix) -> Int</code></pre><p>Convert <code>cmat</code> to row echelon form.</p><p>Returns rank of check matrix.</p><p><strong>Examples</strong></p><pre><codeclass="language-julia-repl hljs">julia> cmat = CheckMatrix(Bool[
</code></pre></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L319-L352">source</a></section></article><articleclass="docstring"><header><aclass="docstring-article-toggle-button fa-solid fa-chevron-down"href="javascript:;"title="Collapse docstring"></a><aclass="docstring-binding"id="QuantumLegos.eliminate_dependent_row!"href="#QuantumLegos.eliminate_dependent_row!"><code>QuantumLegos.eliminate_dependent_row!</code></a> — <spanclass="docstring-category">Function</span></header><section><div><pre><codeclass="language-julia hljs">eliminate_dependent_row!(cmat::CheckMatrix) -> CheckMatrix</code></pre><p>Remove dependent rows to keep only independent generators.</p></div><aclass="docs-sourcelink"target="_blank"href="https://github.com/qwjyh/QuantumLegos.jl/blob/f60e0cc4b885816a38722094dca59652e350b613/src/checkmatrix.jl#L407-L411">source</a></section></article></article><navclass="docs-footer"><aclass="docs-footer-prevpage"href="../pauliops/">« PauliOps</a><aclass="docs-footer-nextpage"href="../distance/">How to calculate code distance from the state. »</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal"id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="auto">Automatic (OS)</option><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.4.1 on <spanclass="colophon-date"title="Tuesday 7 May 2024 07:29">Tuesday 7 May 2024</span>. Using Julia version 1.10.3.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>