├── .gitattributes ├── .github └── workflows │ ├── Tests.yml │ ├── doc-preview-cleanup.yml │ └── documentation.yml ├── .gitignore ├── LICENSE ├── Project.toml ├── README.md ├── benchmarks ├── iterators_bench.jl └── weight_dist_bench.jl ├── data ├── A1_X_stabs.csv ├── color_codes │ ├── 488d11stabslogs_trellis.jld2 │ ├── 488d13stabslogs_trellis.jld2 │ ├── 488d15stabslogs_trellis.jld2 │ ├── 488d17stabslogs_trellis.jld2 │ ├── 488d19stabslogs_trellis.jld2 │ ├── 488d3stabslogs_trellis.jld2 │ ├── 488d5stabslogs_trellis.jld2 │ ├── 488d7stabslogs_trellis.jld2 │ ├── 488d9stabslogs_trellis.jld2 │ ├── 666d11stabslogs_trellis.jld2 │ ├── 666d13stabslogs_trellis.jld2 │ ├── 666d15stabslogs_trellis.jld2 │ ├── 666d17stabslogs_trellis.jld2 │ ├── 666d19stabslogs_trellis.jld2 │ ├── 666d21stabslogs_trellis.jld2 │ ├── 666d3stabslogs_trellis.jld2 │ ├── 666d5stabslogs_trellis.jld2 │ ├── 666d7stabslogs_trellis.jld2 │ └── 666d9stabslogs_trellis.jld2 ├── surface3D │ ├── surface3D_3_hx.alist │ ├── surface3D_3_lx.alist │ ├── surface3D_3_mx.alist │ ├── surface3D_4_hx.alist │ ├── surface3D_4_lx.alist │ ├── surface3D_4_mx.alist │ ├── surface3D_5_hx.alist │ ├── surface3D_5_lx.alist │ ├── surface3D_5_mx.alist │ ├── surface3D_6_hx.alist │ ├── surface3D_6_lx.alist │ ├── surface3D_6_mx.alist │ ├── surface3D_7_hx.alist │ ├── surface3D_7_lx.alist │ ├── surface3D_7_mx.alist │ ├── surface3D_8_hx.alist │ ├── surface3D_8_lx.alist │ ├── surface3D_8_mx.alist │ ├── surface3D_9_hx.alist │ ├── surface3D_9_lx.alist │ └── surface3D_9_mx.alist └── toric3D │ ├── toric3D_10_hx.alist │ ├── toric3D_10_lmx.alist │ ├── toric3D_10_lx.alist │ ├── toric3D_10_mx.alist │ ├── toric3D_10_mxlmx.alist │ ├── toric3D_11_hx.alist │ ├── toric3D_11_lmx.alist │ ├── toric3D_11_lx.alist │ ├── toric3D_11_mx.alist │ ├── toric3D_11_mxlmx.alist │ ├── toric3D_12_hx.alist │ ├── toric3D_12_lmx.alist │ ├── toric3D_12_lx.alist │ ├── toric3D_12_mx.alist │ ├── toric3D_12_mxlmx.alist │ ├── toric3D_13_hx.alist │ ├── toric3D_13_lmx.alist │ ├── toric3D_13_lx.alist │ ├── toric3D_13_mx.alist │ ├── toric3D_13_mxlmx.alist │ ├── toric3D_2_hx.alist │ ├── toric3D_2_lmx.alist │ ├── toric3D_2_lx.alist │ ├── toric3D_2_mx.alist │ ├── toric3D_2_mxlmx.alist │ ├── toric3D_3_hx.alist │ ├── toric3D_3_lmx.alist │ ├── toric3D_3_lx.alist │ ├── toric3D_3_mx.alist │ ├── toric3D_3_mxlmx.alist │ ├── toric3D_4_hx.alist │ ├── toric3D_4_lmx.alist │ ├── toric3D_4_lx.alist │ ├── toric3D_4_mx.alist │ ├── toric3D_4_mxlmx.alist │ ├── toric3D_5_hx.alist │ ├── toric3D_5_lmx.alist │ ├── toric3D_5_lx.alist │ ├── toric3D_5_mx.alist │ ├── toric3D_5_mxlmx.alist │ ├── toric3D_6_hx.alist │ ├── toric3D_6_lmx.alist │ ├── toric3D_6_lx.alist │ ├── toric3D_6_mx.alist │ ├── toric3D_6_mxlmx.alist │ ├── toric3D_7_hx.alist │ ├── toric3D_7_lmx.alist │ ├── toric3D_7_lx.alist │ ├── toric3D_7_mx.alist │ ├── toric3D_7_mxlmx.alist │ ├── toric3D_8_hx.alist │ ├── toric3D_8_lmx.alist │ ├── toric3D_8_lx.alist │ ├── toric3D_8_mx.alist │ ├── toric3D_8_mxlmx.alist │ ├── toric3D_9_hx.alist │ ├── toric3D_9_lmx.alist │ ├── toric3D_9_lx.alist │ ├── toric3D_9_mx.alist │ └── toric3D_9_mxlmx.alist ├── docs ├── Manifest.toml ├── Project.toml ├── make.jl └── src │ ├── Classical │ ├── GeneralizedReedSolomon.md │ ├── ReedMuller.md │ ├── concatenation.md │ ├── cyclic_code.md │ ├── linear_code.md │ ├── misc_known_codes.md │ ├── new_codes_from_old.md │ ├── product_codes.md │ └── quasi-cyclic_code.md │ ├── Examples │ ├── Quantum Reed-Muller Codes.md │ └── The Vardy-Be’ery Decomposition.md │ ├── LDPC │ ├── Tanner_codes.md │ ├── analysis.md │ ├── channels.md │ ├── codes.md │ └── decoders.md │ ├── Quantum │ ├── misc_known_codes.md │ ├── product_codes.md │ ├── quantum_code.md │ └── weight_reduction.md │ ├── Tutorials │ ├── Cyclic Codes.md │ ├── Linear Codes.md │ ├── Message Passing.md │ ├── Quantum Codes.md │ ├── Weight Reduction.md │ ├── message_passing_tests.jl │ └── min_dist.md │ ├── assets │ └── logo.png │ ├── index.md │ ├── references.bib │ ├── references.md │ ├── theindex.md │ ├── tilings.md │ ├── trellis.md │ ├── utils.md │ └── weight_dist.md ├── ext ├── JLD2Ext │ ├── JLD2Ext.jl │ └── Quantum │ │ └── misc_known_codes.jl ├── JuMPExt │ ├── JuMPExt.jl │ └── LDPC │ │ ├── analysis.jl │ │ └── decoders.jl └── MakieExt │ ├── Classical │ ├── Tanner.jl │ └── weight_dist.jl │ ├── LDPC │ ├── analysis.jl │ ├── codes.jl │ └── cycles.jl │ ├── MakieExt.jl │ └── Quantum │ └── weight_dist.jl ├── src ├── Classical │ ├── GRS_alternate.jl │ ├── Gabidulin.jl │ ├── Goppa.jl │ ├── MatrixProductCode.jl │ ├── McEliece.jl │ ├── ReedMuller.jl │ ├── Tanner.jl │ ├── TwistedReedSolomon.jl │ ├── concatenation.jl │ ├── cyclic_code.jl │ ├── cyclotomic.jl │ ├── linear_code.jl │ ├── misc_known_codes.jl │ ├── new_codes_from_old.jl │ ├── quasi-cyclic_code.jl │ ├── types.jl │ ├── weight_dist.jl │ └── weight_reduction.jl ├── CodingTheory.jl ├── Convolutional │ ├── convolutional_code.jl │ └── types.jl ├── LDPC │ ├── GBP.jl │ ├── LP_decoders.jl │ ├── MP_decoders.jl │ ├── algorithms.jl │ ├── analysis.jl │ ├── channels.jl │ ├── codes.jl │ ├── cycles.jl │ ├── decoders.jl │ ├── simulations.jl │ └── types.jl ├── Quantum │ ├── decoders │ │ └── OTF.jl │ ├── graph_state.jl │ ├── homological_measurements.jl │ ├── misc_known_codes.jl │ ├── product_codes.jl │ ├── simulation.jl │ ├── stabilizer_code.jl │ ├── subsystem_code.jl │ ├── types.jl │ ├── weight_dist.jl │ └── weight_reduction.jl ├── chain_complex.jl ├── iterators.jl ├── tilings.jl ├── trellis.jl └── utils.jl └── test ├── Classical ├── GRS_alternate_test.jl ├── Goppa_test.jl ├── ReedMuller_test.jl ├── TwistedReedSolomon_test.jl ├── concatenation_test.jl ├── cyclic_code_test.jl ├── cyclotomic_test.jl ├── linear_code_test.jl ├── misc_known_codes_test.jl ├── quasi-cyclic_code_test.jl └── tilings_Tanner_test.jl ├── LDPC ├── GBP_test.jl ├── MP_decoders_test.jl └── codes_test.jl ├── Project.toml ├── QC.txt ├── QR.txt ├── QS.txt ├── QX.txt ├── Quantum ├── decoders │ └── OFT_test.jl ├── homological_measurements_test.jl ├── misc_known_codes_test.jl ├── misc_lit_codes_test.jl ├── product_codes_test.jl ├── quantum_MC_ids_test.jl ├── stabilizer_code_test.jl └── subsystem_code_test.jl ├── chain_complex_test.jl ├── iterators_test.jl ├── runtests.jl ├── testcases.jl └── utils_test.jl /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/Tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | permissions: 4 | actions: write 5 | contents: read 6 | 7 | on: 8 | push: 9 | branches: 10 | - master 11 | tags: '*' 12 | pull_request: 13 | 14 | concurrency: 15 | # Skip intermediate builds: always. 16 | # Cancel intermediate builds: only if it is a pull request build. 17 | group: ${{ github.workflow }}-${{ github.ref }} 18 | cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} 19 | 20 | jobs: 21 | test: 22 | name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} 23 | runs-on: ${{ matrix.os }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | version: 28 | - '1.11' 29 | os: 30 | - ubuntu-latest 31 | arch: 32 | - x64 33 | steps: 34 | # This is from the GLMakie github action 35 | # - run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils 36 | - uses: actions/checkout@v3 37 | - uses: awalsh128/cache-apt-pkgs-action@latest 38 | with: 39 | packages: xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils 40 | - uses: julia-actions/setup-julia@latest 41 | with: 42 | version: ${{ matrix.version }} 43 | arch: ${{ matrix.arch }} 44 | - uses: julia-actions/cache@v1 45 | with: 46 | # cache-name: master-tests 47 | # WARNING: cache-registries is actually slower for Windows runners 48 | cache-registries: "true" 49 | # WARNING: cache-compiled can break with certain choices of OS and architecture. 50 | # see https://github.com/julia-actions/cache/issues/11 51 | cache-compiled: "true" 52 | - uses: julia-actions/julia-buildpkg@latest 53 | - uses: julia-actions/julia-runtest@latest 54 | env: 55 | DISPLAY: :0 56 | with: 57 | prefix: xvfb-run 58 | - uses: julia-actions/julia-processcoverage@latest 59 | - uses: codecov/codecov-action@v3 60 | with: 61 | files: lcov.info 62 | -------------------------------------------------------------------------------- /.github/workflows/doc-preview-cleanup.yml: -------------------------------------------------------------------------------- 1 | name: Doc Preview Cleanup 2 | 3 | on: 4 | pull_request: 5 | types: [closed] 6 | 7 | jobs: 8 | doc-preview-cleanup: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout gh-pages branch 12 | uses: actions/checkout@v3 13 | with: 14 | ref: gh-pages 15 | - name: Delete preview and history + push changes 16 | run: | 17 | if [ -d "previews/PR$PRNUM" ]; then 18 | git config user.name "Documenter.jl" 19 | git config user.email "documenter@juliadocs.github.io" 20 | git rm -rf "previews/PR$PRNUM" 21 | git commit -m "delete preview" 22 | git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree}) 23 | git push --force origin gh-pages-new:gh-pages 24 | fi 25 | env: 26 | PRNUM: ${{ github.event.number }} 27 | -------------------------------------------------------------------------------- /.github/workflows/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | permissions: 4 | actions: write 5 | contents: read 6 | 7 | on: 8 | push: 9 | branches: 10 | - master 11 | tags: '*' 12 | pull_request: 13 | 14 | jobs: 15 | build: 16 | # permissions: 17 | # contents: write 18 | runs-on: ubuntu-latest 19 | steps: 20 | # This is from the GLMakie github action 21 | # - run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils 22 | - uses: actions/checkout@v3 23 | - uses: awalsh128/cache-apt-pkgs-action@latest 24 | with: 25 | packages: xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils 26 | - uses: julia-actions/setup-julia@latest 27 | with: 28 | version: '1.11' 29 | - uses: julia-actions/cache@v1 30 | with: 31 | # cache-name: master-docs 32 | # WARNING: cache-registries is actually slower for Windows runners 33 | cache-registries: "true" 34 | # WARNING: cache-compiled can break with certain choices of OS and architecture. 35 | # see https://github.com/julia-actions/cache/issues/11 36 | cache-compiled: "true" 37 | # the following line goes below after using Pkg 38 | # Pkg.develop([PackageSpec(url="https://github.com/esabo/RamanujanGraphs.jl"), PackageSpec(path=pwd())]) 39 | - name: Install dependencies 40 | run: | 41 | DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e ' 42 | using Pkg 43 | Pkg.develop([PackageSpec(path=pwd())]) 44 | Pkg.instantiate()' 45 | - name: Build and deploy 46 | env: 47 | GITHUB_TOKEN: ${{ secrets.Docs }} 48 | run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ docs/make.jl 49 | # run: julia --project=docs/ --code-coverage=user docs/make.jl 50 | # - uses: julia-actions/julia-processcoverage@v1 51 | # - uses: codecov/codecov-action@v1 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs/build/ 2 | src/unusedcode.jl 3 | src/research.jl 4 | src/symplecticutils.jl 5 | src/trellis_timing_results.txt 6 | src/trellis_old.jl 7 | src/todo_notes.txt 8 | src/testgencs.jl 9 | src/bounds_copy.jl 10 | test/testcases.jl 11 | exportTritrellises.jl 12 | test.jld2 13 | tricolorcodes*.jl 14 | bipartite_solutions.txt 15 | *.png 16 | learninggit.txt 17 | .DS_Store 18 | docs/.DS_Store 19 | *.txt 20 | typestest.jl 21 | simd_add_mul_wt_benchmarks.txt 22 | 23 | # profiling output stuff: 24 | *.pb.gz 25 | *.mem 26 | 27 | Manifest.toml 28 | /.vscode 29 | alg_geo_notes.jl 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, esabo 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Project.toml: -------------------------------------------------------------------------------- 1 | name = "CodingTheory" 2 | uuid = "7ca085cf-10e4-43da-ad7d-8f62f68877b3" 3 | authors = ["Eric Sabo ", "Ben Ide "] 4 | version = "0.1.0" 5 | 6 | [deps] 7 | AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f" 8 | Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" 9 | DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" 10 | Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" 11 | DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 12 | FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" 13 | Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" 14 | Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" 15 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 16 | Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13" 17 | ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" 18 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 19 | SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 20 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 21 | StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 22 | TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" 23 | 24 | [weakdeps] 25 | CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" 26 | Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" 27 | GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" 28 | GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6" 29 | GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2" 30 | GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231" 31 | JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" 32 | JuMP = "4076af6c-e467-56ae-b986-b466b2749572" 33 | Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" 34 | NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a" 35 | WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008" 36 | 37 | [extensions] 38 | JLD2Ext = "JLD2" 39 | JuMPExt = ["JuMP", "GLPK"] 40 | MakieExt = ["Makie"] 41 | 42 | [compat] 43 | AutoHashEquals = "2.2.0" 44 | CairoMakie = "0.13.1" 45 | Colors = "0.13.0" 46 | Combinatorics = "1.0.2" 47 | DataStructures = "0.18.20" 48 | DocStringExtensions = "0.9.3" 49 | FFTW = "1.8.0" 50 | GLMakie = "0.11.2" 51 | GraphMakie = "0.5.13" 52 | GraphPlot = "0.6.0" 53 | Graphs = "1.12.0" 54 | Makie = "0.19.11" 55 | NetworkLayout = "0.4.9" 56 | Oscar = "1.2.2" 57 | StatsBase = "0.34.4" 58 | WGLMakie = "0.8.15" 59 | julia = "≥ 1.10" 60 | 61 | [extras] 62 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 63 | 64 | [targets] 65 | test = ["Test"] 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodingTheory 2 | 3 | [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://esabo.github.io/CodingTheory/dev/) 4 | [![Build Status](https://github.com/esabo/CodingTheory/actions/workflows/Tests.yml/badge.svg?branch=master)](https://github.com/esabo/CodingTheory/actions/workflows/Tests.yml?query=branch%3Amaster) 5 | [![Coverage](https://codecov.io/gh/esabo/CodingTheory/branch/master/graph/badge.svg)](https://codecov.io/gh/esabo/CodingTheory) 6 | 7 | A coding theory library for Julia. 8 | 9 | The goal of this package is to develop a classical and quantum error-correcting codes package in as much native Julia as possible. The library is built around the Oscar.jl framework, and many thanks to Tommy Hofmann of these packages for helping this repo get off the ground. Anyone is welcome to contribute, although the final form of any accepted code may be standardized to maintain intra-package consistency. 10 | 11 | At the moment, all functions work as intended for test cases but have not been unit tested thoroughly enough to guarantee 100% accuracy and error free usage. All results from this library should be mentally checked and any bugs reported (or fixed and pushed). 12 | 13 | Parts of the library are multi-threaded and benefit greatly from the use of multiple cores. 14 | 15 | The minimum distance functions are currently being rewritten and will reappear soon. Depending on what one is looking for, current functions may be sufficient. Feel free to reach out on the [Slack channel](https://join.slack.com/t/juliacodingtheory/shared_invite/zt-2u8n5h5wm-QqnXl2NZqRvTmGGEPumbqQ). 16 | 17 | Improved documentation is currently a major to-do. Again, feel free to ask questions on Slack. 18 | -------------------------------------------------------------------------------- /benchmarks/iterators_bench.jl: -------------------------------------------------------------------------------- 1 | using CodingTheory 2 | using Oscar 3 | using LinearAlgebra 4 | using BenchmarkTools 5 | 6 | function visit_all_subsets(mutate, g_len, v_weight, subset) 7 | if subset 8 | gi=CodingTheory.SubsetGrayCode(g_len, v_weight) 9 | else 10 | gi=CodingTheory.GrayCode(g_len, v_weight; mutate = mutate) 11 | end 12 | for subset in gi 13 | # BenchmarkTools can elide simple computations so we need to do some nontrivial calculation here. 14 | # In any realistic situation we need to look at least look at all entries of the vector. 15 | # Ill model the task of looking at the entries using the 'all' function 16 | Base.all(i->(i==0), subset) 17 | end 18 | return 19 | end 20 | 21 | #= 22 | SubsetGrayCode and GrayCode appear to be in the same ballpark. 23 | GrayCode is faster, SubsetGrayCode uses less memory. 24 | 25 | ###### 26 | # n=25, k=12, mutate=true 27 | ###### 28 | @benchmark visit_all_subsets(25, 12, false) 29 | BenchmarkTools.Trial: 54 samples with 1 evaluation. 30 | Range (min … max): 66.365 ms … 219.557 ms ┊ GC (min … max): 0.00% … 34.15% 31 | Time (median): 92.912 ms ┊ GC (median): 26.24% 32 | Time (mean ± σ): 93.526 ms ± 27.981 ms ┊ GC (mean ± σ): 19.78% ± 13.74% 33 | 34 | ▂▂ █▃ 35 | ███▅▅▁▁▁▁▄▁▁█████▁▁▄▁▁▁▁▄▁▁▁▁▁▅▁▁▁▁▁▁▁▁▁▄▁▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄ ▁ 36 | 66.4 ms Histogram: frequency by time 181 ms < 37 | 38 | Memory estimate: 158.70 MiB, allocs estimate: 5200322. 39 | 40 | BenchmarkTools.Trial: 65 samples with 1 evaluation. 41 | Range (min … max): 51.159 ms … 103.931 ms ┊ GC (min … max): 0.00% … 50.88% 42 | Time (median): 77.176 ms ┊ GC (median): 31.98% 43 | Time (mean ± σ): 77.271 ms ± 6.824 ms ┊ GC (mean ± σ): 31.52% ± 7.35% 44 | 45 | █ ▁ 46 | ▃▃▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▅▆████▅▆▅▁▃▃▁▁▄▁▁▃▁▁▁▁▃ ▁ 47 | 51.2 ms Histogram: frequency by time 89.3 ms < 48 | 49 | Memory estimate: 238.05 MiB, allocs estimate: 5200308. 50 | =# -------------------------------------------------------------------------------- /data/color_codes/488d11stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d11stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d13stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d13stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d15stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d15stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d17stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d17stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d19stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d19stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d3stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d3stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d5stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d5stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d7stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d7stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/488d9stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/488d9stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d11stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d11stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d13stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d13stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d15stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d15stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d17stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d17stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d19stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d19stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d21stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d21stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d3stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d3stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d5stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d5stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d7stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d7stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/color_codes/666d9stabslogs_trellis.jld2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/data/color_codes/666d9stabslogs_trellis.jld2 -------------------------------------------------------------------------------- /data/surface3D/surface3D_3_hx.alist: -------------------------------------------------------------------------------- 1 | 44 51 2 | 4 4 3 | 4 4 4 4 4 4 4 4 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 3 4 3 4 | 3 3 4 4 3 3 3 3 4 4 3 3 3 3 3 3 4 4 4 4 3 3 3 3 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 3 3 3 2 2 2 3 3 3 2 2 2 5 | 1 3 13 17 6 | 2 4 14 18 7 | 3 5 15 19 8 | 4 6 16 20 9 | 7 9 17 21 10 | 8 10 18 22 11 | 9 11 19 23 12 | 10 12 20 24 13 | 1 25 34 14 | 1 2 26 35 15 | 2 27 36 16 | 3 28 37 17 | 3 4 29 38 18 | 4 30 39 19 | 5 31 40 20 | 5 6 32 41 21 | 6 33 42 22 | 7 34 43 23 | 7 8 35 44 24 | 8 36 45 25 | 9 37 46 26 | 9 10 38 47 27 | 10 39 48 28 | 11 40 49 29 | 11 12 41 50 30 | 12 42 51 31 | 13 25 28 32 | 13 14 26 29 33 | 14 27 30 34 | 15 28 31 35 | 15 16 29 32 36 | 16 30 33 37 | 17 34 37 38 | 17 18 35 38 39 | 18 36 39 40 | 19 37 40 41 | 19 20 38 41 42 | 20 39 42 43 | 21 43 46 44 | 21 22 44 47 45 | 22 45 48 46 | 23 46 49 47 | 23 24 47 50 48 | 24 48 51 49 | 1 9 10 50 | 2 10 11 51 | 1 3 12 13 52 | 2 4 13 14 53 | 3 15 16 54 | 4 16 17 55 | 5 18 19 56 | 6 19 20 57 | 5 7 21 22 58 | 6 8 22 23 59 | 7 24 25 60 | 8 25 26 61 | 1 27 28 62 | 2 28 29 63 | 3 30 31 64 | 4 31 32 65 | 1 5 33 34 66 | 2 6 34 35 67 | 3 7 36 37 68 | 4 8 37 38 69 | 5 39 40 70 | 6 40 41 71 | 7 42 43 72 | 8 43 44 73 | 9 27 74 | 10 28 75 | 11 29 76 | 12 27 30 77 | 13 28 31 78 | 14 29 32 79 | 15 30 80 | 16 31 81 | 17 32 82 | 9 18 33 83 | 10 19 34 84 | 11 20 35 85 | 12 21 33 36 86 | 13 22 34 37 87 | 14 23 35 38 88 | 15 24 36 89 | 16 25 37 90 | 17 26 38 91 | 18 39 92 | 19 40 93 | 20 41 94 | 21 39 42 95 | 22 40 43 96 | 23 41 44 97 | 24 42 98 | 25 43 99 | 26 44 100 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_3_lx.alist: -------------------------------------------------------------------------------- 1 | 1 51 2 | 3 1 3 | 3 4 | 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 25 26 27 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 1 31 | 1 32 | 1 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_3_mx.alist: -------------------------------------------------------------------------------- 1 | 12 44 2 | 6 2 3 | 5 6 5 5 6 5 5 6 5 5 6 5 4 | 2 2 2 2 2 2 2 2 1 1 1 2 2 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 1 1 5 | 1 9 12 27 33 6 | 1 2 10 13 28 34 7 | 2 11 14 29 35 8 | 3 12 15 30 36 9 | 3 4 13 16 31 37 10 | 4 14 17 32 38 11 | 5 18 21 33 39 12 | 5 6 19 22 34 40 13 | 6 20 23 35 41 14 | 7 21 24 36 42 15 | 7 8 22 25 37 43 16 | 8 23 26 38 44 17 | 1 2 18 | 2 3 19 | 4 5 20 | 5 6 21 | 7 8 22 | 8 9 23 | 10 11 24 | 11 12 25 | 1 26 | 2 27 | 3 28 | 1 4 29 | 2 5 30 | 3 6 31 | 4 32 | 5 33 | 6 34 | 7 35 | 8 36 | 9 37 | 7 10 38 | 8 11 39 | 9 12 40 | 10 41 | 11 42 | 12 43 | 1 44 | 2 45 | 3 46 | 4 47 | 5 48 | 6 49 | 1 7 50 | 2 8 51 | 3 9 52 | 4 10 53 | 5 11 54 | 6 12 55 | 7 56 | 8 57 | 9 58 | 10 59 | 11 60 | 12 61 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_4_hx.alist: -------------------------------------------------------------------------------- 1 | 123 136 2 | 4 4 3 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 3 4 4 3 4 | 3 3 3 4 4 4 4 4 4 3 3 3 3 3 3 4 4 4 4 4 4 3 3 3 3 3 3 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 3 3 3 3 2 2 2 2 3 3 3 3 3 3 3 3 2 2 2 2 5 | 1 4 37 46 6 | 2 5 38 47 7 | 3 6 39 48 8 | 4 7 40 49 9 | 5 8 41 50 10 | 6 9 42 51 11 | 7 10 43 52 12 | 8 11 44 53 13 | 9 12 45 54 14 | 13 16 46 55 15 | 14 17 47 56 16 | 15 18 48 57 17 | 16 19 49 58 18 | 17 20 50 59 19 | 18 21 51 60 20 | 19 22 52 61 21 | 20 23 53 62 22 | 21 24 54 63 23 | 25 28 55 64 24 | 26 29 56 65 25 | 27 30 57 66 26 | 28 31 58 67 27 | 29 32 59 68 28 | 30 33 60 69 29 | 31 34 61 70 30 | 32 35 62 71 31 | 33 36 63 72 32 | 1 73 89 33 | 1 2 74 90 34 | 2 3 75 91 35 | 3 76 92 36 | 4 77 93 37 | 4 5 78 94 38 | 5 6 79 95 39 | 6 80 96 40 | 7 81 97 41 | 7 8 82 98 42 | 8 9 83 99 43 | 9 84 100 44 | 10 85 101 45 | 10 11 86 102 46 | 11 12 87 103 47 | 12 88 104 48 | 13 89 105 49 | 13 14 90 106 50 | 14 15 91 107 51 | 15 92 108 52 | 16 93 109 53 | 16 17 94 110 54 | 17 18 95 111 55 | 18 96 112 56 | 19 97 113 57 | 19 20 98 114 58 | 20 21 99 115 59 | 21 100 116 60 | 22 101 117 61 | 22 23 102 118 62 | 23 24 103 119 63 | 24 104 120 64 | 25 105 121 65 | 25 26 106 122 66 | 26 27 107 123 67 | 27 108 124 68 | 28 109 125 69 | 28 29 110 126 70 | 29 30 111 127 71 | 30 112 128 72 | 31 113 129 73 | 31 32 114 130 74 | 32 33 115 131 75 | 33 116 132 76 | 34 117 133 77 | 34 35 118 134 78 | 35 36 119 135 79 | 36 120 136 80 | 37 73 77 81 | 37 38 74 78 82 | 38 39 75 79 83 | 39 76 80 84 | 40 77 81 85 | 40 41 78 82 86 | 41 42 79 83 87 | 42 80 84 88 | 43 81 85 89 | 43 44 82 86 90 | 44 45 83 87 91 | 45 84 88 92 | 46 89 93 93 | 46 47 90 94 94 | 47 48 91 95 95 | 48 92 96 96 | 49 93 97 97 | 49 50 94 98 98 | 50 51 95 99 99 | 51 96 100 100 | 52 97 101 101 | 52 53 98 102 102 | 53 54 99 103 103 | 54 100 104 104 | 55 105 109 105 | 55 56 106 110 106 | 56 57 107 111 107 | 57 108 112 108 | 58 109 113 109 | 58 59 110 114 110 | 59 60 111 115 111 | 60 112 116 112 | 61 113 117 113 | 61 62 114 118 114 | 62 63 115 119 115 | 63 116 120 116 | 64 121 125 117 | 64 65 122 126 118 | 65 66 123 127 119 | 66 124 128 120 | 67 125 129 121 | 67 68 126 130 122 | 68 69 127 131 123 | 69 128 132 124 | 70 129 133 125 | 70 71 130 134 126 | 71 72 131 135 127 | 72 132 136 128 | 1 28 29 129 | 2 29 30 130 | 3 30 31 131 | 1 4 32 33 132 | 2 5 33 34 133 | 3 6 34 35 134 | 4 7 36 37 135 | 5 8 37 38 136 | 6 9 38 39 137 | 7 40 41 138 | 8 41 42 139 | 9 42 43 140 | 10 44 45 141 | 11 45 46 142 | 12 46 47 143 | 10 13 48 49 144 | 11 14 49 50 145 | 12 15 50 51 146 | 13 16 52 53 147 | 14 17 53 54 148 | 15 18 54 55 149 | 16 56 57 150 | 17 57 58 151 | 18 58 59 152 | 19 60 61 153 | 20 61 62 154 | 21 62 63 155 | 19 22 64 65 156 | 20 23 65 66 157 | 21 24 66 67 158 | 22 25 68 69 159 | 23 26 69 70 160 | 24 27 70 71 161 | 25 72 73 162 | 26 73 74 163 | 27 74 75 164 | 1 76 77 165 | 2 77 78 166 | 3 78 79 167 | 4 80 81 168 | 5 81 82 169 | 6 82 83 170 | 7 84 85 171 | 8 85 86 172 | 9 86 87 173 | 1 10 88 89 174 | 2 11 89 90 175 | 3 12 90 91 176 | 4 13 92 93 177 | 5 14 93 94 178 | 6 15 94 95 179 | 7 16 96 97 180 | 8 17 97 98 181 | 9 18 98 99 182 | 10 19 100 101 183 | 11 20 101 102 184 | 12 21 102 103 185 | 13 22 104 105 186 | 14 23 105 106 187 | 15 24 106 107 188 | 16 25 108 109 189 | 17 26 109 110 190 | 18 27 110 111 191 | 19 112 113 192 | 20 113 114 193 | 21 114 115 194 | 22 116 117 195 | 23 117 118 196 | 24 118 119 197 | 25 120 121 198 | 26 121 122 199 | 27 122 123 200 | 28 76 201 | 29 77 202 | 30 78 203 | 31 79 204 | 32 76 80 205 | 33 77 81 206 | 34 78 82 207 | 35 79 83 208 | 36 80 84 209 | 37 81 85 210 | 38 82 86 211 | 39 83 87 212 | 40 84 213 | 41 85 214 | 42 86 215 | 43 87 216 | 28 44 88 217 | 29 45 89 218 | 30 46 90 219 | 31 47 91 220 | 32 48 88 92 221 | 33 49 89 93 222 | 34 50 90 94 223 | 35 51 91 95 224 | 36 52 92 96 225 | 37 53 93 97 226 | 38 54 94 98 227 | 39 55 95 99 228 | 40 56 96 229 | 41 57 97 230 | 42 58 98 231 | 43 59 99 232 | 44 60 100 233 | 45 61 101 234 | 46 62 102 235 | 47 63 103 236 | 48 64 100 104 237 | 49 65 101 105 238 | 50 66 102 106 239 | 51 67 103 107 240 | 52 68 104 108 241 | 53 69 105 109 242 | 54 70 106 110 243 | 55 71 107 111 244 | 56 72 108 245 | 57 73 109 246 | 58 74 110 247 | 59 75 111 248 | 60 112 249 | 61 113 250 | 62 114 251 | 63 115 252 | 64 112 116 253 | 65 113 117 254 | 66 114 118 255 | 67 115 119 256 | 68 116 120 257 | 69 117 121 258 | 70 118 122 259 | 71 119 123 260 | 72 120 261 | 73 121 262 | 74 122 263 | 75 123 264 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_4_lx.alist: -------------------------------------------------------------------------------- 1 | 1 136 2 | 4 1 3 | 4 4 | 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 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 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 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 5 | 73 74 75 76 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 1 79 | 1 80 | 1 81 | 1 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_4_mx.alist: -------------------------------------------------------------------------------- 1 | 36 123 2 | 6 2 3 | 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 5 6 6 5 4 | 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 5 | 1 28 32 76 88 6 | 1 2 29 33 77 89 7 | 2 3 30 34 78 90 8 | 3 31 35 79 91 9 | 4 32 36 80 92 10 | 4 5 33 37 81 93 11 | 5 6 34 38 82 94 12 | 6 35 39 83 95 13 | 7 36 40 84 96 14 | 7 8 37 41 85 97 15 | 8 9 38 42 86 98 16 | 9 39 43 87 99 17 | 10 44 48 88 100 18 | 10 11 45 49 89 101 19 | 11 12 46 50 90 102 20 | 12 47 51 91 103 21 | 13 48 52 92 104 22 | 13 14 49 53 93 105 23 | 14 15 50 54 94 106 24 | 15 51 55 95 107 25 | 16 52 56 96 108 26 | 16 17 53 57 97 109 27 | 17 18 54 58 98 110 28 | 18 55 59 99 111 29 | 19 60 64 100 112 30 | 19 20 61 65 101 113 31 | 20 21 62 66 102 114 32 | 21 63 67 103 115 33 | 22 64 68 104 116 34 | 22 23 65 69 105 117 35 | 23 24 66 70 106 118 36 | 24 67 71 107 119 37 | 25 68 72 108 120 38 | 25 26 69 73 109 121 39 | 26 27 70 74 110 122 40 | 27 71 75 111 123 41 | 1 2 42 | 2 3 43 | 3 4 44 | 5 6 45 | 6 7 46 | 7 8 47 | 9 10 48 | 10 11 49 | 11 12 50 | 13 14 51 | 14 15 52 | 15 16 53 | 17 18 54 | 18 19 55 | 19 20 56 | 21 22 57 | 22 23 58 | 23 24 59 | 25 26 60 | 26 27 61 | 27 28 62 | 29 30 63 | 30 31 64 | 31 32 65 | 33 34 66 | 34 35 67 | 35 36 68 | 1 69 | 2 70 | 3 71 | 4 72 | 1 5 73 | 2 6 74 | 3 7 75 | 4 8 76 | 5 9 77 | 6 10 78 | 7 11 79 | 8 12 80 | 9 81 | 10 82 | 11 83 | 12 84 | 13 85 | 14 86 | 15 87 | 16 88 | 13 17 89 | 14 18 90 | 15 19 91 | 16 20 92 | 17 21 93 | 18 22 94 | 19 23 95 | 20 24 96 | 21 97 | 22 98 | 23 99 | 24 100 | 25 101 | 26 102 | 27 103 | 28 104 | 25 29 105 | 26 30 106 | 27 31 107 | 28 32 108 | 29 33 109 | 30 34 110 | 31 35 111 | 32 36 112 | 33 113 | 34 114 | 35 115 | 36 116 | 1 117 | 2 118 | 3 119 | 4 120 | 5 121 | 6 122 | 7 123 | 8 124 | 9 125 | 10 126 | 11 127 | 12 128 | 1 13 129 | 2 14 130 | 3 15 131 | 4 16 132 | 5 17 133 | 6 18 134 | 7 19 135 | 8 20 136 | 9 21 137 | 10 22 138 | 11 23 139 | 12 24 140 | 13 25 141 | 14 26 142 | 15 27 143 | 16 28 144 | 17 29 145 | 18 30 146 | 19 31 147 | 20 32 148 | 21 33 149 | 22 34 150 | 23 35 151 | 24 36 152 | 25 153 | 26 154 | 27 155 | 28 156 | 29 157 | 30 158 | 31 159 | 32 160 | 33 161 | 34 162 | 35 163 | 36 164 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_5_lx.alist: -------------------------------------------------------------------------------- 1 | 1 285 2 | 5 1 3 | 5 4 | 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 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 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 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 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 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 161 162 163 164 165 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 1 167 | 1 168 | 1 169 | 1 170 | 1 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /data/surface3D/surface3D_6_lx.alist: -------------------------------------------------------------------------------- 1 | 1 516 2 | 6 1 3 | 6 4 | 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 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 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 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 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 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 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 1 1 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 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 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 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 301 302 303 304 305 306 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 1 307 | 1 308 | 1 309 | 1 310 | 1 311 | 1 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_2_hx.alist: -------------------------------------------------------------------------------- 1 | 24 24 2 | 4 4 3 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 | 1 3 9 13 6 | 2 4 10 14 7 | 1 3 11 15 8 | 2 4 12 16 9 | 5 7 9 13 10 | 6 8 10 14 11 | 5 7 11 15 12 | 6 8 12 16 13 | 1 2 17 21 14 | 1 2 18 22 15 | 3 4 19 23 16 | 3 4 20 24 17 | 5 6 17 21 18 | 5 6 18 22 19 | 7 8 19 23 20 | 7 8 20 24 21 | 9 10 17 19 22 | 9 10 18 20 23 | 11 12 17 19 24 | 11 12 18 20 25 | 13 14 21 23 26 | 13 14 22 24 27 | 15 16 21 23 28 | 15 16 22 24 29 | 1 3 9 10 30 | 2 4 9 10 31 | 1 3 11 12 32 | 2 4 11 12 33 | 5 7 13 14 34 | 6 8 13 14 35 | 5 7 15 16 36 | 6 8 15 16 37 | 1 5 17 18 38 | 2 6 17 18 39 | 3 7 19 20 40 | 4 8 19 20 41 | 1 5 21 22 42 | 2 6 21 22 43 | 3 7 23 24 44 | 4 8 23 24 45 | 9 13 17 19 46 | 10 14 18 20 47 | 11 15 17 19 48 | 12 16 18 20 49 | 9 13 21 23 50 | 10 14 22 24 51 | 11 15 21 23 52 | 12 16 22 24 53 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_2_lmx.alist: -------------------------------------------------------------------------------- 1 | 3 24 2 | 4 1 3 | 4 4 4 4 | 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 5 | 1 3 5 7 6 | 9 10 13 14 7 | 17 18 19 20 8 | 1 9 | 10 | 1 11 | 12 | 1 13 | 14 | 1 15 | 16 | 2 17 | 2 18 | 19 | 20 | 2 21 | 2 22 | 23 | 24 | 3 25 | 3 26 | 3 27 | 3 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_2_lx.alist: -------------------------------------------------------------------------------- 1 | 3 24 2 | 2 1 3 | 2 2 2 4 | 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 5 | 1 5 6 | 9 11 7 | 17 18 8 | 1 9 | 10 | 11 | 12 | 1 13 | 14 | 15 | 16 | 2 17 | 18 | 2 19 | 20 | 21 | 22 | 23 | 24 | 3 25 | 3 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_2_mx.alist: -------------------------------------------------------------------------------- 1 | 8 24 2 | 6 2 3 | 6 6 6 6 6 6 6 6 4 | 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 | 1 2 9 11 17 21 6 | 1 2 10 12 18 22 7 | 3 4 9 11 19 23 8 | 3 4 10 12 20 24 9 | 5 6 13 15 17 21 10 | 5 6 14 16 18 22 11 | 7 8 13 15 19 23 12 | 7 8 14 16 20 24 13 | 1 2 14 | 1 2 15 | 3 4 16 | 3 4 17 | 5 6 18 | 5 6 19 | 7 8 20 | 7 8 21 | 1 3 22 | 2 4 23 | 1 3 24 | 2 4 25 | 5 7 26 | 6 8 27 | 5 7 28 | 6 8 29 | 1 5 30 | 2 6 31 | 3 7 32 | 4 8 33 | 1 5 34 | 2 6 35 | 3 7 36 | 4 8 37 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_2_mxlmx.alist: -------------------------------------------------------------------------------- 1 | 11 24 2 | 6 3 3 | 6 6 6 6 6 6 6 6 4 4 4 4 | 3 2 3 2 3 2 3 2 3 3 2 2 3 3 2 2 3 3 3 3 2 2 2 2 5 | 1 2 9 11 17 21 6 | 1 2 10 12 18 22 7 | 3 4 9 11 19 23 8 | 3 4 10 12 20 24 9 | 5 6 13 15 17 21 10 | 5 6 14 16 18 22 11 | 7 8 13 15 19 23 12 | 7 8 14 16 20 24 13 | 1 3 5 7 14 | 9 10 13 14 15 | 17 18 19 20 16 | 1 2 9 17 | 1 2 18 | 3 4 9 19 | 3 4 20 | 5 6 9 21 | 5 6 22 | 7 8 9 23 | 7 8 24 | 1 3 10 25 | 2 4 10 26 | 1 3 27 | 2 4 28 | 5 7 10 29 | 6 8 10 30 | 5 7 31 | 6 8 32 | 1 5 11 33 | 2 6 11 34 | 3 7 11 35 | 4 8 11 36 | 1 5 37 | 2 6 38 | 3 7 39 | 4 8 40 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_3_hx.alist: -------------------------------------------------------------------------------- 1 | 81 81 2 | 4 4 3 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 | 1 4 28 37 6 | 2 5 29 38 7 | 3 6 30 39 8 | 4 7 31 40 9 | 5 8 32 41 10 | 6 9 33 42 11 | 1 7 34 43 12 | 2 8 35 44 13 | 3 9 36 45 14 | 10 13 37 46 15 | 11 14 38 47 16 | 12 15 39 48 17 | 13 16 40 49 18 | 14 17 41 50 19 | 15 18 42 51 20 | 10 16 43 52 21 | 11 17 44 53 22 | 12 18 45 54 23 | 19 22 28 46 24 | 20 23 29 47 25 | 21 24 30 48 26 | 22 25 31 49 27 | 23 26 32 50 28 | 24 27 33 51 29 | 19 25 34 52 30 | 20 26 35 53 31 | 21 27 36 54 32 | 1 2 55 64 33 | 2 3 56 65 34 | 1 3 57 66 35 | 4 5 58 67 36 | 5 6 59 68 37 | 4 6 60 69 38 | 7 8 61 70 39 | 8 9 62 71 40 | 7 9 63 72 41 | 10 11 64 73 42 | 11 12 65 74 43 | 10 12 66 75 44 | 13 14 67 76 45 | 14 15 68 77 46 | 13 15 69 78 47 | 16 17 70 79 48 | 17 18 71 80 49 | 16 18 72 81 50 | 19 20 55 73 51 | 20 21 56 74 52 | 19 21 57 75 53 | 22 23 58 76 54 | 23 24 59 77 55 | 22 24 60 78 56 | 25 26 61 79 57 | 26 27 62 80 58 | 25 27 63 81 59 | 28 29 55 58 60 | 29 30 56 59 61 | 28 30 57 60 62 | 31 32 58 61 63 | 32 33 59 62 64 | 31 33 60 63 65 | 34 35 55 61 66 | 35 36 56 62 67 | 34 36 57 63 68 | 37 38 64 67 69 | 38 39 65 68 70 | 37 39 66 69 71 | 40 41 67 70 72 | 41 42 68 71 73 | 40 42 69 72 74 | 43 44 64 70 75 | 44 45 65 71 76 | 43 45 66 72 77 | 46 47 73 76 78 | 47 48 74 77 79 | 46 48 75 78 80 | 49 50 76 79 81 | 50 51 77 80 82 | 49 51 78 81 83 | 52 53 73 79 84 | 53 54 74 80 85 | 52 54 75 81 86 | 1 7 28 30 87 | 2 8 28 29 88 | 3 9 29 30 89 | 1 4 31 33 90 | 2 5 31 32 91 | 3 6 32 33 92 | 4 7 34 36 93 | 5 8 34 35 94 | 6 9 35 36 95 | 10 16 37 39 96 | 11 17 37 38 97 | 12 18 38 39 98 | 10 13 40 42 99 | 11 14 40 41 100 | 12 15 41 42 101 | 13 16 43 45 102 | 14 17 43 44 103 | 15 18 44 45 104 | 19 25 46 48 105 | 20 26 46 47 106 | 21 27 47 48 107 | 19 22 49 51 108 | 20 23 49 50 109 | 21 24 50 51 110 | 22 25 52 54 111 | 23 26 52 53 112 | 24 27 53 54 113 | 1 19 55 57 114 | 2 20 55 56 115 | 3 21 56 57 116 | 4 22 58 60 117 | 5 23 58 59 118 | 6 24 59 60 119 | 7 25 61 63 120 | 8 26 61 62 121 | 9 27 62 63 122 | 1 10 64 66 123 | 2 11 64 65 124 | 3 12 65 66 125 | 4 13 67 69 126 | 5 14 67 68 127 | 6 15 68 69 128 | 7 16 70 72 129 | 8 17 70 71 130 | 9 18 71 72 131 | 10 19 73 75 132 | 11 20 73 74 133 | 12 21 74 75 134 | 13 22 76 78 135 | 14 23 76 77 136 | 15 24 77 78 137 | 16 25 79 81 138 | 17 26 79 80 139 | 18 27 80 81 140 | 28 46 55 61 141 | 29 47 56 62 142 | 30 48 57 63 143 | 31 49 55 58 144 | 32 50 56 59 145 | 33 51 57 60 146 | 34 52 58 61 147 | 35 53 59 62 148 | 36 54 60 63 149 | 28 37 64 70 150 | 29 38 65 71 151 | 30 39 66 72 152 | 31 40 64 67 153 | 32 41 65 68 154 | 33 42 66 69 155 | 34 43 67 70 156 | 35 44 68 71 157 | 36 45 69 72 158 | 37 46 73 79 159 | 38 47 74 80 160 | 39 48 75 81 161 | 40 49 73 76 162 | 41 50 74 77 163 | 42 51 75 78 164 | 43 52 76 79 165 | 44 53 77 80 166 | 45 54 78 81 167 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_3_lmx.alist: -------------------------------------------------------------------------------- 1 | 3 81 2 | 9 1 3 | 9 9 9 4 | 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 1 4 7 10 13 16 19 22 25 6 | 28 29 30 37 38 39 46 47 48 7 | 55 56 57 58 59 60 61 62 63 8 | 1 9 | 10 | 11 | 1 12 | 13 | 14 | 1 15 | 16 | 17 | 1 18 | 19 | 20 | 1 21 | 22 | 23 | 1 24 | 25 | 26 | 1 27 | 28 | 29 | 1 30 | 31 | 32 | 1 33 | 34 | 35 | 2 36 | 2 37 | 2 38 | 39 | 40 | 41 | 42 | 43 | 44 | 2 45 | 2 46 | 2 47 | 48 | 49 | 50 | 51 | 52 | 53 | 2 54 | 2 55 | 2 56 | 57 | 58 | 59 | 60 | 61 | 62 | 3 63 | 3 64 | 3 65 | 3 66 | 3 67 | 3 68 | 3 69 | 3 70 | 3 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_3_lx.alist: -------------------------------------------------------------------------------- 1 | 3 81 2 | 3 1 3 | 3 3 3 4 | 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 5 | 1 10 19 6 | 28 31 34 7 | 55 56 57 8 | 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 1 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 1 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 2 36 | 37 | 38 | 2 39 | 40 | 41 | 2 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 3 63 | 3 64 | 3 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_3_mx.alist: -------------------------------------------------------------------------------- 1 | 27 81 2 | 6 2 3 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 | 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 | 1 2 28 31 55 64 6 | 2 3 29 32 56 65 7 | 1 3 30 33 57 66 8 | 4 5 31 34 58 67 9 | 5 6 32 35 59 68 10 | 4 6 33 36 60 69 11 | 7 8 28 34 61 70 12 | 8 9 29 35 62 71 13 | 7 9 30 36 63 72 14 | 10 11 37 40 64 73 15 | 11 12 38 41 65 74 16 | 10 12 39 42 66 75 17 | 13 14 40 43 67 76 18 | 14 15 41 44 68 77 19 | 13 15 42 45 69 78 20 | 16 17 37 43 70 79 21 | 17 18 38 44 71 80 22 | 16 18 39 45 72 81 23 | 19 20 46 49 55 73 24 | 20 21 47 50 56 74 25 | 19 21 48 51 57 75 26 | 22 23 49 52 58 76 27 | 23 24 50 53 59 77 28 | 22 24 51 54 60 78 29 | 25 26 46 52 61 79 30 | 26 27 47 53 62 80 31 | 25 27 48 54 63 81 32 | 1 3 33 | 1 2 34 | 2 3 35 | 4 6 36 | 4 5 37 | 5 6 38 | 7 9 39 | 7 8 40 | 8 9 41 | 10 12 42 | 10 11 43 | 11 12 44 | 13 15 45 | 13 14 46 | 14 15 47 | 16 18 48 | 16 17 49 | 17 18 50 | 19 21 51 | 19 20 52 | 20 21 53 | 22 24 54 | 22 23 55 | 23 24 56 | 25 27 57 | 25 26 58 | 26 27 59 | 1 7 60 | 2 8 61 | 3 9 62 | 1 4 63 | 2 5 64 | 3 6 65 | 4 7 66 | 5 8 67 | 6 9 68 | 10 16 69 | 11 17 70 | 12 18 71 | 10 13 72 | 11 14 73 | 12 15 74 | 13 16 75 | 14 17 76 | 15 18 77 | 19 25 78 | 20 26 79 | 21 27 80 | 19 22 81 | 20 23 82 | 21 24 83 | 22 25 84 | 23 26 85 | 24 27 86 | 1 19 87 | 2 20 88 | 3 21 89 | 4 22 90 | 5 23 91 | 6 24 92 | 7 25 93 | 8 26 94 | 9 27 95 | 1 10 96 | 2 11 97 | 3 12 98 | 4 13 99 | 5 14 100 | 6 15 101 | 7 16 102 | 8 17 103 | 9 18 104 | 10 19 105 | 11 20 106 | 12 21 107 | 13 22 108 | 14 23 109 | 15 24 110 | 16 25 111 | 17 26 112 | 18 27 113 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_3_mxlmx.alist: -------------------------------------------------------------------------------- 1 | 30 81 2 | 9 3 3 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 9 9 9 4 | 3 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3 2 2 3 3 3 2 2 2 2 2 2 3 3 3 2 2 2 2 2 2 3 3 3 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 | 1 2 28 31 55 64 6 | 2 3 29 32 56 65 7 | 1 3 30 33 57 66 8 | 4 5 31 34 58 67 9 | 5 6 32 35 59 68 10 | 4 6 33 36 60 69 11 | 7 8 28 34 61 70 12 | 8 9 29 35 62 71 13 | 7 9 30 36 63 72 14 | 10 11 37 40 64 73 15 | 11 12 38 41 65 74 16 | 10 12 39 42 66 75 17 | 13 14 40 43 67 76 18 | 14 15 41 44 68 77 19 | 13 15 42 45 69 78 20 | 16 17 37 43 70 79 21 | 17 18 38 44 71 80 22 | 16 18 39 45 72 81 23 | 19 20 46 49 55 73 24 | 20 21 47 50 56 74 25 | 19 21 48 51 57 75 26 | 22 23 49 52 58 76 27 | 23 24 50 53 59 77 28 | 22 24 51 54 60 78 29 | 25 26 46 52 61 79 30 | 26 27 47 53 62 80 31 | 25 27 48 54 63 81 32 | 1 4 7 10 13 16 19 22 25 33 | 28 29 30 37 38 39 46 47 48 34 | 55 56 57 58 59 60 61 62 63 35 | 1 3 28 36 | 1 2 37 | 2 3 38 | 4 6 28 39 | 4 5 40 | 5 6 41 | 7 9 28 42 | 7 8 43 | 8 9 44 | 10 12 28 45 | 10 11 46 | 11 12 47 | 13 15 28 48 | 13 14 49 | 14 15 50 | 16 18 28 51 | 16 17 52 | 17 18 53 | 19 21 28 54 | 19 20 55 | 20 21 56 | 22 24 28 57 | 22 23 58 | 23 24 59 | 25 27 28 60 | 25 26 61 | 26 27 62 | 1 7 29 63 | 2 8 29 64 | 3 9 29 65 | 1 4 66 | 2 5 67 | 3 6 68 | 4 7 69 | 5 8 70 | 6 9 71 | 10 16 29 72 | 11 17 29 73 | 12 18 29 74 | 10 13 75 | 11 14 76 | 12 15 77 | 13 16 78 | 14 17 79 | 15 18 80 | 19 25 29 81 | 20 26 29 82 | 21 27 29 83 | 19 22 84 | 20 23 85 | 21 24 86 | 22 25 87 | 23 26 88 | 24 27 89 | 1 19 30 90 | 2 20 30 91 | 3 21 30 92 | 4 22 30 93 | 5 23 30 94 | 6 24 30 95 | 7 25 30 96 | 8 26 30 97 | 9 27 30 98 | 1 10 99 | 2 11 100 | 3 12 101 | 4 13 102 | 5 14 103 | 6 15 104 | 7 16 105 | 8 17 106 | 9 18 107 | 10 19 108 | 11 20 109 | 12 21 110 | 13 22 111 | 14 23 112 | 15 24 113 | 16 25 114 | 17 26 115 | 18 27 116 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_4_lmx.alist: -------------------------------------------------------------------------------- 1 | 3 192 2 | 16 1 3 | 16 16 16 4 | 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 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 1 1 1 1 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 1 1 1 1 1 1 1 1 1 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 6 | 65 66 67 68 81 82 83 84 97 98 99 100 113 114 115 116 7 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 8 | 1 9 | 10 | 11 | 12 | 1 13 | 14 | 15 | 16 | 1 17 | 18 | 19 | 20 | 1 21 | 22 | 23 | 24 | 1 25 | 26 | 27 | 28 | 1 29 | 30 | 31 | 32 | 1 33 | 34 | 35 | 36 | 1 37 | 38 | 39 | 40 | 1 41 | 42 | 43 | 44 | 1 45 | 46 | 47 | 48 | 1 49 | 50 | 51 | 52 | 1 53 | 54 | 55 | 56 | 1 57 | 58 | 59 | 60 | 1 61 | 62 | 63 | 64 | 1 65 | 66 | 67 | 68 | 1 69 | 70 | 71 | 72 | 2 73 | 2 74 | 2 75 | 2 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 2 89 | 2 90 | 2 91 | 2 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 2 105 | 2 106 | 2 107 | 2 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 2 121 | 2 122 | 2 123 | 2 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 3 137 | 3 138 | 3 139 | 3 140 | 3 141 | 3 142 | 3 143 | 3 144 | 3 145 | 3 146 | 3 147 | 3 148 | 3 149 | 3 150 | 3 151 | 3 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_4_lx.alist: -------------------------------------------------------------------------------- 1 | 3 192 2 | 4 1 3 | 4 4 4 4 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 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 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 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 5 | 1 17 33 49 6 | 65 69 73 77 7 | 129 130 131 132 8 | 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 1 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 1 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 1 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 2 73 | 74 | 75 | 76 | 2 77 | 78 | 79 | 80 | 2 81 | 82 | 83 | 84 | 2 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 3 137 | 3 138 | 3 139 | 3 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_4_mx.alist: -------------------------------------------------------------------------------- 1 | 64 192 2 | 6 2 3 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 | 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 | 1 2 65 69 129 145 6 | 2 3 66 70 130 146 7 | 3 4 67 71 131 147 8 | 1 4 68 72 132 148 9 | 5 6 69 73 133 149 10 | 6 7 70 74 134 150 11 | 7 8 71 75 135 151 12 | 5 8 72 76 136 152 13 | 9 10 73 77 137 153 14 | 10 11 74 78 138 154 15 | 11 12 75 79 139 155 16 | 9 12 76 80 140 156 17 | 13 14 65 77 141 157 18 | 14 15 66 78 142 158 19 | 15 16 67 79 143 159 20 | 13 16 68 80 144 160 21 | 17 18 81 85 145 161 22 | 18 19 82 86 146 162 23 | 19 20 83 87 147 163 24 | 17 20 84 88 148 164 25 | 21 22 85 89 149 165 26 | 22 23 86 90 150 166 27 | 23 24 87 91 151 167 28 | 21 24 88 92 152 168 29 | 25 26 89 93 153 169 30 | 26 27 90 94 154 170 31 | 27 28 91 95 155 171 32 | 25 28 92 96 156 172 33 | 29 30 81 93 157 173 34 | 30 31 82 94 158 174 35 | 31 32 83 95 159 175 36 | 29 32 84 96 160 176 37 | 33 34 97 101 161 177 38 | 34 35 98 102 162 178 39 | 35 36 99 103 163 179 40 | 33 36 100 104 164 180 41 | 37 38 101 105 165 181 42 | 38 39 102 106 166 182 43 | 39 40 103 107 167 183 44 | 37 40 104 108 168 184 45 | 41 42 105 109 169 185 46 | 42 43 106 110 170 186 47 | 43 44 107 111 171 187 48 | 41 44 108 112 172 188 49 | 45 46 97 109 173 189 50 | 46 47 98 110 174 190 51 | 47 48 99 111 175 191 52 | 45 48 100 112 176 192 53 | 49 50 113 117 129 177 54 | 50 51 114 118 130 178 55 | 51 52 115 119 131 179 56 | 49 52 116 120 132 180 57 | 53 54 117 121 133 181 58 | 54 55 118 122 134 182 59 | 55 56 119 123 135 183 60 | 53 56 120 124 136 184 61 | 57 58 121 125 137 185 62 | 58 59 122 126 138 186 63 | 59 60 123 127 139 187 64 | 57 60 124 128 140 188 65 | 61 62 113 125 141 189 66 | 62 63 114 126 142 190 67 | 63 64 115 127 143 191 68 | 61 64 116 128 144 192 69 | 1 4 70 | 1 2 71 | 2 3 72 | 3 4 73 | 5 8 74 | 5 6 75 | 6 7 76 | 7 8 77 | 9 12 78 | 9 10 79 | 10 11 80 | 11 12 81 | 13 16 82 | 13 14 83 | 14 15 84 | 15 16 85 | 17 20 86 | 17 18 87 | 18 19 88 | 19 20 89 | 21 24 90 | 21 22 91 | 22 23 92 | 23 24 93 | 25 28 94 | 25 26 95 | 26 27 96 | 27 28 97 | 29 32 98 | 29 30 99 | 30 31 100 | 31 32 101 | 33 36 102 | 33 34 103 | 34 35 104 | 35 36 105 | 37 40 106 | 37 38 107 | 38 39 108 | 39 40 109 | 41 44 110 | 41 42 111 | 42 43 112 | 43 44 113 | 45 48 114 | 45 46 115 | 46 47 116 | 47 48 117 | 49 52 118 | 49 50 119 | 50 51 120 | 51 52 121 | 53 56 122 | 53 54 123 | 54 55 124 | 55 56 125 | 57 60 126 | 57 58 127 | 58 59 128 | 59 60 129 | 61 64 130 | 61 62 131 | 62 63 132 | 63 64 133 | 1 13 134 | 2 14 135 | 3 15 136 | 4 16 137 | 1 5 138 | 2 6 139 | 3 7 140 | 4 8 141 | 5 9 142 | 6 10 143 | 7 11 144 | 8 12 145 | 9 13 146 | 10 14 147 | 11 15 148 | 12 16 149 | 17 29 150 | 18 30 151 | 19 31 152 | 20 32 153 | 17 21 154 | 18 22 155 | 19 23 156 | 20 24 157 | 21 25 158 | 22 26 159 | 23 27 160 | 24 28 161 | 25 29 162 | 26 30 163 | 27 31 164 | 28 32 165 | 33 45 166 | 34 46 167 | 35 47 168 | 36 48 169 | 33 37 170 | 34 38 171 | 35 39 172 | 36 40 173 | 37 41 174 | 38 42 175 | 39 43 176 | 40 44 177 | 41 45 178 | 42 46 179 | 43 47 180 | 44 48 181 | 49 61 182 | 50 62 183 | 51 63 184 | 52 64 185 | 49 53 186 | 50 54 187 | 51 55 188 | 52 56 189 | 53 57 190 | 54 58 191 | 55 59 192 | 56 60 193 | 57 61 194 | 58 62 195 | 59 63 196 | 60 64 197 | 1 49 198 | 2 50 199 | 3 51 200 | 4 52 201 | 5 53 202 | 6 54 203 | 7 55 204 | 8 56 205 | 9 57 206 | 10 58 207 | 11 59 208 | 12 60 209 | 13 61 210 | 14 62 211 | 15 63 212 | 16 64 213 | 1 17 214 | 2 18 215 | 3 19 216 | 4 20 217 | 5 21 218 | 6 22 219 | 7 23 220 | 8 24 221 | 9 25 222 | 10 26 223 | 11 27 224 | 12 28 225 | 13 29 226 | 14 30 227 | 15 31 228 | 16 32 229 | 17 33 230 | 18 34 231 | 19 35 232 | 20 36 233 | 21 37 234 | 22 38 235 | 23 39 236 | 24 40 237 | 25 41 238 | 26 42 239 | 27 43 240 | 28 44 241 | 29 45 242 | 30 46 243 | 31 47 244 | 32 48 245 | 33 49 246 | 34 50 247 | 35 51 248 | 36 52 249 | 37 53 250 | 38 54 251 | 39 55 252 | 40 56 253 | 41 57 254 | 42 58 255 | 43 59 256 | 44 60 257 | 45 61 258 | 46 62 259 | 47 63 260 | 48 64 261 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_4_mxlmx.alist: -------------------------------------------------------------------------------- 1 | 67 192 2 | 16 3 3 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 16 16 16 4 | 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 5 | 1 2 65 69 129 145 6 | 2 3 66 70 130 146 7 | 3 4 67 71 131 147 8 | 1 4 68 72 132 148 9 | 5 6 69 73 133 149 10 | 6 7 70 74 134 150 11 | 7 8 71 75 135 151 12 | 5 8 72 76 136 152 13 | 9 10 73 77 137 153 14 | 10 11 74 78 138 154 15 | 11 12 75 79 139 155 16 | 9 12 76 80 140 156 17 | 13 14 65 77 141 157 18 | 14 15 66 78 142 158 19 | 15 16 67 79 143 159 20 | 13 16 68 80 144 160 21 | 17 18 81 85 145 161 22 | 18 19 82 86 146 162 23 | 19 20 83 87 147 163 24 | 17 20 84 88 148 164 25 | 21 22 85 89 149 165 26 | 22 23 86 90 150 166 27 | 23 24 87 91 151 167 28 | 21 24 88 92 152 168 29 | 25 26 89 93 153 169 30 | 26 27 90 94 154 170 31 | 27 28 91 95 155 171 32 | 25 28 92 96 156 172 33 | 29 30 81 93 157 173 34 | 30 31 82 94 158 174 35 | 31 32 83 95 159 175 36 | 29 32 84 96 160 176 37 | 33 34 97 101 161 177 38 | 34 35 98 102 162 178 39 | 35 36 99 103 163 179 40 | 33 36 100 104 164 180 41 | 37 38 101 105 165 181 42 | 38 39 102 106 166 182 43 | 39 40 103 107 167 183 44 | 37 40 104 108 168 184 45 | 41 42 105 109 169 185 46 | 42 43 106 110 170 186 47 | 43 44 107 111 171 187 48 | 41 44 108 112 172 188 49 | 45 46 97 109 173 189 50 | 46 47 98 110 174 190 51 | 47 48 99 111 175 191 52 | 45 48 100 112 176 192 53 | 49 50 113 117 129 177 54 | 50 51 114 118 130 178 55 | 51 52 115 119 131 179 56 | 49 52 116 120 132 180 57 | 53 54 117 121 133 181 58 | 54 55 118 122 134 182 59 | 55 56 119 123 135 183 60 | 53 56 120 124 136 184 61 | 57 58 121 125 137 185 62 | 58 59 122 126 138 186 63 | 59 60 123 127 139 187 64 | 57 60 124 128 140 188 65 | 61 62 113 125 141 189 66 | 62 63 114 126 142 190 67 | 63 64 115 127 143 191 68 | 61 64 116 128 144 192 69 | 1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 70 | 65 66 67 68 81 82 83 84 97 98 99 100 113 114 115 116 71 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 72 | 1 4 65 73 | 1 2 74 | 2 3 75 | 3 4 76 | 5 8 65 77 | 5 6 78 | 6 7 79 | 7 8 80 | 9 12 65 81 | 9 10 82 | 10 11 83 | 11 12 84 | 13 16 65 85 | 13 14 86 | 14 15 87 | 15 16 88 | 17 20 65 89 | 17 18 90 | 18 19 91 | 19 20 92 | 21 24 65 93 | 21 22 94 | 22 23 95 | 23 24 96 | 25 28 65 97 | 25 26 98 | 26 27 99 | 27 28 100 | 29 32 65 101 | 29 30 102 | 30 31 103 | 31 32 104 | 33 36 65 105 | 33 34 106 | 34 35 107 | 35 36 108 | 37 40 65 109 | 37 38 110 | 38 39 111 | 39 40 112 | 41 44 65 113 | 41 42 114 | 42 43 115 | 43 44 116 | 45 48 65 117 | 45 46 118 | 46 47 119 | 47 48 120 | 49 52 65 121 | 49 50 122 | 50 51 123 | 51 52 124 | 53 56 65 125 | 53 54 126 | 54 55 127 | 55 56 128 | 57 60 65 129 | 57 58 130 | 58 59 131 | 59 60 132 | 61 64 65 133 | 61 62 134 | 62 63 135 | 63 64 136 | 1 13 66 137 | 2 14 66 138 | 3 15 66 139 | 4 16 66 140 | 1 5 141 | 2 6 142 | 3 7 143 | 4 8 144 | 5 9 145 | 6 10 146 | 7 11 147 | 8 12 148 | 9 13 149 | 10 14 150 | 11 15 151 | 12 16 152 | 17 29 66 153 | 18 30 66 154 | 19 31 66 155 | 20 32 66 156 | 17 21 157 | 18 22 158 | 19 23 159 | 20 24 160 | 21 25 161 | 22 26 162 | 23 27 163 | 24 28 164 | 25 29 165 | 26 30 166 | 27 31 167 | 28 32 168 | 33 45 66 169 | 34 46 66 170 | 35 47 66 171 | 36 48 66 172 | 33 37 173 | 34 38 174 | 35 39 175 | 36 40 176 | 37 41 177 | 38 42 178 | 39 43 179 | 40 44 180 | 41 45 181 | 42 46 182 | 43 47 183 | 44 48 184 | 49 61 66 185 | 50 62 66 186 | 51 63 66 187 | 52 64 66 188 | 49 53 189 | 50 54 190 | 51 55 191 | 52 56 192 | 53 57 193 | 54 58 194 | 55 59 195 | 56 60 196 | 57 61 197 | 58 62 198 | 59 63 199 | 60 64 200 | 1 49 67 201 | 2 50 67 202 | 3 51 67 203 | 4 52 67 204 | 5 53 67 205 | 6 54 67 206 | 7 55 67 207 | 8 56 67 208 | 9 57 67 209 | 10 58 67 210 | 11 59 67 211 | 12 60 67 212 | 13 61 67 213 | 14 62 67 214 | 15 63 67 215 | 16 64 67 216 | 1 17 217 | 2 18 218 | 3 19 219 | 4 20 220 | 5 21 221 | 6 22 222 | 7 23 223 | 8 24 224 | 9 25 225 | 10 26 226 | 11 27 227 | 12 28 228 | 13 29 229 | 14 30 230 | 15 31 231 | 16 32 232 | 17 33 233 | 18 34 234 | 19 35 235 | 20 36 236 | 21 37 237 | 22 38 238 | 23 39 239 | 24 40 240 | 25 41 241 | 26 42 242 | 27 43 243 | 28 44 244 | 29 45 245 | 30 46 246 | 31 47 247 | 32 48 248 | 33 49 249 | 34 50 250 | 35 51 251 | 36 52 252 | 37 53 253 | 38 54 254 | 39 55 255 | 40 56 256 | 41 57 257 | 42 58 258 | 43 59 259 | 44 60 260 | 45 61 261 | 46 62 262 | 47 63 263 | 48 64 264 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_5_lmx.alist: -------------------------------------------------------------------------------- 1 | 3 375 2 | 25 1 3 | 25 25 25 4 | 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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 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 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 0 0 0 0 5 | 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 6 | 126 127 128 129 130 151 152 153 154 155 176 177 178 179 180 201 202 203 204 205 226 227 228 229 230 7 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 8 | 1 9 | 10 | 11 | 12 | 13 | 1 14 | 15 | 16 | 17 | 18 | 1 19 | 20 | 21 | 22 | 23 | 1 24 | 25 | 26 | 27 | 28 | 1 29 | 30 | 31 | 32 | 33 | 1 34 | 35 | 36 | 37 | 38 | 1 39 | 40 | 41 | 42 | 43 | 1 44 | 45 | 46 | 47 | 48 | 1 49 | 50 | 51 | 52 | 53 | 1 54 | 55 | 56 | 57 | 58 | 1 59 | 60 | 61 | 62 | 63 | 1 64 | 65 | 66 | 67 | 68 | 1 69 | 70 | 71 | 72 | 73 | 1 74 | 75 | 76 | 77 | 78 | 1 79 | 80 | 81 | 82 | 83 | 1 84 | 85 | 86 | 87 | 88 | 1 89 | 90 | 91 | 92 | 93 | 1 94 | 95 | 96 | 97 | 98 | 1 99 | 100 | 101 | 102 | 103 | 1 104 | 105 | 106 | 107 | 108 | 1 109 | 110 | 111 | 112 | 113 | 1 114 | 115 | 116 | 117 | 118 | 1 119 | 120 | 121 | 122 | 123 | 1 124 | 125 | 126 | 127 | 128 | 1 129 | 130 | 131 | 132 | 133 | 2 134 | 2 135 | 2 136 | 2 137 | 2 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 2 159 | 2 160 | 2 161 | 2 162 | 2 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 2 184 | 2 185 | 2 186 | 2 187 | 2 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 2 209 | 2 210 | 2 211 | 2 212 | 2 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 2 234 | 2 235 | 2 236 | 2 237 | 2 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 3 259 | 3 260 | 3 261 | 3 262 | 3 263 | 3 264 | 3 265 | 3 266 | 3 267 | 3 268 | 3 269 | 3 270 | 3 271 | 3 272 | 3 273 | 3 274 | 3 275 | 3 276 | 3 277 | 3 278 | 3 279 | 3 280 | 3 281 | 3 282 | 3 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | -------------------------------------------------------------------------------- /data/toric3D/toric3D_5_lx.alist: -------------------------------------------------------------------------------- 1 | 3 375 2 | 5 1 3 | 5 5 5 4 | 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 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 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 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 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 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 1 26 51 76 101 6 | 126 131 136 141 146 7 | 251 252 253 254 255 8 | 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 1 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 1 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 1 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 1 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 2 134 | 135 | 136 | 137 | 138 | 2 139 | 140 | 141 | 142 | 143 | 2 144 | 145 | 146 | 147 | 148 | 2 149 | 150 | 151 | 152 | 153 | 2 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 3 259 | 3 260 | 3 261 | 3 262 | 3 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | -------------------------------------------------------------------------------- /docs/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 3 | BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 4 | CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" 5 | Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" 6 | CodingTheory = "7ca085cf-10e4-43da-ad7d-8f62f68877b3" 7 | DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" 8 | Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" 9 | Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 10 | DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 11 | DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" 12 | Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" 13 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 14 | Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" 15 | Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13" 16 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 17 | -------------------------------------------------------------------------------- /docs/make.jl: -------------------------------------------------------------------------------- 1 | using DocumenterCitations, Documenter, CodingTheory 2 | 3 | bib = CitationBibliography(joinpath(@__DIR__, "src", "references.bib"); style = :numeric) 4 | 5 | Documenter.makedocs(; 6 | plugins=[bib], 7 | clean = true, 8 | doctest = false, 9 | modules = Module[CodingTheory], 10 | repo = "", 11 | highlightsig = true, 12 | sitename = "CodingTheory.jl", 13 | expandfirst = [], 14 | warnonly = [:missing_docs], 15 | pages = ["Introduction" => "index.md", 16 | "Tutorials" => [ 17 | "Tutorials/Linear Codes.md", 18 | "Tutorials/Cyclic Codes.md", 19 | "Tutorials/Quantum Codes.md", 20 | "Tutorials/Weight Reduction.md" 21 | ], 22 | "Examples" => [ 23 | "Examples/The Vardy-Be’ery Decomposition.md", 24 | "Examples/Quantum Reed-Muller Codes.md" 25 | ], 26 | "Classical" => [ 27 | "Classical/linear_code.md", 28 | "Classical/concatenation.md", 29 | "Classical/cyclic_code.md", 30 | "Classical/quasi-cyclic_code.md", 31 | "Classical/GeneralizedReedSolomon.md", 32 | "Classical/ReedMuller.md", 33 | "Classical/new_codes_from_old.md", 34 | "Classical/product_codes.md", 35 | "Classical/misc_known_codes.md" 36 | ], 37 | "LDPC" => [ 38 | "LDPC/codes.md", 39 | "LDPC/Tanner_codes.md", 40 | "LDPC/analysis.md", 41 | "LDPC/channels.md", 42 | "LDPC/decoders.md" 43 | ], 44 | "Quantum" => [ 45 | "Quantum/quantum_code.md", 46 | "Quantum/product_codes.md", 47 | "Quantum/misc_known_codes.md", 48 | "Quantum/weight_reduction.md" 49 | ], 50 | "Misc" => [ 51 | "tilings.md", 52 | "trellis.md", 53 | "utils.md", 54 | "weight_dist.md" 55 | ], 56 | "References" => "references.md", 57 | "Index" => "theindex.md" 58 | # "Developer Documentation" => [ 59 | 60 | # ], 61 | ] 62 | ) 63 | 64 | deploydocs(repo = "github.com/esabo/CodingTheory.git", devbranch = "dev") 65 | -------------------------------------------------------------------------------- /docs/src/Classical/GeneralizedReedSolomon.md: -------------------------------------------------------------------------------- 1 | # Generalized Reed-Solomon Codes 2 | 3 | Generalized Reed-Solomon codes are a subtype of `LinearCode` and inherit its methods. 4 | 5 | ## Constructors 6 | 7 | ```@docs 8 | GeneralizedReedSolomonCode 9 | ``` 10 | 11 | ## Attributes 12 | 13 | ```@docs 14 | scalars 15 | ``` 16 | 17 | ```@docs 18 | dual_scalars 19 | ``` 20 | 21 | ```@docs 22 | evaluation_points 23 | ``` 24 | 25 | ## Methods 26 | 27 | -------------------------------------------------------------------------------- /docs/src/Classical/ReedMuller.md: -------------------------------------------------------------------------------- 1 | # Reed-Muller Codes 2 | 3 | Reed-Muller codes are a subtype of `LinearCode` and inherit its methods. 4 | 5 | ## Constructors 6 | The (binary) Reed-Muller family is generated using the recursive, $(u \mid u + v)$-form of the generator matrices. Different sources use different conventions for the base case generator matrix. If `alt` is `true`, the identity is used for the generator matrix for $\mathcal{RM}(1, 1)$; otherwise, $\begin{pmatrix} 1 & 1\\ 0 & 1\end{pmatrix}$ is used. 7 | 8 | ```@docs 9 | ReedMullerCode 10 | ``` 11 | 12 | ## Attributes 13 | 14 | ```@docs 15 | order 16 | ``` 17 | 18 | ```@docs 19 | number_of_variables 20 | ``` 21 | 22 | ## Methods 23 | -------------------------------------------------------------------------------- /docs/src/Classical/concatenation.md: -------------------------------------------------------------------------------- 1 | # Concatenated Codes 2 | ## Background 3 | There are at least three different meanings for the term "code concatenation": 4 | 1. The concatenation of a code over a finite field $E$ with another code over a subfield $F < E$. 5 | 2. The concatenation of two codes over the same field. 6 | 3. The generalized concatenation scheme of Blokh and Zyablov. 7 | In the original proposal, there is an $[n_o, k_o, d_o]_{q_o}$ *outer code* $\mathrm{C}_{\mathrm{out}}$ and an $[n_i, k_i, d_i]_{q_i}$ *inner code* $\mathrm{C}_{\mathrm{in}}$ such that $\mathbb{F}_{q_i} < \mathbb{F}_{q_o}$ and $k_i = [\mathbb{F}_{q_o} : \mathbb{F}_{q_i}]$. Each bit of the outer code is expanded to the subfield of the inner code (link). The inner code then encodes $k_i$ bits of the result at a time and the result is concatenated into a single vector. Since the dimension of the inner code is the degree of the field extension, each bit gets expanded into $k_i$ bits, and the inner code encodes each bit of the outer code individually. 8 | 9 | The second case is a slight generalization of this. Here, both codes are over the same field and the dimension of the inner code must divide the length of the outer code. As before, the input is first encoded with the outer code and then the inner code encodes $k_i$ bits at a time, concatenating the results. (Using the first case, $k_i$ would have to be 1.) 10 | 11 | 12 | 13 | 14 | 15 | ## Constructors 16 | The constructor for the first two cases examines the input codes and automatically selects the correct procedure. Additionally, skipping one extra step, the constructor will also except an outer code over an extension field for which the second method can then be applied to the inner code and an expanded version of the outer code. 17 | ```@docs 18 | concatenate 19 | ``` 20 | 21 | ## Attributes 22 | ```@docs 23 | inner_code 24 | ``` 25 | 26 | ```@docs 27 | outer_code 28 | ``` 29 | 30 | The concatenation type is `:expanded`, `:same`, or `:generalized` depending on which of the three methods above is used. 31 | ```@docs 32 | concatenation_type 33 | ``` 34 | If the concatenation required expansion, the basis and dual basis used for the expansion are returned via the following commands; otherwise, these are `missing`. 35 | ```@docs 36 | expansion_basis 37 | ``` 38 | 39 | ```@docs 40 | expansion_dual_basis 41 | ``` 42 | 43 | ## Methods 44 | This function accepts valid inputs to both the full concatenated code and the outer code. In the later case, it performs a two-step encoding as described above. 45 | ```@docs 46 | encode 47 | ``` 48 | 49 | [È. L. Blokh, V. V. Zyablov, “Coding of Generalized Concatenated Codes”, Probl. Peredachi Inf., 10:3 (1974), 45–50; Problems Inform. Transmission, 10:3 (1974), 218–222] -------------------------------------------------------------------------------- /docs/src/Classical/cyclic_code.md: -------------------------------------------------------------------------------- 1 | # Cyclic Codes 2 | 3 | Cyclic codes are a subtype of `LinearCode` and inherit its methods. For more information on how to use these functions, see the [Cyclic Codes Tutorial](@ref). 4 | 5 | ## Cyclotomic Cosets 6 | 7 | The following set of functions are useful for defining cyclic codes. 8 | 9 | ```@docs 10 | ord 11 | ``` 12 | 13 | ```@docs 14 | cyclotomic_coset 15 | ``` 16 | 17 | ```@docs 18 | all_cyclotomic_cosets 19 | ``` 20 | 21 | ```@docs 22 | complement_qcosets 23 | ``` 24 | 25 | ```@docs 26 | qcoset_pairings 27 | ``` 28 | 29 | ```@docs 30 | qcoset_table 31 | ``` 32 | 33 | ```@docs 34 | dual_qcosets 35 | ``` 36 | 37 | ## Constructors 38 | 39 | ```@docs 40 | CyclicCode 41 | ``` 42 | 43 | ```@docs 44 | BCHCode 45 | ``` 46 | 47 | ```@docs 48 | ReedSolomonCode 49 | ``` 50 | 51 | ```@docs 52 | QuadraticResidueCode 53 | ``` 54 | 55 | ## Attributes 56 | 57 | ```@docs 58 | splitting_field 59 | ``` 60 | 61 | ```@docs 62 | polynomial_ring 63 | ``` 64 | 65 | ```@docs 66 | primitive_root 67 | ``` 68 | 69 | ```@docs 70 | offset 71 | ``` 72 | 73 | ```@docs 74 | design_distance 75 | ``` 76 | 77 | ```@docs 78 | qcosets 79 | ``` 80 | 81 | ```@docs 82 | qcosets_reps 83 | ``` 84 | 85 | ```@docs 86 | zeros 87 | ``` 88 | 89 | ```@docs 90 | nonzeros 91 | ``` 92 | 93 | ```@docs 94 | generator_polynomial 95 | ``` 96 | 97 | ```@docs 98 | parity_check_polynomial 99 | ``` 100 | 101 | ```@docs 102 | idempotent 103 | ``` 104 | 105 | ```@docs 106 | BCH_bound 107 | ``` 108 | 109 | ```@docs 110 | is_narrowsense 111 | ``` 112 | 113 | ```@docs 114 | is_reversible 115 | ``` 116 | 117 | ```@docs 118 | CodingTheory.is_degenerate 119 | ``` 120 | 121 | ```@docs 122 | is_primitive 123 | ``` 124 | 125 | ```@docs 126 | is_antiprimitive 127 | ``` 128 | 129 | ## Methods 130 | 131 | ```@docs 132 | defining_set 133 | ``` 134 | 135 | ```@docs 136 | dual_defining_set 137 | ``` 138 | 139 | ```@docs 140 | CodingTheory.is_cyclic 141 | ``` 142 | 143 | ```@docs 144 | complement 145 | ``` 146 | 147 | ```@docs 148 | ∩ 149 | ``` 150 | 151 | ```@docs 152 | + 153 | ``` 154 | -------------------------------------------------------------------------------- /docs/src/Classical/linear_code.md: -------------------------------------------------------------------------------- 1 | # Linear Codes 2 | 3 | ## Constructors 4 | 5 | Generic linear codes may be constructed in two ways: via a matrix or via a vector space object. If a vector space is used, the basis of the vector space is used as a generator matrix for the code. If the optional parameter `parity` is set to true, the input is considered a parity-check matrix instead of a generator matrix. At the moment, no convention is used for the zero code and an error is thrown for such imputs. Zero rows are automatically removed from the input but zero columns are not. See the [Linear Codes Over Finite Fields](@ref) for usage examples. 6 | ```@docs 7 | LinearCode 8 | ``` 9 | 10 | ## Attributes 11 | 12 | Various getter/accessor functions are provided for accessing attributes about the codes. The user is strongly encouraged to use these functions and never to work with the underlying structs directly, as many functions rely on the information in the structs to be in a specific order and don't check if information has been updated. 13 | 14 | ```@docs 15 | field 16 | ``` 17 | 18 | ```@docs 19 | length 20 | ``` 21 | 22 | ```@docs 23 | dimension 24 | ``` 25 | 26 | ```@docs 27 | cardinality 28 | ``` 29 | 30 | ```@docs 31 | rate 32 | ``` 33 | 34 | See also: encode` 35 | 36 | If the linear code was created by passing in a generator (parity-check) matrix, then this matrix is stored in addition to the standard form. Note that this matrix is potentially over complete (has more rows than its rank). The standard form is returned when the optional parameter `stand_form` is set to true. Some code families are not constructed using these matrices. In these cases, the matrices are initially `missing` and are computed and cached when these functions are called for the first time. Direct access to the underlying structs is not recommended. 37 | ```@docs 38 | generator_matrix 39 | ``` 40 | 41 | ```@docs 42 | parity_check_matrix 43 | ``` 44 | 45 | ```@docs 46 | is_overcomplete 47 | ``` 48 | 49 | Recall that putting the matrix into standard form may require column permutations. If this is the case, the column permutation matrix $P$ such that $\mathrm{rowspace}(G) = \mathrm{rowspace}(G_\mathrm{stand} * P)$ may be accessed using the following function. If no column permutations are required, this returns `missing`. 50 | ```@docs 51 | standard_form_permutation 52 | ``` 53 | 54 | The minimum distance of some code families are known and are set during construction. The minimum distance is automatically computed in the constructor for codes which are deemed "small enough". Otherwise, the minimum distance is `missing`. Primitive bounds on the minimum distance are given by 55 | 56 | ```@docs 57 | minimum_distance_upper_bound 58 | ``` 59 | 60 | If the minimum distance of the code is known, the following functions return useful properties; otherwise they return `missing`. 61 | 62 | ```@docs 63 | relative_distance 64 | ``` 65 | 66 | ```@docs 67 | CodingTheory.genus 68 | ``` 69 | 70 | ```@docs 71 | is_MDS 72 | ``` 73 | 74 | ```@docs 75 | number_correctable_errors 76 | ``` 77 | 78 | The minimum distance and its bounds may be manually set as well. Nothing is done to check this value for correctness. 79 | ```@docs 80 | set_distance_lower_bound! 81 | ``` 82 | 83 | ```@docs 84 | set_minimum_distance! 85 | ``` 86 | 87 | See: `minimum_distance_lower_bound`, `set_distance_upper_bound!` 88 | 89 | ## Methods 90 | 91 | ```@docs 92 | Singleton_bound 93 | ``` 94 | 95 | ```@docs 96 | syndrome 97 | ``` 98 | 99 | ```@docs 100 | in 101 | ``` 102 | 103 | ```@docs 104 | ⊆ 105 | ``` 106 | 107 | ```@docs 108 | are_equivalent 109 | ``` 110 | 111 | ```@docs 112 | dual 113 | ``` 114 | 115 | ```@docs 116 | is_self_dual 117 | ``` 118 | 119 | ```@docs 120 | is_self_orthogonal 121 | ``` 122 | 123 | ```@docs 124 | is_dual_containing 125 | ``` 126 | 127 | ```@docs 128 | hull 129 | ``` 130 | 131 | ```@docs 132 | is_LCD 133 | ``` 134 | 135 | ```@docs 136 | Hermitian_dual 137 | ``` 138 | 139 | ```@docs 140 | is_Hermitian_self_dual 141 | ``` 142 | 143 | ```@docs 144 | is_Hermitian_self_orthogonal 145 | ``` 146 | 147 | ```@docs 148 | is_Hermitian_dual_containing 149 | ``` 150 | 151 | ```@docs 152 | Hermitian_hull 153 | ``` 154 | 155 | ```@docs 156 | is_Hermitian_LCD 157 | ``` 158 | 159 | ```@docs 160 | is_even 161 | ``` 162 | 163 | ```@docs 164 | is_doubly_even 165 | ``` 166 | 167 | ```@docs 168 | is_triply_even 169 | ``` 170 | 171 | ```@docs 172 | characteristic_polynomial 173 | ``` 174 | 175 | ```@docs 176 | VectorSpace 177 | ``` 178 | 179 | ```@docs 180 | words 181 | ``` 182 | -------------------------------------------------------------------------------- /docs/src/Classical/misc_known_codes.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous Known Linear Codes 2 | 3 | Some of the well-known codes are programmed into the library for convenience. 4 | 5 | ```@docs 6 | RepetitionCode 7 | ``` 8 | 9 | ```@docs 10 | Hexacode 11 | ``` 12 | 13 | ```@docs 14 | HammingCode 15 | ``` 16 | 17 | ```@docs 18 | TetraCode 19 | ``` 20 | 21 | ```@docs 22 | SimplexCode 23 | ``` 24 | 25 | ```@docs 26 | GolayCode 27 | ``` 28 | 29 | ```@docs 30 | ExtendedGolayCode 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/src/Classical/new_codes_from_old.md: -------------------------------------------------------------------------------- 1 | # Modifying Codes 2 | 3 | ## Constructors 4 | The first two constructors throw an error when one of the arguments is the zero code. 5 | ```@docs 6 | u_u_plus_v 7 | ``` 8 | 9 | Let `C1` be an $[n, k1, d1]$ and `C2` an $[n, k2, d2]$ linear code. This construction produces an $[3n, 2k1 + k2]$ linear code. For binary codes, $\mathrm{wt}(u + w \mid v + w \mid u + v + w) = 2 \mathrm{wt}(u \veebar v) - \mathrm{wt}(w) + 4s$, where $s = |\{i \mid u_i = v_i = 0, w_i = 1\}|$. 10 | ```@docs 11 | u_plus_w_v_plus_w_u_plus_v_plus_w 12 | ``` 13 | 14 | Let `C1` be an $[n, k, d]$, `C2` an $[n, k - l, d + e]$, and `C3` an $[m, l, e]$ linear code with `C2 ⊂ C1` be proper. Construction X creates a $[n + m, k, d + e]$ linear code. 15 | ```@docs 16 | construction_X 17 | ``` 18 | 19 | Let `C1` be an $[n, k1, d1]$, `C2` an $[n, k2, d2]$, `C3` an $[n, k3, d3]$, `C4` an $[n4, k2 - k1, d4]$, and `C5` an $[n5, k3 - k2, d5]$ linear code with `C1 ⊂ C2 ⊂ C3`. Construction X3 creates an $[n + n4 + n5, k3, d]$ linear code with $d \geq \min\{d1, d2 + d4, d3 + d5\}$. 20 | ```@docs 21 | construction_X3 22 | ``` 23 | 24 | The direct sum code has generator matrix `G1 ⊕ G2` and parity-check matrix `H1 ⊕ H2`. 25 | 26 | ```@docs 27 | ⊕ 28 | ``` 29 | 30 | The generator matrix of the (direct) product code is the kronecker product of the generator matrices of the inputs. 31 | 32 | ```@docs 33 | × 34 | ``` 35 | 36 | The parity-check matrix of the tensor product code is the kronecker product of the parity-check matrices of the inputs. 37 | 38 | There is some debate on how to define this product. This is known to often be the full ambient space. 39 | ```@docs 40 | entrywise_product_code 41 | ``` 42 | 43 | ```@docs 44 | / 45 | ``` 46 | 47 | `juxtaposition` is representation dependent and therefore works on the potentially over-complete generator matrices, not on the standard form. 48 | ```@docs 49 | juxtaposition 50 | ``` 51 | 52 | ## Methods 53 | 54 | If `C` is a quasi-cyclic code, `permute_code` returns a `LinearCode` object. See: `permute_code` 55 | 56 | The most common way to extend a code is to add an extra column to the generator matrix whose values make the sum of the rows zero. This is called an even extension and is the default for `extend(C)`. Alternatively, this new column may be inserted at any index `c` in the matrix, e.g. `extend(C, c)`. In the most general case, one may provide a vector `a` and define the values of the new column to be `-a` dot the row. The standard definition is clearly just the special case that `a` is the all-ones vector. 57 | ```@docs 58 | extend 59 | ``` 60 | 61 | Puncturing deletes columns from the generator matrix and then removes any potentially resulting zero rows. 62 | ```@docs 63 | puncture 64 | ``` 65 | 66 | Expurgating deletes rows from the generator matrix and then removes any potentially resulting zero columns. This function works directly on the potentially over-complete generator matrix and not on the standard form. 67 | ```@docs 68 | expurgate 69 | ``` 70 | 71 | Shortening is expurgating followed by puncturing. This implementation uses the theorem that the dual of code shortened on `L` is equal to the puncture of the dual code on `L`, i.e., `dual(puncture(dual(C), L))`. 72 | ```@docs 73 | shorten 74 | ``` 75 | 76 | Augmentation vertically joins the matrix `M` to the bottom of the generator matrix of `C`. This function works directly on the potentially over-complete generator matrix and not on the standard form. 77 | ```@docs 78 | augment 79 | ``` 80 | 81 | Lengthening augments the all 1's row and then extends. 82 | ```@docs 83 | lengthen 84 | ``` 85 | 86 | ```@docs 87 | subcode 88 | ``` 89 | 90 | This function arguments generators of `C1 / C2` to `C2` until the desired dimenion is reached. 91 | ```@docs 92 | subcode_of_dimension_between_codes 93 | ``` 94 | 95 | ```@docs 96 | expanded_code 97 | ``` 98 | 99 | The subfield subcode is computed directly via an expansion, whereas the trace code is computed using Delsarte's theorem. 100 | ```@docs 101 | subfield_subcode 102 | ``` 103 | 104 | ```@docs 105 | trace_code 106 | ``` 107 | 108 | !!! warning "Experimental" 109 | The next two functions need significantly more testing, but appear to work so far. 110 | 111 | ```@docs 112 | even_subcode 113 | ``` 114 | 115 | ```@docs 116 | doubly_even_subcode 117 | ``` 118 | 119 | ## Weight reduction 120 | 121 | See the weight reduction tutorial for a more detailed explanation of this function. 122 | 123 | ```@docs 124 | weight_reduction 125 | ``` 126 | -------------------------------------------------------------------------------- /docs/src/Classical/product_codes.md: -------------------------------------------------------------------------------- 1 | # Product Codes 2 | 3 | ## Constructors 4 | 5 | ```@docs 6 | MatrixProductCode 7 | ``` 8 | 9 | ```@docs 10 | 11 | ``` 12 | 13 | product_code 14 | tensor_product_code 15 | 16 | 17 | ## Attributes 18 | 19 | MPC.C 20 | MPC.A 21 | 22 | ## Methods 23 | -------------------------------------------------------------------------------- /docs/src/Classical/quasi-cyclic_code.md: -------------------------------------------------------------------------------- 1 | # Quasi-Cyclic Codes 2 | 3 | Quasi-cyclic codes are a subtype of `LinearCode` and inherit its methods. While quasi-cyclic codes may be seen as generalizations of cyclic codes, here they are treated as independent topics. 4 | 5 | ## Constructors 6 | 7 | ```@docs 8 | QuasiCyclicCode 9 | ``` 10 | 11 | ## Attributes 12 | 13 | ```@docs 14 | CodingTheory.index 15 | ``` 16 | 17 | ```@docs 18 | expansion_factor 19 | ``` 20 | 21 | ```@docs 22 | is_single_generator 23 | ``` 24 | 25 | ```@docs 26 | polynomial_matrix 27 | ``` 28 | 29 | ```@docs 30 | polynomial_matrix_type 31 | ``` 32 | 33 | The type parameter is either `:G` or `:H`, specifying whether the polynomial matrix represents the generator or parity-check matrix. 34 | ```@docs 35 | type 36 | ``` 37 | 38 | ## Methods 39 | 40 | The following are not computed and stored at the time of construction and must be computed by using these methods. 41 | 42 | ```@docs 43 | weight_matrix 44 | ``` 45 | 46 | ```@docs 47 | noncirculant_generator_matrix 48 | ``` 49 | 50 | ```@docs 51 | noncirculant_parity_check_matrix 52 | ``` 53 | 54 | ```@docs 55 | CodingTheory.generators 56 | ``` 57 | 58 | ```@docs 59 | circulants 60 | ``` 61 | -------------------------------------------------------------------------------- /docs/src/LDPC/Tanner_codes.md: -------------------------------------------------------------------------------- 1 | # Generalized LDPC/Tanner Codes 2 | 3 | ## Constructors 4 | 5 | ```@docs 6 | Tanner_code 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/src/LDPC/analysis.md: -------------------------------------------------------------------------------- 1 | # LDPC Ensemble Analysis 2 | 3 | ## Degree Distributions 4 | 5 | ```@docs 6 | check_concentrated_degree_distribution 7 | ``` 8 | 9 | ```@docs 10 | optimal_lambda 11 | ``` 12 | 13 | ```@docs 14 | optimal_rho 15 | ``` 16 | 17 | ```@docs 18 | optimal_lambda_and_rho 19 | ``` 20 | 21 | ```@docs 22 | optimal_threshold 23 | ``` 24 | 25 | ## Density Evolution 26 | ```@docs 27 | density_evolution 28 | ``` 29 | 30 | 31 | # Misc 32 | 33 | ```@docs 34 | multiplicative_gap_lower_bound 35 | ``` 36 | 37 | ```@docs 38 | density_lower_bound 39 | ``` 40 | 41 | See also: `plot_EXIT_chart`, `multiplicative_gap` 42 | 43 | ## Comments 44 | 45 | (these are just temporary notes) 46 | 47 | We have functions for the following: 48 | 49 | * `optimal_lambda` (`optimal_rho`): Given $\lambda$ (or $\rho$) and a threshold $\epsilon^{BP}$ (or target rate), find the distribution $\rho$ (or $\lambda$) with at least that threshold maximizing design rate (with at least that target rate maximizing threshold). 50 | * `optimal_lambda_and_rho`: Given a target rate (threshold), find distributions $\lambda$ and $\rho$ that maximize threshold (rate). 51 | * `optimal_threshold`: Given distributions $\lambda$ and $\rho$, compute the threshold 52 | 53 | Example of using `optimal_lambda_and_rho` and `optimal_threshold`: 54 | 55 | ```julia-repl 56 | julia> λ, ρ, r, ε = optimal_lambda_and_rho(8, 6, 0.4, :ε); 0.4 - optimal_threshold(λ, ρ) 57 | 2.849104958069226e-7 58 | 59 | julia> λ, ρ, r, ε = optimal_lambda_and_rho(8, 6, 0.4, :ε, Δλ = 0.0001); 0.4 - optimal_threshold(λ, ρ) 60 | 1.0256726462598564e-7 61 | 62 | julia> λ, ρ, r, ε = optimal_lambda_and_rho(8, 6, 0.4, :ε, Δλ = 0.0001); 0.4 - optimal_threshold(λ, ρ, Δ = BigFloat("1e-7")) 63 | 1.025672727266482436145720743991009459178786186514042575060182100591178904349331e-07 64 | 65 | julia> λ, ρ, r, ε = optimal_lambda_and_rho(8, 6, 0.4, :ε, Δλ = 0.0001, Δρ = 0.001); 0.4 - optimal_threshold(λ, ρ, Δ = BigFloat("1e-7")) 66 | 1.025672727266482436145720743991009459178786186514042575060182100591178904349331e-07 67 | ``` 68 | 69 | This shows the accuracy of these functions and how to tune that accuracy. `optimal_lambda` and `optimal_rho` also have an optional keyword parameter `Δ` for tuning accuracy. Note that using `BigFloat` only behaves properly for `optimal_threshold`, any other `Δ` parameter should be `Float64`. Even for `optimal_threshold`, it's best to just use `Float64` unless you are specifically testing numerical stability. 70 | -------------------------------------------------------------------------------- /docs/src/LDPC/channels.md: -------------------------------------------------------------------------------- 1 | # LDPC Noise Channels 2 | 3 | ## Constructors 4 | 5 | ```@docs 6 | BinaryErasureChannel 7 | ``` 8 | 9 | ```@docs 10 | BinarySymmetricChannel 11 | ``` 12 | 13 | ```@docs 14 | BAWGNChannel 15 | ``` 16 | 17 | ## Attributes 18 | 19 | ```@docs 20 | erasure_probability 21 | ``` 22 | 23 | ```@docs 24 | crossover_probability 25 | ``` 26 | 27 | ```@docs 28 | standard_deviation 29 | ``` 30 | 31 | ```@docs 32 | variance 33 | ``` 34 | 35 | ## Methods 36 | 37 | ```@docs 38 | capacity 39 | ``` 40 | -------------------------------------------------------------------------------- /docs/src/LDPC/codes.md: -------------------------------------------------------------------------------- 1 | # LDPC Codes 2 | 3 | ## Constructors 4 | An LDPC code is defined by a specific choice of a parity-check matrix for a code. Different parity-check matrices for the same linear code produce different LDPC codes. As such, the `LDPCCode` constructor does not accept a code, but rather a matrix. 5 | ```@docs 6 | LDPCCode 7 | ``` 8 | 9 | ``` 10 | julia> H = matrix(GF(2), 6, 9, [ 11 | 1 0 1 0 1 0 0 0 1; 12 | 0 1 1 0 1 1 1 0 0; 13 | 0 0 0 1 0 1 0 0 0; 14 | 0 0 0 1 1 0 1 1 0; 15 | 0 1 1 1 0 1 0 0 1; 16 | 1 1 0 0 0 0 1 1 1]); 17 | 18 | julia> L = LDPCCode(H) 19 | [9, 3, 3]_2 irregular 5-limited LDPC code with density 0.46296296296296297. 20 | 21 | Variable degree polynomial: 22 | 21//25*x^2 + 4//25*x 23 | Check degree polynomial: 24 | 3//5*x^4 + 8//25*x^3 + 2//25*x 25 | Parity-check matrix: 6 × 9 26 | 1 0 1 0 1 0 0 0 1 27 | 0 1 1 0 1 1 1 0 0 28 | 0 0 0 1 0 1 0 0 0 29 | 0 0 0 1 1 0 1 1 0 30 | 0 1 1 1 0 1 0 0 1 31 | 1 1 0 0 0 0 1 1 1 32 | ``` 33 | 34 | Random regular LDPC codes maybe be constructed via `regular_LDPC_code` and `irregular_LDPC_code` 35 | 36 | ## Attributes 37 | The polynomials ``\lambda(x)`` and ``\rho(x)`` as well as the degrees of each variable and check nodes are computed upon construction. 38 | ```@docs 39 | variable_degree_polynomial 40 | ``` 41 | 42 | ```@docs 43 | check_degree_polynomial 44 | ``` 45 | 46 | ```@docs 47 | variable_degree_distribution 48 | ``` 49 | 50 | ```@docs 51 | check_degree_distribution 52 | ``` 53 | 54 | ```@docs 55 | degree_distributions 56 | ``` 57 | 58 | A bar graph of the degree distributions is available 59 | ```@docs 60 | degree_distributions_plot 61 | ``` 62 | 63 | For convenience, the maximum degrees are also stored. 64 | ```@docs 65 | column_bound 66 | ``` 67 | 68 | ```@docs 69 | row_bound 70 | ``` 71 | 72 | ```@docs 73 | column_row_bounds 74 | ``` 75 | 76 | ```@docs 77 | limited 78 | ``` 79 | 80 | ```@docs 81 | CodingTheory.density 82 | ``` 83 | 84 | ```@docs 85 | is_regular 86 | ``` 87 | 88 | The Tanner graph corresponding to the parity-matrix defining the LDPC code can be generated as a `SimpleDiGraph` and visually in a `Figure` object. 89 | ```@docs 90 | Tanner_graph 91 | ``` 92 | 93 | ```@docs 94 | Tanner_graph_plot 95 | ``` 96 | 97 | ## Methods 98 | Occassionally useful for small examples, the following function produces a `Figure` of the Tanner graph unrolled to a given level. 99 | ```@docs 100 | computation_graph 101 | ``` 102 | 103 | ```@docs 104 | girth 105 | ``` 106 | 107 | To count or explicitly enumerate the short cycles of the Tanner graph, use 108 | ```@docs 109 | count_short_cycles 110 | ``` 111 | 112 | See also: `shortest_cycles` 113 | 114 | Various information about the ACE value of cycles in the Tanner graph may be computed with the following functions. See: `ACE_spectrum`, `shortest_cycle_ACE`, `ACE_distribution`, `average_ACE_distribution`, `median_ACE_distribution`, `mode_ACE_distribution` 115 | 116 | ## Greedy Construction Algorithms 117 | -------------------------------------------------------------------------------- /docs/src/LDPC/decoders.md: -------------------------------------------------------------------------------- 1 | # Decoding LDPC Codes 2 | 3 | ## Message Passing 4 | ```@docs 5 | Gallager_A 6 | ``` 7 | 8 | ```@docs 9 | Gallager_B 10 | ``` 11 | 12 | ```@docs 13 | sum_product 14 | ``` 15 | 16 | ```@docs 17 | sum_product_box_plus 18 | ``` 19 | 20 | ```@docs 21 | min_sum 22 | ``` 23 | 24 | See also: `find_MP_schedule` 25 | 26 | ## Linear Programming 27 | 28 | ```@docs 29 | LP_decoder_LDPC 30 | ``` 31 | 32 | ## Simulations 33 | 34 | See: `decoder_simulation` -------------------------------------------------------------------------------- /docs/src/Quantum/misc_known_codes.md: -------------------------------------------------------------------------------- 1 | # Miscellaneous Known Stabilizer Codes 2 | 3 | ```@autodocs 4 | Modules = [CodingTheory] 5 | Pages = ["miscknownquantumcodes.jl"] 6 | Private = false 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/src/Quantum/product_codes.md: -------------------------------------------------------------------------------- 1 | # Product Codes 2 | 3 | - [Hypergraph product](https://errorcorrectionzoo.org/c/hypergraph_product): [Tillich_2014](@cite) 4 | - [Generalized Shor](https://errorcorrectionzoo.org/c/generalized_shor): [bacon2006quantum](@cite) 5 | - Hyperbicycle: [pryadko2013quantum](@cite) 6 | - [Generealized bicycle](https://errorcorrectionzoo.org/c/generalized_bicycle): [pryadko2013quantum](@cite), [Kovalev_2013](@cite), [panteleev2021degenerate](@cite) 7 | - Generalized hypergraph product: [panteleev2021degenerate](@cite) 8 | - Bias-tailored lifted product: [roffe2023bias](@cite) 9 | - Bivariate bicycle: [wang2024coprime](@cite) 10 | - Coprime bivarate bicycle: [wang2024coprime](@cite) 11 | 12 | 13 | ```@autodocs 14 | Modules = [CodingTheory] 15 | Pages = ["quantumproductcodes.jl"] 16 | Private = false 17 | ``` 18 | -------------------------------------------------------------------------------- /docs/src/Quantum/quantum_code.md: -------------------------------------------------------------------------------- 1 | * `char_vec`: a length `2n` vector with elements in the `Z/(2p)` if 2 | `characteristic(field(C1))` is 2 and `Z/(p)` otherwise. The first `n` elements 3 | specify the exponents of the `X` phases and second `n` the exponents of the 4 | `Z` phases; a missing argument will be set to the all-zero vector 5 | 6 | # Notes 7 | * A `+1` phase should be entered as `0` since the character vector stores the 8 | exponents. 9 | * Stabilizer signs are automatically computed given the character vector. 10 | * The orthogonality of the stabilizers are automatically checked and will error 11 | upon failure. 12 | 13 | assumed to be in 14 | symplectic form over the base field. 15 | 16 | * This is intended to be a simple function wrapper for `typeof(S)` since the 17 | constructor for `SubsystemCode` automatically returns a `SubsystemCodeCSS` if possible. 18 | Manually changing the elements of the struct `S` without using the helper 19 | functions provided here is therefore not recommended. 20 | 21 | # Stabilizer Codes 22 | 23 | ```@autodocs 24 | Modules = [CodingTheory] 25 | Pages = ["stabilizercode.jl"] 26 | Private = false 27 | ``` 28 | 29 | # Subsystem Codes 30 | 31 | ```@autodocs 32 | Modules = [CodingTheory] 33 | Pages = ["subsystemcode.jl"] 34 | Private = false 35 | ``` 36 | 37 | # Graph States 38 | 39 | ```@autodocs 40 | Modules = [CodingTheory] 41 | Pages = ["graphstate.jl"] 42 | Private = false 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/src/Quantum/weight_reduction.md: -------------------------------------------------------------------------------- 1 | # Weight Reduction 2 | 3 | See the weight reduction tutorial for a more detailed explanation of this function. 4 | 5 | ```@docs 6 | copying 7 | ``` 8 | 9 | ```@docs 10 | copying_as_coning 11 | ``` 12 | 13 | ```@docs 14 | gauging 15 | ``` 16 | 17 | ```@docs 18 | gauging_as_coning 19 | ``` 20 | 21 | ```@docs 22 | thickening_and_choose_heights 23 | ``` 24 | 25 | ```@docs 26 | coning 27 | ``` 28 | 29 | ```@docs 30 | quantum_weight_reduction 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/src/Tutorials/min_dist.md: -------------------------------------------------------------------------------- 1 | # Minimum Distance Solvers 2 | 3 | There are numerous 4 | most work by repeatedly generating codewords, some randomly, some deterministically and systematically 5 | 6 | # Background 7 | ## Classical 8 | Recall that for linear codes the minimum distance is equal to the minimum weight. It is therefore always valid to compute every element of the code one-by-one by constructing all possible combinations of the generators of the generator matrix, computing their weights, and then returning the minimum. This takes exponential time. Vardy showed that the computation of the minimum distance is NP-Hard and the corresponding decision problem is NP-Complete \cite{vardy1997intractability}, so we can't expect a polynomial-time algorithm but we can do better than brute force. There are two main minimum-weight algorithms in the literature: the Brouwer-Zimmermann (BZ) algorithm and Leon's algorithm \cite{leon1988probabilistic}. The latter is probabilistic and returns the minimum weight with high confidence for a binary linear code. 9 | 10 | Consider an $[n, k, d]$ code. The BZ algorithm (roughly) works by enumerating every length-$k$ vector of weight $w$ for $1 \leq w \leq k$. After all vectors of a given weight are processed, a lower bound on the distance is increased. The algorithm also keeps an upper bound equal to the smallest weight codeword it has found so far. The algorithm terminates when the lower bound meets the upper bound. Usually this implies that a codeword of weight equal to the upper bound has been found. However, this library maintains an internal system of bounds on the distance for each code. Hence, it is possible that an upper bound has been previously computed by another method which had not yet been attained by a codeword during the BZ algorithm. Codewords acheiving the distance (or bound) are always returned with the weight whenever possible; otherwise they return the weight and `missing`. 11 | 12 | In contrast to BZ's deterministic and systematic approach, some algorithms repeatedly generate random codewords. The lowest-weight codeword generated provides an upper bound on the distance. If the sampling is done well, a large number of iterations can provide a close bound on the distance with high probabiliity. This technique cannot provide a lower bound, so there is no way to terminate early or guarantee the answer is correct without obtaining a bound by other means. In particular, this approach can be combined with the BZ aglorithm to try to generate a codeword or lower an upper bound given BZ's lower bound. Bounds are automatically updated internally, although this may not be possible if a method is terminated prematurely by the user. Bounds from a previous run will be used in any subesquent runs. 13 | 14 | ## Quantum 15 | The situation is much different in the quantum case. Recall that the minimum distance is given by the minimum weight of a non-trivial logical operator \eqref{dQECC}. This generally has nothing to do with the minimum distance of the corresponding stabilizer code considered as a classical, additive code. Note that $\mathcal{C}_{\mathcal{P}_n}(\mathcal{S}) \backslash \mathcal{S}$ is a set-difference of size $p^{n + k} - p^{n - k}$ and not a quotient module of size $p^{2k}$. Constructing a basis for the centralizer is an easy row reduction but enumerating its elements are not as easy as before. The brute-force method always works but the concept of an information set is now more complicated since one cannot row reduce down to the identity. White and Grassl tackled this in \cite{white2006enumeration, white2006new} where they map the additive code onto a linear code in a way that the minimum of distance of the additive code may be implied from that of the linear code. This mapping increases the parameters from $n$ to $3n$ and $d$ to $2d$, dramatically increasing the overall runtime of the BZ algorithm. Further complicating the quantum case, once a minimal weight vector is detected, one must check to see if it is an element of $S$. 16 | 17 | To see how classical intuition can be harmful here, recall that the rotated surface code of distance $d$ has many weight-two elements. The Steane code also has minimum distance three despite having all elements of weight four. These apparent inconsistencies go back to the fact that stabilizer codes are specified by their parity-check matrices but the distances are determined by the dual. In general, low-weight elements are necessary for quantum codes to perform well against certain types of errors \cite{hu2021mitigating}. 18 | 19 | often faster to bound dx/dz and then take min 20 | 21 | # Methods 22 | ## Classical 23 | 24 | 25 | Note that it is sometimes cheaper to compute the weight enumerator of the dual code then use the MacWilliams identities to compute the desired distance. The method `minimum_distance(C)` attempts to automatically determine which algorithm... 26 | 27 | 28 | use subfield subcode to bound 29 | 30 | ## Quantum 31 | 32 | exact algorithms 33 | lower bounds w/ Gray code 34 | upper bounds w/ random information sets 35 | native QDistRnd but also interface to original GAP version 36 | graph states 37 | -------------------------------------------------------------------------------- /docs/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esabo/CodingTheory/924bdf3d8be9822a7a9a49477c3deabda8d2e7be/docs/src/assets/logo.png -------------------------------------------------------------------------------- /docs/src/index.md: -------------------------------------------------------------------------------- 1 | # ErrorCorrection.jl 2 | 3 | Welcome to `CodingTheory.jl` (soon to be renamed `ErrorCorrection.jl`), a coding theory library for Julia. The package is built on the [Oscar framework](https://docs.oscar-system.org/dev/), while using as much native Julia as possible. The library supports classical, modern (LDPC), and quantum coding theory. 4 | 5 | The main developers so far are 6 | * [esabo](https://github.com/esabo) 7 | * [benide](https://github.com/benide) 8 | We are also grateful for contributions from 9 | * [MikeVasmer](https://github.com/MikeVasmer) 10 | * [kalmarek](https://github.com/kalmarek) 11 | and various members of the Oscar project, especially [thofma](https://github.com/thofma) for helping get the initial package off the ground. 12 | 13 | If you are interested in contributing to the library, see the Developer Documentation and feel free to contact us on the #codingtheory channel of the Julia Slack workspace. 14 | 15 | ## Structure 16 | 17 | The following constants are refernced throughout this documentation 18 | ``` 19 | const CTFieldTypes = FinField 20 | const CTFieldElem = FinFieldElem 21 | const CTMatrixTypes = MatElem{<:CTFieldElem} 22 | const CTPolyRing = PolyRing{<:CTFieldElem} 23 | const CTPolyRingElem = PolyRingElem{<:CTFieldElem} 24 | const CTGroupAlgebra = GroupAlgebraElem{fpFieldElem, GroupAlgebra{fpFieldElem, FinGenAbGroup, FinGenAbGroupElem}} 25 | const CTChainComplex = Union{ComplexOfMorphisms{AbstractAlgebra.FPModule{fpFieldElem}}} 26 | ``` 27 | REDO GIVEN NEW TYPES: 28 | A code is defined by matrices of type `CTMatrixTypes`, which include `fpMatrix` and `fqPolyRepMatrix`. The former have base ring `GF(p)` and the latter `GF(p, l, :α)`. Due to the way finite fields are typically represented in a computer, matrices over `GF(p, l, :α)` are *considerably* larger and slower than those over `GF(p)`. This in turn *considerably* limits the length of the codes able to be handled by the library when using this type. Therefore, it is *strongly* encouraged to utilize the field constructor `GF(p)` instead of `GF(p, 1)` when building codes over $$\mathbb{F}_p$$. 29 | 30 | It is recommended to avoid `deepcopy(C)` and instead use `copy(C)` to create a copy of the code `C`. The use of `deepcopy` on a code object will create a new Galois field object in the struct while the matrices in the struct will still be defined over the previous Galois field. Although these two Galois fields are mathematically identical, functions in the Oscar framework consider them to be different. 31 | 32 | The various code families in the library are mathematically related in complex patterns which are unable to be faithfully represented in Julia's linear type hierarchy. As such, it is not recommended to rely on `typeof` to discern properties of codes. For quantum codes where this is more useful, the traits `HasLogicals/HasNoLogicals`, `HasGauges/HasNoGauges`, and `IsCSS/IsNotCSS` have been setup to detect graph states ($k = 0$), subsystem codes, and CSS codes, respectively. 33 | 34 | It is often desirable to build a code with a specific matrix representation. While properties such as standard forms and correct parameters are computed and used throughout in the background, the original matrix (matrices) used to create the code is always kept and displayed. This is of particular importance in LDPC codes, where one wants a specific representation of the code, and quantum codes, where one often prefers an over complete set of stabilizers. The user should not use matrix dimensions to determine code parameters or code parameters to iterate over matrices. Use the function `is_overcomplete` to determine if any of the matrices representing the code are over complete, i.e., have more rows than its rank. 35 | 36 | ## Suppressing The Oscar Banner 37 | 38 | The Oscar banner will display be default when calling `using CodingTheory`. This can be suppressed by running Julia with the `-q` flag: `julia -q`. Note that this will also suppress the Julia banner. 39 | -------------------------------------------------------------------------------- /docs/src/references.md: -------------------------------------------------------------------------------- 1 | ```@raw html 2 | 15 | ``` 16 | 17 | # References 18 | 19 | ```@bibliography 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/src/theindex.md: -------------------------------------------------------------------------------- 1 | ```@index 2 | ``` 3 | -------------------------------------------------------------------------------- /docs/src/tilings.md: -------------------------------------------------------------------------------- 1 | # Tilings 2 | 3 | ```@autodocs 4 | Modules = [CodingTheory] 5 | Pages = ["tilings.jl"] 6 | Private = false 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/src/trellis.md: -------------------------------------------------------------------------------- 1 | # Trellises 2 | 3 | ```@autodocs 4 | Modules = [CodingTheory] 5 | Pages = ["trellis.jl"] 6 | Private = false 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/src/utils.md: -------------------------------------------------------------------------------- 1 | # Utilies 2 | 3 | ```@autodocs 4 | Modules = [CodingTheory] 5 | Pages = ["utils.jl"] 6 | Private = false 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/src/weight_dist.md: -------------------------------------------------------------------------------- 1 | # Weight Enumerators, Distributions, And Minimum Distances 2 | 3 | For more information on the algorithms contained in this function see 4 | "Enumeration Based Algorithms" by Gregory White. 5 | 6 | enumeration-based algorithms using the binary, reflected Gray code such as Brouwer-Zimmermann 7 | and adaptions 8 | 9 | notational used for complete and Hamming weight enumerators 10 | 11 | ```@autodocs 12 | Modules = [CodingTheory] 13 | Pages = ["weight_dist.jl"] 14 | Private = false 15 | ``` 16 | -------------------------------------------------------------------------------- /ext/JLD2Ext/JLD2Ext.jl: -------------------------------------------------------------------------------- 1 | module JLD2Ext 2 | 3 | import CodingTheory 4 | import CodingTheory: TriangularColorCode488, TriangularColorCode666, StabilizerCode, set_logicals!, set_minimum_distance! #PlanarSurfaceCode3D, PlanarSurfaceCode3D_X, ToricCode3D, 5 | import JLD2 6 | import JLD2: @load 7 | import Oscar: GF, matrix 8 | 9 | include("Quantum/misc_known_codes.jl") 10 | 11 | end 12 | -------------------------------------------------------------------------------- /ext/JuMPExt/JuMPExt.jl: -------------------------------------------------------------------------------- 1 | module JuMPExt 2 | 3 | import CodingTheory 4 | import CodingTheory: optimal_lambda, optimal_rho, optimal_lambda_and_rho, LP_decoder_LDPC, AbstractLinearCode, BinarySymmetricChannel 5 | import JuMP 6 | import JuMP: @variable, @constraint, @objective 7 | import GLPK 8 | import Oscar 9 | 10 | include("LDPC/decoders.jl") 11 | include("LDPC/analysis.jl") 12 | 13 | end 14 | -------------------------------------------------------------------------------- /ext/JuMPExt/LDPC/decoders.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 - 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # LP Decoders 9 | ############################# 10 | 11 | function _init_LP_decoder_LDPC(H::Union{CodingTheory.CTMatrixTypes, AbstractMatrix{<:Number}}) 12 | check_adj_list, _ = CodingTheory._node_adjacencies(H) 13 | subsets = Vector{Vector{Vector{Int}}}() 14 | nr, nc = size(H) 15 | hasi = [[Vector{Int}() for _ in 1:nc] for _ in 1:nr] 16 | wmap = zeros(Int, nr) 17 | curr = 1 18 | for (j, cn) in enumerate(check_adj_list) 19 | wmap[j] = curr 20 | inner_subsets = Vector{Vector{Int}}() 21 | for S in powerset(cn) 22 | if iseven(length(S)) # && !isempty(S) 23 | push!(inner_subsets, S) 24 | for i in S 25 | push!(hasi[j][i], curr) 26 | end 27 | curr += 1 28 | end 29 | end 30 | push!(subsets, inner_subsets) 31 | end 32 | 33 | model = Model(GLPK.Optimizer) 34 | @variable(model, 0 <= f[1:nc] <= 1) 35 | @variable(model, 0 <= w[1:curr - 1] <= 1) 36 | for i in 1:nr 37 | if i != nr 38 | @constraint(model, sum(w[wmap[i]:wmap[i + 1] - 1]) == 1) 39 | else 40 | @constraint(model, sum(w[wmap[i]:end]) == 1) 41 | end 42 | end 43 | for j in 1:nr 44 | for i in 1:nc 45 | if !isempty(hasi[j][i]) 46 | @constraint(model, f[i] == sum(w[hasi[j][i]])) 47 | end 48 | end 49 | end 50 | @objective(model, Min, sum(0 * f[i] for i in 1:nc)) 51 | return model 52 | end 53 | _init_LP_decoder_LDPC(C::AbstractLinearCode) = _init_LP_decoder_LDPC(parity_check_matrix(C)) 54 | 55 | function _LP_decoder_LDPC(model::JuMP.Model, v::Union{CodingTheory.CTMatrixTypes, 56 | Vector{<:Integer}}, Ch::BinarySymmetricChannel) 57 | 58 | γ = CodingTheory._channel_init_BSC(isa(v, Vector) ? v : Int.(data.(v))[:], Ch.param) 59 | @objective(model, Min, dot(γ, model[:f])) 60 | optimize!(model) 61 | termination_status(model) == MOI.INFEASIBLE && throw(DomainError("No solution exists")) 62 | @assert termination_status(model) == MOI.OPTIMAL "Didn't find an optimal point" 63 | w = value.(model[:f]) 64 | # all(isinteger(x) for x in w) || @warn "Solution is not integral" 65 | return w 66 | end 67 | 68 | function CodingTheory.LP_decoder_LDPC(H::Union{CodingTheory.CTMatrixTypes, AbstractMatrix{<:Number}}, v::Union{CodingTheory.CTMatrixTypes, Vector{<:Integer}}, Ch::BinarySymmetricChannel) 69 | 70 | model = _init_LP_decoder_LDPC(H) 71 | return _LP_decoder_LDPC(model, v, Ch) 72 | end 73 | CodingTheory.LP_decoder_LDPC(C::AbstractLinearCode, v::Union{CodingTheory.CTMatrixTypes, 74 | Vector{<:Integer}}, Ch::BinarySymmetricChannel) = CodingTheory.LP_decoder_LDPC( 75 | parity_check_matrix(C), v, Ch) 76 | -------------------------------------------------------------------------------- /ext/MakieExt/Classical/Tanner.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 - 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | """ 8 | $TYPEDSIGNATURES 9 | 10 | Return the Tanner graph of the matrix `H` as a `Figure` object. 11 | 12 | # Note 13 | - Run `using Makie` to activate this extension. 14 | """ 15 | function CodingTheory.Tanner_graph_plot(H::Union{CodingTheory.CTMatrixTypes, Matrix{Int}}) 16 | # convert H to A 17 | M = CodingTheory._Flint_matrix_to_Julia_int_matrix(H) 18 | nr, nc = size(M) 19 | A = zeros(Int, nr + nc, nr + nc) 20 | # put in top right corner in order to get parents, children working 21 | A[1:nc, nc + 1:end] = transpose(M) 22 | 23 | fig = CairoMakie.Figure(); 24 | ax = CairoMakie.Axis(fig[1, 1], yreversed = true, xautolimitmargin = (0.15, 0.20), 25 | yautolimitmargin = (0.15, 0.20)) 26 | CairoMakie.hidespines!(ax) 27 | CairoMakie.hidedecorations!(ax) 28 | 29 | left_x, left_y = zeros(nc), 1.:nc 30 | right_x, right_y = ones(nr) * nr, range(1, nc, nr) 31 | x = vcat(left_x, right_x) 32 | y = vcat(left_y, right_y) 33 | points = CairoMakie.Point2f.(zip(x, y)) 34 | cols = (:aqua, :red, :orange, :green, :blue, :purple) 35 | 36 | G = Grphs.SimpleDiGraph(A) 37 | parents = [Grphs.inneighbors(G, i) for i in Grphs.vertices(G)] 38 | children = findall(x -> length(x) > 0, parents) 39 | 40 | for (i, v) in enumerate(children) 41 | for node in parents[v] 42 | CairoMakie.lines!([CairoMakie.Point2f(x[[node, v]])...], [CairoMakie.Point2f(y[[node, 43 | v]])...], color = cols[i % 6 + 1], linewidth = 5) 44 | end 45 | CairoMakie.text!(points[v], text = L"c_{%$i}", offset = (20, -15)) 46 | end 47 | 48 | for (i, point) in enumerate(points[1:nc]) 49 | CairoMakie.scatter!(point, color = :black, marker = :circle, markersize = 25) 50 | CairoMakie.text!(point, text = L"v_{%$i}", offset = (-30, -10)) 51 | end 52 | 53 | for (i, point) in enumerate(points[nc + 1:end]) 54 | CairoMakie.scatter!(point, color = :black, marker = :rect, markersize = 25) 55 | end 56 | display(fig) 57 | return fig 58 | end 59 | -------------------------------------------------------------------------------- /ext/MakieExt/Classical/weight_dist.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 - 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # Weight Enumerators 9 | ############################# 10 | 11 | """ 12 | $TYPEDSIGNATURES 13 | 14 | Return a bar graph of the weight distribution of `C`. 15 | 16 | # Note 17 | - Run `using Makie` to activate this extension. 18 | """ 19 | function CodingTheory.weight_plot(C::AbstractLinearCode; alg::Symbol = :auto) 20 | wt_dist = weight_distribution(C, alg = alg, compact = true) 21 | x_ticks = findall(x -> x > 0, vec(wt_dist)) .- 1 22 | y_ticks = [wt_dist[i] for i in 1:length(wt_dist) if !iszero(wt_dist[i])] 23 | ismissing(C.d) ? (title = "Weight Distribution - [$(C.n), $(C.k)]";) : 24 | title = "Weight Distribution - [$(C.n), $(C.k), $(C.d)]" 25 | 26 | fig = Figure() 27 | ax = Axis(fig[1, 1], xlabel = "Weight", ylabel = "Number of Terms", title = title) 28 | barplot!(ax, 0:C.n, wt_dist', bar_width = 1, xticks = x_ticks, yticks = y_ticks) 29 | # fig = bar(0:C.n, wt_dist', bar_width = 1, xticks = x_ticks, yticks = y_ticks, 30 | # legend = false, xlabel = "Weight", ylabel = "Number of Terms", title = title) 31 | display(fig) 32 | return fig 33 | end 34 | -------------------------------------------------------------------------------- /ext/MakieExt/LDPC/analysis.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 - 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # general functions 9 | ############################# 10 | 11 | """ 12 | $TYPEDSIGNATURES 13 | 14 | Return a plot of the EXIT chart for the ensemble given the channel up to a numerical tolerance of `tol`. 15 | 16 | # Note 17 | - Run `using Makie` to activate this extension. 18 | """ 19 | function CodingTheory.EXIT_chart_plot(E::LDPCEnsemble, Ch::AbstractClassicalNoiseChannel; tol::Float64 = 1e-9) 20 | 21 | @assert isa(Ch, BinaryErasureChannel) "Only BEC is implemented so far" 22 | x = 0:0.01:1 23 | c = 1 .- [CodingTheory._poly_eval(x, E.ρ) for x in 1 .- x] 24 | v = Ch.param .* [CodingTheory._poly_eval(x, E.λ) for x in x] 25 | Ch ∈ keys(E.density_evo) || CodingTheory._density_evolution!(E, Ch) 26 | evo_x, evo_y = E.density_evo[Ch] 27 | ind = findfirst(evo_x .<= tol) 28 | title = if isnothing(ind) 29 | "Failed to converge after $(length(evo_x) - 1) iterations (tol = $tol)" 30 | else 31 | "Converged after $(ind - 1) iterations (tol = $tol), \$\\varepsilon = $(Ch.param)\$" 32 | end 33 | 34 | fig = Figure() 35 | ax = Axis(fig[1, 1], limits = ((0, min(1, Ch.param * 1.2)), (0, 1)), title = title) 36 | lines!(x, c, label = L"c(x)") 37 | lines!(v, x, label = L"v_{\varepsilon}^{-1}(x)") 38 | stairs!(evo_x[1:ind], evo_y[1:ind], linestyle = :dash, linecolor = :black) 39 | axislegend(position = :rb) 40 | display(fig) 41 | return fig 42 | 43 | # p = plot(x, c, label = "\$c(x)\$") 44 | # plot!(p, v, x, label = "\$v_{\\varepsilon}^{-1}(x)\$") 45 | # plot!(p, evo_x[1:ind], evo_y[1:ind], seriestype = :steppre, linestyle = :dash, 46 | # linecolor = :black, label = false) 47 | # plot!(p, legend = :bottomright, xlims = (0, min(1, Ch.param * 1.2)), ylims = (0, 1), 48 | # title = title) 49 | # return p 50 | end 51 | -------------------------------------------------------------------------------- /ext/MakieExt/MakieExt.jl: -------------------------------------------------------------------------------- 1 | module MakieExt 2 | 3 | import CodingTheory, Oscar 4 | import CodingTheory: Tanner_graph_plot, weight_plot, EXIT_chart_plot, degree_distributions_plot, simple_cycle_length_distribution_plot, ACE_spectrum_plot, computation_graph, weight_plot_CSS_X, weight_plot_CSS_Z, weight_plot_CSS, AbstractLinearCode, AbstractLDPCCode, 5 | LDPCEnsemble, AbstractClassicalNoiseChannel, AbstractStabilizerCode, AbstractStabilizerCodeCSS, 6 | simple_cycle_length_distribution, simple_cycle_distribution_by_variable_node, ACE_distribution, 7 | short_cycle_length_distribution, short_cycle_distribution_by_variable_node, girth 8 | # import Makie 9 | using Makie, NetworkLayout, CairoMakie, GraphMakie, GLMakie, WGLMakie#, GraphPlot 10 | import CairoMakie: @L_str #, Figure, Axis, hidespines!, hidedecorations!, lines!, text! 11 | import Graphs as Grphs 12 | using DocStringExtensions 13 | # import CairoMakie: save 14 | 15 | include("Classical/Tanner.jl") 16 | include("Classical/weight_dist.jl") 17 | include("LDPC/codes.jl") 18 | include("LDPC/cycles.jl") 19 | include("LDPC/analysis.jl") 20 | include("Quantum/weight_dist.jl") 21 | 22 | end 23 | -------------------------------------------------------------------------------- /src/Classical/Gabidulin.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | # TODO currently untested and have no unit tests 12 | 13 | """ 14 | GeneralizedGabidulinCode(F::CTFieldTypes, eval_pts::Vector{CTFieldElem}, k::Int, s::Int; parity::Bool = false) 15 | 16 | Return the vector representation of the dimension `k` generalized Gabidulin code given the 17 | evaluation points `eval_pts` with respect to the subfield `F` of the base ring of `eval_pts`. 18 | 19 | # Notes 20 | - Distances are reported with respect to the Hamming metric. 21 | """ 22 | function GeneralizedGabidulinCode(F::CTFieldTypes, eval_pts::Vector{CTFieldElem}, k::Int, s::Int; parity::Bool = false) 23 | 24 | is_empty(eval_pts) && throw(ArgumentError("The input vector `eval_pts` cannot be empty.")) 25 | is_positive(s) || throw(DomainError(s, "The parameter `s` must be positive.")) 26 | E = parent(eval_pts[1]) 27 | all(parent(pt) == E for pt in eval_pts) || throw(ArgumentError("All evaluation points must be over the same base ring.")) 28 | flag, m = is_extension_field(E, F) 29 | flag || throw(ArgumentError("The input field is not a subfield of the base ring of the evaluation points.")) 30 | n = length(eval_pts) 31 | n ≤ m || throw(ArgumentError("The number of evaluation points must be less than or equal to the degree of the field extension.")) 32 | 0 < k ≤ n || throw(DomainError(k, "The code dimenion must be `0 < k ≤ n`.")) 33 | q = Int(order(F)) 34 | 35 | B = zero_matrix(E, n, n) 36 | for r in 1:n 37 | for c in 1:n 38 | B[r, c] = eval_pts[c]^(q^(n - 1)) 39 | end 40 | end 41 | iszero(det(B)) || throw(ArgumentError("The evaluation points must be linearly independent.")) 42 | 43 | G = zero_matrix(E, k, n) 44 | for r in 1:k 45 | for c in 1:n 46 | G[r, c] = eval_pts[c]^(q^(s * (r - 1))) 47 | end 48 | end 49 | 50 | return LinearCode(G, parity) 51 | # reaches Singleton bound for the rank metric: d_R = n - k + 1 52 | end 53 | 54 | """ 55 | GabidulinCode(F::CTFieldTypes, eval_pts::Vector{CTFieldElem}, k::Int; parity::Bool = false) 56 | 57 | Return the vector representation of the dimension `k` Gabidulin code given the evaluation points 58 | `eval_pts` with respect to the subfield `F` of the base ring of `eval_pts`. 59 | 60 | # Notes 61 | - Distances are reported with respect to the Hamming metric. 62 | """ 63 | GabidulinCode(F::CTFieldTypes, eval_pts::Vector{CTFieldElem}, k::Int; parity::Bool = false) = 64 | GeneralizedGabidulinCode(F, eval_pts, k, 1, parity = parity) 65 | 66 | # TODO the dual is also a Gabidulin code, need to figure out those eval points based on these 67 | # but that would require making a type for this named code 68 | # TODO are these MDS or just in rank metric? 69 | -------------------------------------------------------------------------------- /src/Classical/Goppa.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | function GoppaCode(F::CTFieldTypes, L::Vector{FqFieldElem}, g::FqPolyRingElem) 12 | is_empty(L) && throw(ArgumentError("The input vector `L` cannot be empty.")) 13 | E = parent(L[1]) 14 | all(parent(pt) == E for pt in L) || throw(ArgumentError("All elements of the input vector `L` must be over the same base ring.")) 15 | E == base_ring(g) || throw(ArgumentError("Input vector must be over the same base ring as the Goppa polynomial.")) 16 | rts = roots(g) 17 | isempty(L ∩ rts) || throw(ArgumentError("The input vector must not contain any roots of the Goppa polynomial.")) 18 | is_subfield(F, E)[1] || throw(ArgumentError("The input field is not a subfield of the base ring of the polynomial.")) 19 | 20 | n = length(L) 21 | t = degree(g) 22 | H = zero_matrix(E, t, n) 23 | for c in 1:n 24 | for r in 1:t 25 | H[r, c] = L[c]^(r - 1) * g(L[c])^(-1) 26 | end 27 | end 28 | 29 | basis, _ = primitive_basis(E, F) 30 | if typeof(E) === typeof(F) 31 | H_exp = transpose(expand_matrix(transpose(H), F, basis)) 32 | else 33 | H_exp = change_base_ring(F, transpose(expand_matrix(transpose(H), GF(Int(order(F))), basis))) 34 | end 35 | 36 | # just call LinearCode constructor here? 37 | 38 | # compute G 39 | G = kernel(H_exp, side = :right) 40 | k = rank(G) 41 | if ncols(G) == k 42 | G_tr = transpose(G) 43 | else 44 | # remove empty columns for flint objects https://github.com/oscar-system/Oscar.jl/issues/1062 45 | nr = nrows(G) 46 | G_tr = zero_matrix(base_ring(G), k, nr) 47 | for r in 1:nr 48 | for c in 1:rnk_G 49 | !iszero(G[r, c]) && (G_tr[c, r] = G[r, c];) 50 | end 51 | end 52 | end 53 | G = G_tr 54 | n = ncols(G) 55 | 56 | G_stand, H_stand, P, _ = _standard_form(G) 57 | ub1, _ = _min_wt_row(G) 58 | ub2, _ = _min_wt_row(G_stand) 59 | ub = min(ub1, ub2) 60 | 61 | C = GoppaCode(F, E, n, k, missing, 1, ub, G, H_exp, G_stand, H_stand, P, 62 | missing, L, g) 63 | if BigInt(order(base_ring(G)))^min(k, n - k) <= 1.5e5 64 | C.weight_enum = if 2k <= n 65 | _weight_enumerator_BF(C.G_stand) 66 | else 67 | MacWilliams_identity(dual(C), _weight_enumerator_BF(C.H_stand)) 68 | end 69 | d = minimum(filter(is_positive, first.(exponent_vectors(CWE_to_HWE(C.weight_enum).polynomial)))) 70 | set_minimum_distance!(C, d) 71 | else 72 | l_bound = t + 1 73 | if Int(order(F)) == 2 74 | facs = factor(g) 75 | deg_g2 = 0 76 | for i in collect(values(facs.fac)) 77 | iseven(i) ? (deg_g2 += i;) : (deg_g2 += i + 1;) 78 | end 79 | l_bound = deg_g2 + 1 80 | end 81 | set_distance_lower_bound!(C, l_bound) 82 | end 83 | 84 | return C 85 | end 86 | 87 | ############################# 88 | # getter functions 89 | ############################# 90 | 91 | """ 92 | Goppa_polynomial(C::AbstractGoppaCode) 93 | 94 | Return the Goppa polynomial of `C`. 95 | """ 96 | Goppa_polynomial(C::AbstractGoppaCode) = C.g 97 | 98 | """ 99 | extension(C::AbstractGoppaCode) 100 | 101 | Return the field over which the Goppa polynomial is defined. 102 | """ 103 | extension_field(C::AbstractGoppaCode) = C.E 104 | 105 | ############################# 106 | # setter functions 107 | ############################# 108 | 109 | ############################# 110 | # general functions 111 | ############################# 112 | 113 | """ 114 | is_seperable(C::AbstractGoppaCode) 115 | 116 | Return true if the Goppa polynomail is seperable. 117 | """ 118 | is_irreducible(C::AbstractGoppaCode) = Oscar.is_irreducible(C.g) 119 | 120 | """ 121 | is_seperable(C::AbstractGoppaCode) 122 | 123 | Return true if the Goppa polynomail is seperable. 124 | """ 125 | is_seperable(C::AbstractGoppaCode) = is_squarefree(C.g) 126 | 127 | """ 128 | nonzeros(C::AbstractGoppaCode) 129 | 130 | Return the set `L` of the `Γ(L, g)` Goppa code. 131 | """ 132 | nonzeros(C::AbstractGoppaCode) = C.L 133 | 134 | """ 135 | is_cumulative(C::AbstractGoppaCode) 136 | 137 | Return true if the Goppa polynomail is of the form `g(z) = (z - β)^r`. 138 | """ 139 | function is_cumulative(C::AbstractGoppaCode) 140 | fac = factor(C.g) 141 | length(fac.facs) == 1 ? (return true;) : (return false;) 142 | end 143 | -------------------------------------------------------------------------------- /src/Classical/MatrixProductCode.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022, 2023 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | # TODO: need to make sure codes are not overcomplete 12 | """ 13 | MatrixProductCode(C::Vector{AbstractLinearCode}, A::CTMatrixTypes) 14 | 15 | Return the matrix product code defined by the vector of linear codes `C` and matrix `A`. 16 | """ 17 | function MatrixProductCode(C::Vector{AbstractLinearCode}, A::CTMatrixTypes) 18 | isempty(C) && throw(ArgumentError("Vector of linear codes cannot be empty.")) 19 | iszero(A) && throw(ArgumentError("Matrix A cannot be zero.")) 20 | s, l = size(A) 21 | s == length(C) || throw(ArgumentError("Number of rows of A must be equal to the number of codes.")) 22 | F = C[1].F 23 | n = C[1].n 24 | for i in 2:s 25 | F == C[i].F || throw(ArgumentError("All codes must have the same base ring.")) 26 | n == C[i].n || throw(ArgumentError("All codes must have the same length.")) 27 | end 28 | F == base_ring(A) || throw(ArgumentError("Codes and matrix must have the same base ring.")) 29 | 30 | # H formula holds in special case only 31 | G = zero_matrix(F, sum([C[i].k for i in 1:s], l * n)) 32 | # H = zero_matrix(F, sum([nrows(C[i].H) for i in 1:s], l * n)) 33 | curr = 1 34 | # currH = 1 35 | # need to do in this row/column order 36 | for r in 1:s 37 | for c in 1:l 38 | G[curr:curr + C[r].k, 1 + (r - 1) * n:r * n] = A[r, c] * generator_matrix(C[r], true) 39 | # H[currH:currH + nrows(C[r].H), 1 + (r - 1) * n:r * n] = A[r, c] * paritycheckmatrix(C[r]) 40 | end 41 | curr += C[r].k 42 | # currH += nrows(C[r].H) 43 | end 44 | 45 | G_stand, H_stand, P, k = _standard_form(G) 46 | if ismissing(P) 47 | _, H = right_kernel(G) 48 | # note the H here is transpose of the standard definition 49 | H = _remove_empty(transpose(H), :rows) 50 | else 51 | H = H_stand * P 52 | end 53 | 54 | ub1, _ = _min_wt_row(G) 55 | ub2, _ = _min_wt_row(G_stand) 56 | ub = minimum([ub1, ub2]) 57 | return MatrixProductCode(F, n, k, 1, ub, missing, G, H, G_stand, 58 | H_stand, P, missing, C, A) 59 | end 60 | 61 | ############################# 62 | # getter functions 63 | ############################# 64 | 65 | # TODO: why are there no getter functions for this? C, A inputs? 66 | 67 | ############################# 68 | # setter functions 69 | ############################# 70 | 71 | ############################# 72 | # general functions 73 | ############################# 74 | -------------------------------------------------------------------------------- /src/Classical/ReedMuller.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, 2023 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | # """ 12 | # ReedMullergeneratormatrix(r::Int, m::Int, alt::Bool=false) 13 | 14 | # Return the recursive form of the generator matrix for the ``\\mathcal{RM}(r, m)`` Reed-Muller code. 15 | 16 | # # Notes 17 | # * If `alt` is `true`, the identity is used for the generator matrix for ``\\mathcal{RM}(1, 1)``, as in common in some sources. 18 | # Otherwise, `[1 1; 0 1]` is used, as is common in other sources. 19 | # """ 20 | function _Reed_Muller_generator_matrix(r::Int, m::Int, alt::Bool=false) 21 | (0 ≤ r ≤ m) || throw(DomainError("Reed-Muller codes require 0 ≤ r ≤ m, received r = $r and m = $m.")) 22 | 23 | F = Oscar.Nemo.Native.GF(2) 24 | if r == 1 && m == 1 && !alt 25 | return matrix(F, 2, 2, [1, 1, 0, 1]) 26 | elseif r == m 27 | return identity_matrix(F, 2^m) 28 | elseif r == 0 29 | return matrix(F, ones(Int, 1, 2^m)) 30 | else 31 | Grm1 = _Reed_Muller_generator_matrix(r, m - 1, alt) 32 | Gr1m1 = _Reed_Muller_generator_matrix(r - 1, m - 1, alt) 33 | return vcat(hcat(Grm1, Grm1), hcat(zero_matrix(F, nrows(Gr1m1), ncols(Gr1m1)), Gr1m1)) 34 | end 35 | end 36 | 37 | """ 38 | ReedMullerCode(r::Int, m::Int, alt::Bool=false) 39 | 40 | Return the ``\\mathcal{RM}(r, m)`` Reed-Muller code. 41 | 42 | # Notes 43 | * If `alt` is `true`, the identity is used for the generator matrix for ``\\mathcal{RM}(1, 1)``, as in common in some sources. 44 | Otherwise, `[1 1; 0 1]` is used, as is common in other sources. 45 | """ 46 | function ReedMullerCode(r::Int, m::Int, alt::Bool=false) 47 | (0 ≤ r < m) || throw(DomainError("Reed-Muller codes require 0 ≤ r < m, received r = $r and m = $m.")) 48 | m < 64 || throw(DomainError("This Reed-Muller code requires the implmentation of BigInts. Change if necessary.")) 49 | 50 | G = _Reed_Muller_generator_matrix(r, m, alt) 51 | H = _Reed_Muller_generator_matrix(m - r - 1, m, alt) 52 | G_stand, H_stand, P, rnk = _standard_form(G) 53 | 54 | # verify 55 | ncols(G) == 2^m || error("Generator matrix computed in ReedMuller has the wrong number of columns; received: $(ncols(G)), expected: $(BigInt(2)^m).") 56 | k = sum([binomial(m, i) for i in 0:r]) 57 | nrows(G) == k || error("Generator matrix computed in ReedMuller has the wrong number of rows; received: $(nrows(G)), expected: $k.") 58 | size(H) == (2^m - k, k) && (H = transpose(H);) 59 | d = 2^(m - r) 60 | 61 | if r == 1 62 | R, vars = polynomial_ring(Nemo.ZZ, 2) 63 | poly = vars[1]^(2^m) + (2^(m + 1) - 2) * vars[1]^(2^m - 2^(m - 1))*vars[2]^(2^(m - 1)) + vars[2]^(2^m) 64 | return ReedMullerCode(base_ring(G), ncols(G), nrows(G), d, d, d, r, m, G, 65 | H, G_stand, H_stand, P, WeightEnumerator(poly, :complete)) 66 | end 67 | 68 | return ReedMullerCode(base_ring(G), ncols(G), nrows(G), d, d, d, r, m, G, 69 | H, G_stand, H_stand, P, missing) 70 | end 71 | 72 | ############################# 73 | # getter functions 74 | ############################# 75 | 76 | """ 77 | order(C::ReedMullerCode) 78 | RM_r(C::ReedMullerCode) 79 | 80 | Return the order, `r`, of the ``\\mathcal{RM}(r, m)`` Reed-Muller code. 81 | """ 82 | order(C::ReedMullerCode) = C.r 83 | RM_r(C::ReedMullerCode) = order(C) 84 | 85 | """ 86 | number_of_variables(C::ReedMullerCode) 87 | RM_m(C::ReedMullerCode) 88 | 89 | Return the number of variables, `m`, of the ``\\mathcal{RM}(r, m)`` Reed-Muller code. 90 | """ 91 | number_of_variables(C::ReedMullerCode) = C.m 92 | RM_m(C::ReedMullerCode) = C.m 93 | 94 | ############################# 95 | # setter functions 96 | ############################# 97 | 98 | ############################# 99 | # general functions 100 | ############################# 101 | 102 | -------------------------------------------------------------------------------- /src/Classical/TwistedReedSolomon.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | """ 12 | TwistedReedSolomonCode(k::Int, α::Vector{T}, t::Vector{Int}, h::Vector{Int}, η::Vector{T}) where T <: CTFieldElem 13 | 14 | Return the twisted Reed-Solomon code defined in `https://arxiv.org/abs/2107.06945`. 15 | """ 16 | function TwistedReedSolomonCode(k::Int, α::Vector{T}, t::Vector{Int}, h::Vector{Int}, η::Vector{T}) where T <: CTFieldElem 17 | 18 | l = length(t) 19 | l == length(h) || throw(ArgumentError("Input vectors `t`, `h`, and `η` must have the same length")) 20 | l == length(η) || throw(ArgumentError("Input vectors `t`, `h`, and `η` must have the same length")) 21 | length(unique(collect(zip(h, t)))) == l || throw(ArgumentError("The tuples `(h[i], t[i])` must be distinct")) 22 | n = length(α) 23 | length(unique(α)) == n || throw(ArgumentError("The elements of `α` must be distinct")) 24 | 1 ≤ k ≤ n || throw(DomainError(k, "The dimension of the code must satisfy `1 ≤ k ≤ length(α)`")) 25 | all(1 ≤ x ≤ n - k for x in t) || throw(DomainError(t, "Elements of `t` must satsify `1 ≤ t[i] ≤ n - k`")) 26 | all(0 ≤ x ≤ k - 1 for x in h) || throw(DomainError(h, "Elements of `h` must satsify `0 ≤ h[i] ≤ k - 1`")) 27 | F = parent(α[1]) 28 | all(parent(x) == F for x in α) || throw(DomainError(α, "All elements of `α` must be over the same base ring")) 29 | all(parent(x) == F for x in η) || throw(DomainError(η, "All elements of `η` must be over the same base ring as the elements of `α`")) 30 | 31 | _, x = polynomial_ring(F, :x) 32 | G = zero_matrix(F, k, n) 33 | for i in 0:k - 1 34 | g_i = x^i 35 | for j in 1:l 36 | h[j] == i && (g_i += η[j] * x^(k - 1 + t[j]);) 37 | end 38 | 39 | for c in 1:n 40 | G[i + 1, c] = g_i(α[c]) 41 | end 42 | end 43 | # display(G) 44 | 45 | t_dual = k .- h 46 | h_dual = (n - k) .- t 47 | H = zero_matrix(F, n - k, n) 48 | for i in 0:n - k - 1 49 | g_i = x^i 50 | for j in 1:l 51 | h_dual[j] == i && (g_i += -η[j] * x^(n - k - 1 + t_dual[j]);) 52 | end 53 | 54 | for c in 1:n 55 | H[i + 1, c] = g_i(α[c]) 56 | end 57 | end 58 | # println(" ") 59 | # display(H) 60 | 61 | # println(" ") 62 | # display(G * transpose(H)) 63 | 64 | C = LinearCode(G, H, false) 65 | return TwistedReedSolomonCode(C.F, C.n, C.k, C.d, C.l_bound, C.u_bound, C.G, C.H, C.G_stand, C.H_stand, C.P_stand, C.weight_enum, α, t, h, η, l) 66 | end 67 | 68 | ############################# 69 | # getter functions 70 | ############################# 71 | 72 | """ 73 | twist_vector(C::AbstractTwistedReedSolomonCode) 74 | 75 | Return the twist vector of `C`. 76 | """ 77 | twist_vector(C::AbstractTwistedReedSolomonCode) = C.t 78 | 79 | """ 80 | hook_vector(C::AbstractTwistedReedSolomonCode) 81 | 82 | Return the hook vector of `C`. 83 | """ 84 | hook_vector(C::AbstractTwistedReedSolomonCode) = C.h 85 | 86 | """ 87 | coefficient_vector(C::AbstractTwistedReedSolomonCode) 88 | 89 | Return the coefficient vector of `C`. 90 | """ 91 | coefficient_vector(C::AbstractTwistedReedSolomonCode) = C.η 92 | 93 | """ 94 | number_of_twists(C::AbstractTwistedReedSolomonCode) 95 | 96 | Return the number of twists of `C`. 97 | """ 98 | number_of_twists(C::AbstractTwistedReedSolomonCode) = C.l 99 | 100 | ############################# 101 | # setter functions 102 | ############################# 103 | 104 | ############################# 105 | # general functions 106 | ############################# 107 | 108 | # TODO check if all of these are in linear_code and branches on type 109 | # TODO can do better wrt d, bounds, and weight enumerator 110 | function dual(C::AbstractTwistedReedSolomonCode) 111 | return TwistedReedSolomonCode(C.F, C.n, C.n - C.k, missing, 1, C.n, C.H, C.G, C.H_stand, C.G_stand, C.P_stand, missing, C.α, C.k .- C.h, (C.n - C.k) .- C.t, -C.η, C.l) 112 | end 113 | -------------------------------------------------------------------------------- /src/Convolutional/types.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # abstract types 9 | ############################# 10 | 11 | abstract type AbstractCode end 12 | abstract type AbstractConvolutionalCode <: AbstractCode end 13 | 14 | ############################# 15 | # concrete types 16 | ############################# 17 | 18 | ############################# 19 | # convolutional_code.jl 20 | ############################# 21 | 22 | struct PathEnumerator 23 | polynomial::Union{ZZMPolyRingElem, Nemo.AbsSimpleNumFieldElem} 24 | type::Symbol 25 | end 26 | 27 | mutable struct ConvolutionalCode <: AbstractConvolutionalCode 28 | F::CTFieldTypes # base field 29 | n::Int # length 30 | k::Int # dimension 31 | d::Union{Int, Missing} # free distance 32 | # l_bound::Int # lower bound on d 33 | # u_bound::Int # upper bound on d 34 | D::CTFieldElem # delay operator 35 | m::Int # memory 36 | vi::Vector{Int} # constraint lengths 37 | mnrs::Union{Vector{fqPolyRingElem}, Vector{FqPolyRingElem}} 38 | int_deg::Int # interal degree 39 | ext_deg::Int # external degree 40 | G::CTPolyMatrix 41 | H::CTPolyMatrix 42 | path_enum::Union{PathEnumerator, Missing} 43 | end 44 | -------------------------------------------------------------------------------- /src/LDPC/LP_decoders.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 - 2024 Eric Sabo, Benjamin Ide 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # LP Decoders 9 | ############################# 10 | 11 | # function _init_LP_decoder_LDPC end 12 | 13 | # function _LP_decoder_LDPC end 14 | 15 | # TODO: docstring and in extension 16 | """ 17 | LP_decoder_LDPC(H::Union{CTMatrixTypes, AbstractMatrix{<:Number}}, v::Union{CTMatrixTypes, Vector{<:Integer}}, Ch::BinarySymmetricChannel) 18 | LP_decoder_LDPC(C::AbstractLinearCode, v::Union{CTMatrixTypes, Vector{<:Integer}}, Ch::BinarySymmetricChannel) 19 | 20 | Return 21 | 22 | # Note 23 | - Run `using JuMP, GLPK` to activate this extension. 24 | """ 25 | function LP_decoder_LDPC end 26 | -------------------------------------------------------------------------------- /src/LDPC/algorithms.jl: -------------------------------------------------------------------------------- 1 | # # Copyright (c) 2022 Eric Sabo 2 | # # All rights reserved. 3 | # # 4 | # # This source code is licensed under the BSD-style license found in the 5 | # # LICENSE file in the root directory of this source tree. 6 | 7 | # function PEGalg(numvar::Int, numchk::Int, vardegdist::Vector{Int}) 8 | # numvar == length(vardegdist) || throw(ArgumentError("Vector length must match number of variable nodes.")) 9 | 10 | 11 | 12 | 13 | # create empty PCM H 14 | # also store graph? 15 | 16 | # what data structure is required to efficently build the subgraph 17 | # need to be able to immediately know which vertices connect to which 18 | # if we have to have some overhead to get that format, so be it 19 | # therefore, we will use the adjacency list format 20 | # we don't need the edges to be sorted, so we will implement ourselves instead of usin Graphs.jl 21 | # the variable node lists can be preallocated since we know the degree distribution 22 | # but the check node lists can be higher since the number of these is less than the number of variables 23 | # need to come up with an estimated average check node degree to preallocate 24 | 25 | 26 | # don't want the subgraph to be stored in an array because it will constantly grow and shrink 27 | # linked-list based structure most appropriate then 28 | # start with a vertex and create leaves for everything in adj_list[v] 29 | # simultaneously create a RB tree out of these nodes 30 | # check node: Int ID, Int dist, Int currdeg, Vector{Int} vertices 31 | # can most likely skip the latter and simply point to location in other array given ID 32 | # loop over this next layer and add them as children and make a RB tree out of them 33 | # arrange RB trees in each layer into a single array of RB tree pointers 34 | 35 | # end 36 | 37 | -------------------------------------------------------------------------------- /src/LDPC/channels.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Eric Sabo, Benjamin Ide 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # constructors 9 | ############################# 10 | 11 | """ 12 | BinaryErasureChannel(ε::Float64) 13 | BEC(ε::Float64) 14 | 15 | Return the binary erasure channel with erasure probability `ε`. 16 | """ 17 | function BinaryErasureChannel(ε::Float64) 18 | 0 <= ε <= 1 || throw(DomainError("The erasure probability must be in [0, 1]")) 19 | return BinaryErasureChannel(ε, 1 - ε) 20 | end 21 | BEC(ε::Float64) = BinaryErasureChannel(ε) 22 | 23 | """ 24 | BinarySymmetricChannel(p::Float64) 25 | BSC(p::Float64) 26 | 27 | Return the binary symmetric channel with crossover probability `p`. 28 | """ 29 | function BinarySymmetricChannel(p::Float64) 30 | 0 <= p <= 1 || throw(DomainError("The crossover probability must be in [0, 1]")) 31 | return BinarySymmetricChannel(p, 1 - _binary_entropy(p)) 32 | end 33 | BSC(p::Float64) = BinarySymmetricChannel(p) 34 | 35 | """ 36 | BAWGNChannel(σ::Float64) 37 | BAWGNC(σ::Float64) 38 | 39 | Return the binary (input) additive white Gaussian noise channel with standard deivation `σ` 40 | (noise variance `σ^2`). 41 | """ 42 | function BAWGNChannel(σ::Float64) 43 | # TODO: is this a good range for this parameter? 44 | 0 <= σ <= 1 || throw(DomainError("The standard deviation must be in [0, 1]")) 45 | return BAWGNChannel(σ, missing) 46 | end 47 | BAWGNC(σ::Float64) = BAWGNChannel(σ) 48 | 49 | # TODO: add an issymmetric parameter to simplify DE later 50 | 51 | ############################# 52 | # getter functions 53 | ############################# 54 | 55 | """ 56 | erasure_probability(Ch::BinaryErasureChannel) 57 | 58 | Return the erasure probability of the binary erasure channel. 59 | """ 60 | erasure_probability(Ch::BinaryErasureChannel) = Ch.param 61 | 62 | """ 63 | crossover_probability(Ch::BinarySymmetricChannel) 64 | 65 | Return the crossover probability of the binary symmetric channel. 66 | """ 67 | crossover_probability(Ch::BinarySymmetricChannel) = Ch.param 68 | 69 | """ 70 | standard_deviation(Ch::BAWGNChannel) 71 | 72 | Return the standard deviation of the BAWGN channel. 73 | """ 74 | standard_deviation(Ch::BAWGNChannel) = Ch.param 75 | 76 | """ 77 | variance(Ch::BAWGNChannel) 78 | 79 | Return the variance of the BAWGN channel. 80 | """ 81 | variance(Ch::BAWGNChannel) = Ch.param^2 82 | 83 | ############################# 84 | # general functions 85 | ############################# 86 | 87 | """ 88 | capacity(Ch::AbstractClassicalNoiseChannel) 89 | 90 | Return the capacity of the noise channel. 91 | """ 92 | function capacity(Ch::AbstractClassicalNoiseChannel) 93 | ismissing(Ch.capacity) || return Ch.capacity 94 | 95 | # TODO: compute capacity functional 96 | error("Not yet written") 97 | end 98 | 99 | function show(io::IO, Ch::AbstractClassicalNoiseChannel) 100 | if isa(Ch, BinaryErasureChannel) 101 | print(io, "Binary erasure channel with erasure probability $(Ch.param)") 102 | elseif isa(Ch, BinarySymmetricChannel) 103 | print(io, "Binary symmetric channel with crossover probability $(Ch.param)") 104 | elseif isa(Ch, BAWGNChannel) 105 | print(io, "Binary (input) additive white Gaussian noise channel with standard deviation $(Ch.param)") 106 | else 107 | print(io, "Classical noise channel with parameter $(Ch.param)") 108 | end 109 | 110 | if !ismissing(Ch.capacity) 111 | println(io, " and capacity $(Ch.capacity).") 112 | else 113 | println(io, ".") 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /src/LDPC/types.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 - 2024 Eric Sabo, Benjamin Ide 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | ############################# 8 | # abstract types 9 | ############################# 10 | 11 | abstract type AbstractLDPCCode <: AbstractLinearCode end 12 | 13 | abstract type AbstractNoiseChannel end 14 | abstract type AbstractClassicalNoiseChannel <: AbstractNoiseChannel end 15 | abstract type AbstractBinaryErasureChannel <: AbstractClassicalNoiseChannel end 16 | abstract type AbstractBinarySymmetricChannel <: AbstractClassicalNoiseChannel end 17 | abstract type AbstractBAWGNChannel <: AbstractClassicalNoiseChannel end 18 | 19 | ############################# 20 | # concrete types 21 | ############################# 22 | 23 | ############################# 24 | # LDPC/codes.jl 25 | ############################# 26 | 27 | mutable struct LDPCCode <: AbstractLDPCCode 28 | F::CTFieldTypes # base field 29 | n::Int # length 30 | k::Int # dimension 31 | d::Union{Int, Missing} # minimum distance 32 | l_bound::Int # lower bound on d 33 | u_bound::Int # upper bound on d 34 | H::CTMatrixTypes 35 | num_edges::Int 36 | var_degs::Vector{Int} 37 | check_degs::Vector{Int} 38 | col_bound::Int 39 | row_bound::Int 40 | limited::Int 41 | density::Float64 42 | is_reg::Bool 43 | # Tanner_graph::Union{Figure, Missing} 44 | λ::QQPolyRingElem 45 | ρ::QQPolyRingElem 46 | girth::Union{Int, Missing} 47 | ACEs_per_var_node::Vector{Vector{Int}} 48 | simple_cycles::Vector{Vector{Int}} 49 | max_cyc_len::Int 50 | end 51 | 52 | ############################# 53 | # LDPC/channels.jl 54 | ############################# 55 | 56 | struct BinaryErasureChannel <: AbstractBinaryErasureChannel 57 | param::Float64 58 | capacity::Float64 59 | end 60 | 61 | struct BinarySymmetricChannel <: AbstractBinarySymmetricChannel 62 | param::Float64 63 | capacity::Float64 64 | end 65 | 66 | mutable struct BAWGNChannel <: AbstractBAWGNChannel 67 | param::Float64 68 | capacity::Union{Float64, Missing} 69 | end 70 | 71 | ############################# 72 | # LDPC/ensembles.jl 73 | ############################# 74 | 75 | mutable struct LDPCEnsemble 76 | λ::PolyRingElem 77 | ρ::PolyRingElem 78 | L::PolyRingElem 79 | R::PolyRingElem 80 | l_avg::Float64 81 | r_avg::Float64 82 | design_rate::Float64 83 | density_evo::Dict{AbstractClassicalNoiseChannel, NTuple{2, Vector{Float64}}} 84 | threshold::Dict{Type, Float64} 85 | end 86 | -------------------------------------------------------------------------------- /src/Quantum/graph_state.jl: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022, 2023 Eric Sabo 2 | # All rights reserved. 3 | # 4 | # This source code is licensed under the BSD-style license found in the 5 | # LICENSE file in the root directory of this source tree. 6 | 7 | """ 8 | GraphState(G::SimpleGraph{Int64}) 9 | 10 | Return the graph state defined by the graph `G`. 11 | """ 12 | function GraphState(G::SimpleGraph{Int}) 13 | # probably need some checks on G here but maybe the function args are good enough 14 | A = adjacency_matrix(G) 15 | _, nc = size(A) 16 | for i in 1:nc 17 | iszero(A[i, i]) || throw(ArgumentError("Graph cannot have self-loops.")) 18 | end 19 | # are there non-binary graph states? 20 | F = Oscar.Nemo.Native.GF(2) 21 | Fone = F(1) 22 | sym_stabs = zero_matrix(F, nc, 2 * nc) 23 | for r in 1:nc 24 | sym_stabs[r, r] = Fone 25 | for c in 1:nc 26 | isone(A[r, c]) && (sym_stabs[r, c + nc] = Fone;) 27 | end 28 | end 29 | # this should automatically compute everything for the GraphState constructor 30 | return StabilizerCode(sym_stabs) 31 | end 32 | 33 | """ 34 | ClusterState(w::Int, h::Int) 35 | 36 | Return the cluster state (graph state) on the rectangular lattice with width `w` and height `h`. 37 | """ 38 | function ClusterState(w::Int, h::Int) 39 | (0 <= w && 0 <= h) || throw(ArgumentError("Rectangle dimensions must be positive.")) 40 | 41 | # BUG this function has never been updated from the quadratic form 42 | E = GF(2, 2, :ω) 43 | ω = gen(E) 44 | Eone = E(1) 45 | A = zero_matrix(E, w * h, w * h) 46 | curr = 1 47 | for r in 1:h 48 | for c in 1:w 49 | A[curr, curr] = Eone 50 | c != 1 && (A[curr, curr - 1] = ω;) 51 | c != w && (A[curr, curr + 1] = ω;) 52 | r != 1 && (A[curr, curr - w] = ω;) 53 | r != h && (A[curr, curr + w] = ω;) 54 | curr += 1 55 | end 56 | end 57 | return StabilizerCode(A) 58 | end 59 | -------------------------------------------------------------------------------- /test/Classical/GRS_alternate_test.jl: -------------------------------------------------------------------------------- 1 | @testset "Classical/GRS_alternate.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "GRS And Alternate Codes" begin 5 | # the [q, k, q - k + 1] extended narrow-sense Reed-Solomon code over 𝔽_q is GRS and MDS 6 | 7 | # narrrow-sense RS codes are GRS codes with n = q - 1, γ_i = α^i, and v_i = 1 for 0 <= i <= n - 1 8 | 9 | # MacWilliams & Sloane, p. 335 10 | E = GF(8) 11 | α = gen(E) 12 | γ = [α^i for i in 0:6] 13 | v = [E(1) for _ in 1:7] 14 | A = AlternateCode(GF(2), 2, v, γ) 15 | @test length(A) == 7 16 | @test dimension(A) == 3 17 | @test minimum_distance(A) == 4 18 | 19 | v = γ 20 | A = AlternateCode(GF(2), 2, v, γ) 21 | @test length(A) == 7 22 | @test dimension(A) == 4 23 | @test minimum_distance(A) == 3 24 | 25 | # maybe problem on p. 338 26 | # would require a weird setup of scalars given their def of H based on g 27 | 28 | # Ling & Zing, Example 9.2.4 (i), p. 193 29 | # E = GF(2^m) 30 | # F = GF(2) 31 | # v = (1, α, α^2, ..., α^(2^m - 2)] 32 | # all non-zero 33 | # γ = collect(E)[2:end] 34 | # A = AlternateCode(F, 2^m - 2, v, γ) 35 | # change_base_ring to Oscar.Native.Nemo.GF(2) 36 | # should be equal to HammingCode(2, m) 37 | # m = 4 38 | # E = GF(2^m) 39 | # α = gen(E) 40 | # F = GF(2) 41 | # v = [α^i for i in 0:2^m - 2] 42 | # γ = [α^i for i in 1:2^m - 1] 43 | # A = AlternateCode(F, 2^m - 2, v, γ) 44 | # TODO not really understanding if I'm using notation right 45 | 46 | # Ling & Zing, Example 9.2.4 (ii), p. 194 47 | # BCH codes are alternate codes 48 | 49 | # Ling & Zing, Example 9.2.4 (iii), p. 194 50 | E = GF(2^3) 51 | n = 6 52 | α = gen(E) 53 | # α is root of α^3 + α + 1 = 0 54 | v = [E(1) for _ in 1:n] 55 | γ = [α, α^2, α^3, α^4, α^5, α^6] 56 | A = AlternateCode(GF(2), 3, v, γ) 57 | @test length(A) == 6 58 | @test dimension(A) == 2 59 | @test minimum_distance(A) == 4 60 | 61 | # TODO write tests for GRS(Γ), GRS(A), etc 62 | end 63 | 64 | @testset "Srivastava codes" begin 65 | # MacWilliams & Sloane, Example, p. 358 66 | E = GF(2^6) 67 | α = gen(E) 68 | a = [E(0), E(1), α^9, α^18, α^27, α^36, α^45, α^54] 69 | w = [α] 70 | z = [E(1) for _ in 1:8] 71 | F = GF(2) 72 | C = GeneralizedSrivastavaCode(F, a, w, z, 2) 73 | @test Int(order(field(C))) == 2 74 | @test length(C) == 8 75 | @test dimension(C) == 2 76 | @test minimum_distance(C) == 5 77 | 78 | # from Goppa_test.jl 79 | E2 = GF(8, :α) 80 | S, z = polynomial_ring(E2, :z) 81 | β = gen(E2) 82 | g = β^3 + z + z^2 83 | L = [E2(0); [β^i for i in 0:6]] 84 | C2 = GoppaCode(F, L, g) 85 | flag, _ = are_permutation_equivalent(C, C2) 86 | @test_broken flag 87 | # broken because the perm function isn't correct 88 | 89 | # MacWilliams & Sloane, Problem (15), p. 359 90 | E = GF(2^4) 91 | α = gen(E) 92 | w = [E(0), E(1)] 93 | a = setdiff(collect(E), w) 94 | z = [E(1) for _ in 1:length(a)] 95 | C = GeneralizedSrivastavaCode(F, a, w, z, 2) 96 | @test length(C) == 14 97 | @test dimension(C) == 6 98 | @test minimum_distance(C) == 5 99 | D = dual(C) 100 | @test minimum_distance(D) == 4 101 | 102 | # MacWilliams & Sloane, Problem (16), p. 359 103 | E = GF(2^4) 104 | α = gen(E) 105 | w = [α^-1, α^-3] 106 | a = setdiff(collect(E), [E(0); w]) 107 | z = a 108 | C = GeneralizedSrivastavaCode(F, a, w, z, 2) 109 | @test length(C) == 13 110 | @test dimension(C) == 5 111 | @test minimum_distance(C) == 5 112 | D = dual(C) 113 | @test minimum_distance(D) == 5 114 | 115 | # MacWilliams & Sloane, Problem (18), p. 359 116 | # binary primitive GeneralizedSrivastavaCode with z_i = 1, s = 1 117 | # is a primitive, narrow-sense BCH code 118 | end 119 | end 120 | -------------------------------------------------------------------------------- /test/Classical/Goppa_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Classical/Goppa.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Goppa Code" begin 5 | # Ling & Xing, Example 9.3.10 (iii), p. 200 6 | E = GF(8, :α) 7 | S, z = polynomial_ring(E, :z) 8 | α = gen(E) 9 | # α satisfies α^3 + α + 1 10 | # julia> minimal_polynomial(α) 11 | # x^3 + x + 1 12 | g = α^3 + z + z^2 13 | L = [E(0); [α^i for i in 0:6]] 14 | F = GF(2) 15 | C = GoppaCode(F, L, g) 16 | @test length(C) == 8 17 | @test dimension(C) == 2 18 | @test minimum_distance(C) == 5 19 | 20 | # Ling & Xing, Corollary 9.3.4, p. 198 21 | n = length(L) 22 | # v = [g(a)^(-1) for a in L] 23 | v = [g(L[i]) * prod(L[i] - L[j] for j in 1:n if i ≠ j)^-1 for i in 1:n] 24 | t = degree(g) 25 | C2 = AlternateCode(F, n - t, v, L) 26 | # TODO I highly suspect this result comes from using different bases and scalars throughout different books and the expansion is highly basis dependent 27 | @test_broken are_equivalent(C, C2) 28 | 29 | # MacWilliams & Sloane, p. 342 30 | g = z^2 + z + 1 31 | C = GoppaCode(F, L, g) 32 | @test is_irreducible(C) 33 | C_ext = extend(C) 34 | @test length(C_ext) == 9 35 | @test dimension(C_ext) == 2 36 | @test minimum_distance(C_ext) == 6 37 | C_ext_perm = permute_code(C_ext, [2, 6, 8, 9, 4, 7, 1, 3, 5]) 38 | flag, C_cyc = is_cyclic(C_ext_perm) 39 | @test flag 40 | 41 | # TODO need permutation in M&S for cyclic test 42 | # MacWilliams & Sloane, p. 355 43 | # g = quadratic with distinct roots 44 | # L = set diff GF(2^m) minus those 45 | # extend GoppaCode 46 | # is cyclic 47 | # E = GF(2^5, :α) 48 | # S, z = polynomial_ring(E, :z) 49 | # α = gen(E) 50 | # g = z^2 + z + 1 51 | # L = [E(0); [α^i for i in 0:Int(order(E)) - 2]] 52 | # C = GoppaCode(F, L, g) 53 | # @test is_irreducible(C) 54 | # C_ext = extend(C) 55 | # @test length(C_ext) == 33 56 | # @test dimension(C_ext) == 22 57 | # @test minimum_distance(C_ext) == 6 58 | # C_ext_perm = permute_code(C_ext, need) 59 | # flag, C_cyc = is_cyclic(C_ext_perm) 60 | # @test flag 61 | # # which ring is this even in? 62 | # @test generator_polynomial(C_cyc) == 1 63 | # 1 + x^2 + x^5 + x^6 + x^9 + x^11 64 | 65 | # MacWilliams & Sloane, p. 343 66 | E = GF(2^5, :α) 67 | S, z = polynomial_ring(E, :z) 68 | α = gen(E) 69 | L = [E(0); [α^i for i in 0:Int(order(E)) - 2]] 70 | g = z^3 + z + 1 71 | C = GoppaCode(F, L, g) 72 | @test is_irreducible(C) 73 | @test length(C) == 32 74 | @test dimension(C) == 17 75 | @test minimum_distance(C) == 7 76 | 77 | # MacWilliams & Sloane, p. 344 78 | E = GF(2^4, :α) 79 | S, z = polynomial_ring(E, :z) 80 | α = gen(E) 81 | g = z^2 + z + α^3 82 | L = [E(0); [α^i for i in 0:Int(order(E)) - 2]] 83 | C = GoppaCode(GF(2), L, g) 84 | @test is_irreducible(C) 85 | @test length(C) == 16 86 | @test dimension(C) == 8 87 | @test minimum_distance(C) == 5 88 | 89 | # MacWilliams & Sloane, p. 349 90 | E = GF(2^4, :α) 91 | S, z = polynomial_ring(E, :z) 92 | α = gen(E) 93 | g = z^3 + z + 1 94 | L = [α^i for i in 0:14] 95 | C = GoppaCode(GF(2), L, g) 96 | @test length(C) == 15 97 | @test dimension(C) == 3 98 | @test minimum_distance(C) == 7 99 | 100 | # is equivalent to narrow-sense BCH code 101 | # Ling & Xing, p. 200 102 | # MacWilliams & Sloane, p. 345 103 | # Huffman & Pless, p. 522 104 | # the narrow-sense BCH code of length n and designed distance δ is the Goppa code with L = [1, β^(-1), β^(-2), ..., β^(1 - n)] and g = x^(δ - 1) 105 | # here β is the primitive root used in the BCH code 106 | # TODO I may not be fully understanding the variables being used here as they change from source to source 107 | # C = BCHCode(2, 15, 5) 108 | # α = primitive_root(C) 109 | # L = [α^(1 - i) for i in 1:C.n] 110 | # E = extension_field(C) 111 | # S, z = polynomial_ring(E, :z) 112 | # g = z^(design_distance(C) - 1) 113 | # C2 = GoppaCode(GF(2), L, g) 114 | # @test_broken are_equivalent(C, C2) 115 | end 116 | end 117 | -------------------------------------------------------------------------------- /test/Classical/ReedMuller_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Classical/ReedMuller.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Misc Known ReedMullerCodes" begin 5 | F = Oscar.Nemo.Native.GF(2) 6 | # Huffman, Pless, p. 34 7 | # identity used for RM(1, 1) 8 | @test CodingTheory._Reed_Muller_generator_matrix(1, 1, true) == matrix(F, 9 | [1 0; 10 | 0 1]); 11 | @test generator_matrix(ReedMullerCode(1, 2, true)) == matrix(F, 12 | [1 0 1 0; 13 | 0 1 0 1; 14 | 0 0 1 1]); 15 | @test generator_matrix(ReedMullerCode(1, 3, true)) == matrix(F, 16 | [1 0 1 0 1 0 1 0; 17 | 0 1 0 1 0 1 0 1; 18 | 0 0 1 1 0 0 1 1; 19 | 0 0 0 0 1 1 1 1]) 20 | @test generator_matrix(ReedMullerCode(2, 3, true)) == matrix(F, 21 | [1 0 0 0 1 0 0 0; 22 | 0 1 0 0 0 1 0 0; 23 | 0 0 1 0 0 0 1 0; 24 | 0 0 0 1 0 0 0 1; 25 | 0 0 0 0 1 0 1 0; 26 | 0 0 0 0 0 1 0 1; 27 | 0 0 0 0 0 0 1 1]) 28 | 29 | # Ling & Xing, p. 119 30 | # other sources, using [1 1; 0 1] for RM(1, 1) 31 | @test CodingTheory._Reed_Muller_generator_matrix(1, 1) == matrix(F, 32 | [1 1; 33 | 0 1]); 34 | @test generator_matrix(ReedMullerCode(1, 2)) == matrix(F, 35 | [1 1 1 1; 36 | 0 1 0 1; 37 | 0 0 1 1]); 38 | @test generator_matrix(ReedMullerCode(1, 3)) == matrix(F, 39 | [1 1 1 1 1 1 1 1; 40 | 0 1 0 1 0 1 0 1; 41 | 0 0 1 1 0 0 1 1; 42 | 0 0 0 0 1 1 1 1]) 43 | end 44 | 45 | @testset "self-dual property" begin 46 | # if m is odd and r = (m - 1)/2 then RM(r, m) = RM((m - 1)/2, m) is self-dual 47 | # random m 48 | C = ReedMullerCode(2, 5) 49 | # length 2^m 50 | @test length(C) == 2^5 51 | @test is_self_dual(C) 52 | # RM(0, m) is the length 2^m repetition code 53 | @test are_equivalent(ReedMullerCode(0, 3), RepetitionCode(2, 8)) 54 | end 55 | 56 | @testset "SimplexCode from ReedMullerCode" begin 57 | # puncturing RM(1, m) and taking the even subcode is the simplex code S_m 58 | # random parameters 59 | C = ReedMullerCode(1, 4) 60 | pC = puncture(C, [1]) 61 | epC = even_subcode(pC) 62 | S = SimplexCode(2, 4) 63 | 64 | @test are_equivalent(epC, S) 65 | C.d = missing 66 | 67 | # BUG syndrome trellis still weird 68 | # @test minimum_distance(C) == 8 69 | # the weight distribution of RM(1, m) is [[0, 1], [2^(m - 1), 2^(m + 1) - 2], [2^m, 1]] 70 | C.weight_enum = missing 71 | wt_dist = weight_distribution(C, alg = :auto, compact = true) 72 | @test wt_dist == [(2^4, 1), (2^3, 2^5 - 2), (0, 1)] 73 | end 74 | 75 | @testset "Nested and Even-weight Property" begin 76 | # Reed-Muller codes are nested 77 | m = rand(3:6) 78 | r = rand(1:m - 2) 79 | C = ReedMullerCode(r, m) 80 | C2 = ReedMullerCode(r + 1, m) 81 | @test C ⊆ C2 82 | 83 | # # all weights of RM(r, m) are multiples of 2^(Int(ceil(m / r) - 1) 84 | # sup = support(C) 85 | # flag = true 86 | # for i in sup 87 | # if !iszero(i % 2^(Int(ceil(m / r) - 1))) 88 | # flag = false 89 | # break 90 | # end 91 | # end 92 | # @test flag == true 93 | 94 | # RM(m - 1, m) contains all vectors of even weight 95 | C = ReedMullerCode(m - 1, m) 96 | sup = support(C) 97 | flag = true 98 | for i in sup 99 | if isodd(i) 100 | flag = false 101 | break 102 | end 103 | end 104 | @test flag == true 105 | 106 | C = ReedMullerCode(2, 5) 107 | @test weight_distribution(C, alg = :auto, compact = true) == [(32, 1), (24, 620), 108 | (20, 13888), (16, 36518), (12, 13888), (8, 620), (0, 1)] 109 | end 110 | end 111 | -------------------------------------------------------------------------------- /test/Classical/TwistedReedSolomon_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Classical/TwistedReedSolomon.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Twisted Reed-Solomon Codes" begin 5 | # https://arxiv.org/abs/2107.06945 6 | # Example 4 7 | # η = 0 gives original RS code 8 | # TODO determine which RS codes with the below 9 | 10 | # Example 4 11 | F = GF(3, 2, :ω); 12 | ω = gen(F); 13 | k = 5; 14 | α = collect(F); 15 | t = [2]; 16 | h = [2]; 17 | sqs = [i^2 for i in F]; 18 | η = [setdiff(α, sqs)[1]]; 19 | C = TwistedReedSolomonCode(k, α, t, h, η); 20 | G = zero_matrix(F, k, length(α)); 21 | for c in 1:length(α) 22 | G[1, c] = α[c]^0 23 | G[2, c] = α[c]^1 24 | G[3, c] = α[c]^2 + η[1] * α[c]^6 25 | G[4, c] = α[c]^3 26 | G[5, c] = α[c]^4 27 | end 28 | @test G == generator_matrix(C) 29 | 30 | # Example 4 31 | F = GF(2, 3, :ω); 32 | ω = gen(F); 33 | k = 5; 34 | α = collect(F); 35 | t = [1, 3, 3]; 36 | h = [4, 4, 2]; 37 | # paper does not specify, random suffices because here we are just matching the form of G 38 | η = [F(0), ω, ω^2]; 39 | C = TwistedReedSolomonCode(k, α, t, h, η); 40 | G = zero_matrix(F, k, length(α)); 41 | for c in 1:length(α) 42 | G[1, c] = α[c]^0 43 | G[2, c] = α[c]^1 44 | G[3, c] = α[c]^2 + η[3] * α[c]^7 45 | G[4, c] = α[c]^3 46 | G[5, c] = α[c]^4 + η[1] * α[c]^5 + η[2] * α[c]^7 47 | end 48 | @test G == generator_matrix(C) 49 | 50 | # BUG can't quite get these parameters to match mine 51 | # # https://arxiv.org/pdf/2211.06066 52 | # # this paper has shifted indices wrt the original definition 53 | # # Example 3.6 54 | # F = Oscar.Nemo.Native.GF(11) 55 | # l = 2 56 | # α = [F(1), F(2), F(3), F(5), F(6), F(8), F(9), F(10)] 57 | # k = 3 58 | # h = [k - l + i - 1 for i in 1:l] 59 | # t = [i for i in 1:l] 60 | # η = [F(0), F(0)] 61 | # C = TwistedReedSolomonCode(k, α, t, h, η); 62 | # @test length(C) == 8 63 | # @test dimension(C) == 3 64 | # # @test minimum_distance(C) == 6 65 | # # @test is_MDS(C) 66 | 67 | # η = [F(2), F(9)] 68 | # C = TwistedReedSolomonCode(k, α, t, h, η); 69 | # @test length(C) == 8 70 | # @test dimension(C) == 3 71 | # # @test minimum_distance(C) == 6 72 | # # @test is_MDS(C) 73 | 74 | # k = 4 75 | # h = [k - l + i - 1 for i in 1:l] 76 | # t = [i for i in 1:l] 77 | # η = [F(0), F(0)] 78 | # C = TwistedReedSolomonCode(k, α, t, h, η); 79 | # @test length(C) == 8 80 | # @test dimension(C) == 4 81 | # # @test minimum_distance(C) == 5 82 | # # @test is_MDS(C) 83 | 84 | # η = [F(4), F(4)] 85 | # C = TwistedReedSolomonCode(k, α, t, h, η); 86 | # @test length(C) == 8 87 | # @test dimension(C) == 4 88 | # # @test minimum_distance(C) == 5 89 | # # @test is_MDS(C) 90 | 91 | # η = [F(6), F(6)] 92 | # C = TwistedReedSolomonCode(k, α, t, h, η); 93 | # @test length(C) == 8 94 | # @test dimension(C) == 4 95 | # # @test minimum_distance(C) == 5 96 | # # @test is_MDS(C) 97 | 98 | # k = 5 99 | # h = [k - l + i - 1 for i in 1:l] 100 | # t = [i for i in 1:l] 101 | # η = [F(0), F(0)] 102 | # C = TwistedReedSolomonCode(k, α, t, h, η); 103 | # @test length(C) == 8 104 | # @test dimension(C) == 5 105 | # # @test minimum_distance(C) == 4 106 | # # @test is_MDS(C) 107 | 108 | # η = [F(9), F(10)] 109 | # C = TwistedReedSolomonCode(k, α, t, h, η); 110 | # @test length(C) == 8 111 | # @test dimension(C) == 5 112 | # # @test minimum_distance(C) == 4 113 | # # @test is_MDS(C) 114 | 115 | # # Example 3.7 116 | # F = Oscar.Nemo.Native.GF(13) 117 | # l = 3 118 | # α = [F(0), F(1), F(2), F(3), F(4), F(5), F(6), F(9), F(10), F(12)] 119 | # k = 5 120 | # h = [k - l + i - 1 for i in 1:l] 121 | # t = [i for i in 1:l] 122 | # η = [F(2), F(3), F(6)] 123 | # C = TwistedReedSolomonCode(k, α, t, h, η); 124 | # @test length(C) == 10 125 | # @test dimension(C) == 5 126 | # # @test minimum_distance(C) == 6 127 | # # @test is_MDS(C) 128 | 129 | # # this paper also does twisted-GRS codes 130 | # # the above examples are with v = 1 there 131 | end 132 | end 133 | -------------------------------------------------------------------------------- /test/Classical/cyclotomic_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Classical/cyclotomic.jl" begin 2 | using CodingTheory 3 | 4 | @test all_cyclotomic_cosets(2, 15, to_sort = false) == [[0], [1, 2, 4, 8], [3, 6, 12, 9], 5 | [5, 10], [7, 14, 13, 11]] 6 | @test all_cyclotomic_cosets(3, 13, to_sort = true) == [[0], [1, 3, 9], [2, 5, 6], [4, 10, 12] , [7, 8, 11]] 7 | end 8 | -------------------------------------------------------------------------------- /test/Classical/misc_known_codes_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Classical/misc_known_codes.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Hexacode" begin 5 | # Right now these are hardcoded in the function Hexacode(), but 6 | # testing in case we move to having some of it done automatically 7 | H = Hexacode() 8 | ω = gen(H.F) 9 | @test H.n == 6 10 | @test H.k == 3 11 | @test H.d == H.l_bound == H.u_bound == 4 12 | @test H.H == matrix(H.F, [1 ω ω 1 0 0; ω 1 ω 0 1 0; ω ω 1 0 0 1]) 13 | end 14 | 15 | @testset "HammingCode and SimplexCode" begin 16 | R, (x, y) = polynomial_ring(Nemo.ZZ, [:x, :y]) 17 | # Hamming codes 18 | # Tetra code is Hammingcode(3, 2) 19 | # random Hamming code 20 | F = Oscar.Nemo.Native.GF(2) 21 | C = HammingCode(2, 7) 22 | col = rand(1:length(C)) 23 | # columns are 1, 2, ... 2^r - 1 written as binary numerals 24 | @test parity_check_matrix(C)[:, col:col] == matrix(F, length(C) - 25 | dimension(C), 1, reverse(digits(col, base=2, pad=7))) 26 | # should be [2^r - 1, 2^r - 1 - r, 3] 27 | @test length(C) == 2^7 - 1 28 | @test dimension(C) == 2^7 - 1 - 7 29 | C.d = missing 30 | #@test minimum_distance(C) == 3 31 | C = HammingCode(2, 3) 32 | ham_WE = weight_enumerator(C, type = :Hamming) 33 | @test polynomial(ham_WE) == x^7 + 7*x^3*y^4 + 7*x^4*y^3 + y^7 34 | n = length(C) 35 | C.weight_enum = missing 36 | @test polynomial(ham_WE) == divexact((x + y)^n + n*(x + y)^div(n - 1, 2)*(y - x)^div(n + 1, 2), n + 1) 37 | 38 | # simplex codes 39 | # random simplex code 40 | C = SimplexCode(2, 4) 41 | known = C.weight_enum 42 | # C.weight_enum = missing 43 | # HWEbf = weight_enumerator(C, type = :Hamming) 44 | # C.weight_enum = missing 45 | # HWEtrellis = weight_enumerator(C, type = :Hamming, "trellis") 46 | # @test CWEtoHWE(known) == HWEbf 47 | # @test HWEbf == HWEtrellis 48 | # all nonzero codewords have weights q^{r - 1} 49 | # flag = true 50 | # for exps in [collect(exponent_vectors(polynomial(HWEtrellis)))[i][1] 51 | # for i in 1:length(polynomial(HWEtrellis))] 52 | # if !iszero(exps % 2^(4 - 1)) 53 | # flag = false 54 | # break 55 | # end 56 | # end 57 | # @test flag == true 58 | @test length(C) == 2^4 - 1 59 | @test CodingTheory.dimension(C) == 4 60 | C = SimplexCode(2, 3) 61 | @test MacWilliams_identity(C, weight_enumerator(C, type = :Hamming, alg = :bruteforce)) == ham_WE 62 | end 63 | 64 | @testset "Golay code" begin 65 | R, (x, y) = polynomial_ring(Nemo.ZZ, [:x, :y]) 66 | # Golay codes 67 | # TODO: test extend for the ternary Golay code 68 | C = ExtendedGolayCode(2) 69 | @test is_self_dual(C) 70 | C.weight_enum = missing 71 | @test polynomial(weight_enumerator(C, type = :Hamming)) == y^24 + 759*x^8*y^16 + 2576*x^12*y^12 + 759*x^16*y^8 + x^24 72 | C = GolayCode(2) 73 | C.weight_enum = missing 74 | @test polynomial(weight_enumerator(C, type = :Hamming)) == y^23 + 253*x^7*y^16 + 75 | 506*x^8*y^15 + 1288*x^11*y^12 + 1288*x^12*y^11 + 506*x^15*y^8 + 253*x^16*y^7 + x^23 76 | C = ExtendedGolayCode(3) 77 | @test is_self_dual(C) 78 | # well-known weight enumerators 79 | C.weight_enum = missing 80 | @test polynomial(weight_enumerator(C, type = :Hamming)) == y^12 + 264*x^6*y^6 + 440*x^9*y^3 + 24*x^12 81 | C = GolayCode(3) 82 | @test polynomial(weight_enumerator(C, type = :Hamming)) == y^11 + 132*x^5*y^6 + 132*x^6*y^5 + 330*x^8*y^3 + 110*x^9*y^2 + 24*x^11 83 | # cyclic code with generator polynomial g(x) = -1 + x^2 - x^3 + x^4 + x^5 84 | # and idempotent e(x) = -(x^2 + x^6 + x^7 + x^8 + x^10) 85 | # should be eqivalent to the [11, 6, 5] Golay code (maybe permutation?) 86 | 87 | # Huffman & Pless, p33, exercise 61d 88 | C = ExtendedGolayCode(3) 89 | C2 = extend(puncture(C, 7), 7) 90 | T = identity_matrix(C.F, 12) 91 | T[7,7] = C.F(-1) 92 | C3 = LinearCode(C2.G * T) 93 | @test are_equivalent(C, C3) 94 | end 95 | 96 | @testset "Tetra code" begin 97 | # tetra code 98 | C = TetraCode() 99 | C.weight_enum = missing 100 | CWE = polynomial(weight_enumerator(C, type = :complete)) 101 | vars = gens(parent(CWE)) 102 | @test CWE == vars[1]^4 + vars[1]*vars[2]^3 + 3*vars[1]*vars[2]^2*vars[3] + 103 | 3*vars[1]*vars[2]*vars[3]^2 + vars[1]*vars[3]^3 104 | end 105 | # Hadamard code 106 | # the dual code of the Hamming code is the shortened Hadamard code 107 | # equivalent to RM(1, m) 108 | 109 | end 110 | -------------------------------------------------------------------------------- /test/Classical/tilings_Tanner_test.jl: -------------------------------------------------------------------------------- 1 | # @testitem"Classical/tilings.jl & Classical/Tanner.jl" begin 2 | # using Graphs 3 | # using Oscar 4 | # using CodingTheory 5 | 6 | # min_index = 250; 7 | # max_index = 5000; 8 | # F = Oscar.Nemo.Native.GF(2) 9 | 10 | # # first test case 11 | # local_code = HammingCode(2, 3); 12 | # H = parity_check_matrix(local_code) 13 | # locs_wts = Vector{Int}() 14 | # for i in 1:nrows(H) 15 | # push!(locs_wts, wt(H[i, :])) 16 | # end 17 | 18 | # g = r_s_group(3, 7); 19 | # subgroups = normal_subgroups(g, max_index) 20 | # for subgroup in subgroups 21 | # # for this test case, the subgroup are numbers [3, 4, 5, 6, 7, 8, 9] 22 | # if is_fixed_point_free(subgroup, g) && GAP.Globals.Index(g.group, subgroup) > min_index 23 | # adj = sparse(transpose(coset_intersection([2, 3], [1, 3], subgroup, g))) 24 | # code = Tanner_code(adj, local_code) 25 | # # code = LinearCode(matrix(F, code), true) # remove later 26 | # @test code.k >= adj.n - adj.m * (local_code.n - local_code.k) 27 | 28 | # flag = true 29 | # for i in 1:nrows(code.H) 30 | # wt(code.H[i, :]) ∈ locs_wts || (flag = false;) 31 | # end 32 | # @test flag 33 | # end 34 | # end 35 | 36 | # # second test case 37 | # # C1 = GAP.Globals.BestKnownLinearCode(5, 2, GAP.Globals.GF(2)) 38 | # # x = GAP.Globals.GeneratorMat(C1) 39 | # # y = [GAP.Globals.Int(x[i, j]) for i in 1:2, j in 1:5] 40 | # y = [0 0 1 1 1; 1 1 0 1 1] 41 | # z = matrix(F, y) 42 | # C_loc = LinearCode(z) 43 | # G_test = Graphs.complete_graph(6) 44 | # EVI = sparse(transpose(Graphs.incidence_matrix(G_test))) 45 | # H1 = Tanner_code(EVI, C_loc) 46 | # EVI_G, left, right = edge_vertex_incidence_graph(G_test) 47 | # H2 = Tanner_code(EVI_G, left, right, C_loc) 48 | # @test parity_check_matrix(H1) == parity_check_matrix(H2) 49 | 50 | # # third test case 51 | # g = r_s_group(5, 4) 52 | # test_mat = CodingTheory.CoxeterMatrix(3, [1, 5, 2, 1, 4, 1]) 53 | # @test g.cox_mat == test_mat 54 | # subgroups = normal_subgroups(g, 100) 55 | # @test length(subgroups) == 7 56 | # filter!(x -> is_fixed_point_free(x, g), subgroups) 57 | # @test length(subgroups) == 0 58 | 59 | # # fourth test case 60 | # g = r_s_group(8, 3) 61 | # test_mat = CodingTheory.CoxeterMatrix(3, [1, 8, 2, 1, 3, 1]) 62 | # @test g.cox_mat == test_mat 63 | # subgroups = normal_subgroups(g, 100) 64 | # @test length(subgroups) == 10 65 | # filter!(x -> is_fixed_point_free(x, g), subgroups) 66 | # @test length(subgroups) == 1 67 | 68 | # # fifth test case 69 | # g = triangle_group(4, 3, 3) 70 | # test_mat = CodingTheory.CoxeterMatrix(3, [1, 4, 3, 1, 3, 1]) 71 | # @test g.cox_mat == test_mat 72 | # subgroups = normal_subgroups(g, 100) 73 | # @test length(subgroups) == 6 74 | # filter!(x -> is_fixed_point_free(x, g), subgroups) 75 | # @test length(subgroups) == 2 76 | 77 | # # sixth test case 78 | # g = q_r_s_group(4, 3, 5) 79 | # test_mat = CodingTheory.CoxeterMatrix(4, [1, 4, 2, 2, 1, 3, 2, 1, 5, 1]) 80 | # @test g.cox_mat == test_mat 81 | # subgroups = normal_subgroups(g, 100) 82 | # @test length(subgroups) == 6 83 | # filter!(x -> is_fixed_point_free(x, g), subgroups) 84 | # @test length(subgroups) == 0 85 | 86 | # # seventh test case 87 | # g = star_tetrahedron_group(5, 3, 3) 88 | # test_mat = CodingTheory.CoxeterMatrix(4, [1, 5, 3, 3, 1, 2, 2, 1, 2, 1]) 89 | # @test g.cox_mat == test_mat 90 | # subgroups = normal_subgroups(g, 100) 91 | # @test length(subgroups) == 3 92 | # filter!(x -> is_fixed_point_free(x, g), subgroups) 93 | # @test length(subgroups) == 0 94 | # end 95 | -------------------------------------------------------------------------------- /test/LDPC/GBP_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "LDPC/GBP.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "LDPC Region Graphs" begin 5 | # Region graphs 6 | r1 = Region([1, 5]) 7 | r2 = Region([1, 2, 3]) 8 | r3 = Region([1, 3, 4]) 9 | r4 = Region([1, 2, 4]) 10 | r5 = Region([1, 3], -1) 11 | r6 = Region([1, 2], -1) 12 | r7 = Region([1, 4], -1) 13 | r8 = Region([1], 0) 14 | push!(r1.subregions, r8) 15 | append!(r2.subregions, [r5, r6, r8]) 16 | append!(r3.subregions, [r5, r7, r8]) 17 | append!(r4.subregions, [r6, r7, r8]) 18 | push!(r5.subregions, r8) 19 | push!(r6.subregions, r8) 20 | push!(r7.subregions, r8) 21 | append!(r5.ancestors, [r2, r3]) 22 | append!(r6.ancestors, [r2, r4]) 23 | append!(r7.ancestors, [r3, r4]) 24 | append!(r8.ancestors, [r1, r2, r3, r4, r5, r6, r7]) 25 | append!(r5.parents, [r2, r3]) 26 | append!(r6.parents, [r2, r4]) 27 | append!(r7.parents, [r3, r4]) 28 | append!(r8.parents, [r1, r5, r6, r7]) 29 | R1 = RegionGraph([r1, r2, r3, r4, r5, r6, r7, r8]) 30 | # R2 = region_graph_from_base_nodes([1, 5], [1, 2, 3], [1, 3, 4], [1, 2, 4]) #causes error 31 | # need to write an == 32 | # @test R1 == R2 33 | # @test is_valid_region_graph(R1) 34 | # @test R1 == remove_zero_overcounting_numbers(R1) 35 | 36 | r1 = Region([1, 2, 4, 5]) 37 | r2 = Region([2, 3, 5, 6]) 38 | r3 = Region([4, 5, 7, 8]) 39 | r4 = Region([5, 6, 8, 9]) 40 | r5 = Region([4, 5], -1) 41 | r6 = Region([5, 6], 0) 42 | r7 = Region([2], -1) 43 | r8 = Region([5], -2) 44 | r9 = Region([6], -1) 45 | r10 = Region([8], -1) 46 | append!(r1.subregions, [r5, r7, r8]) 47 | append!(r2.subregions, [r6, r7, r8, r9]) 48 | append!(r3.subregions, [r5, r8, r10]) 49 | append!(r4.subregions, [r8, r9, r10]) 50 | push!(r5.subregions, r8) 51 | push!(r6.subregions, r8) 52 | append!(r5.ancestors, [r1, r3]) 53 | push!(r6.ancestors, r2) 54 | append!(r7.ancestors, [r1, r2]) 55 | append!(r8.ancestors, [r2, r4, r5, r6]) 56 | append!(r9.ancestors, [r2, r4]) 57 | append!(r10.ancestors, [r3, r4]) 58 | append!(r5.parents, [r1, r3]) 59 | push!(r6.parents, r2) 60 | append!(r7.parents, [r1, r2]) 61 | append!(r8.parents, [r4, r5, r6]) 62 | append!(r9.parents, [r2, r4]) 63 | append!(r10.parents, [r3, r4]) 64 | R1 = RegionGraph([r1, r2, r3, r4, r5, r6, r7, r8, r9, r10]) 65 | # R2 = region_graph_from_base_nodes([[1, 2, 4, 5], [2, 3, 5, 6], [4, 5, 7, 8], [5, 6, 8, 9]]) 66 | # need to write an == 67 | # @test R1 == R2 68 | # @test is_valid_region_graph(R1) 69 | # @test R1 ≠ remove_zero_overcounting_numbers(R1) 70 | 71 | r1 = Region([1, 2, 4, 5]) 72 | r2 = Region([2, 3, 5, 6]) 73 | r3 = Region([5, 6, 8, 9]) 74 | r4 = Region([4, 5, 7, 8]) 75 | r5 = Region([2, 5], -1) 76 | r6 = Region([4, 5], -1) 77 | r7 = Region([5, 6], -1) 78 | r8 = Region([5, 8], -1) 79 | append!(r1.subregions, [r5, r6]) 80 | append!(r2.subregions, [r5, r7]) 81 | append!(r3.subregions, [r7, r8]) 82 | push!(r4.subregions, r8) 83 | append!(r5.ancestors, [r1, r2]) 84 | append!(r6.ancestors, [r1, r4]) 85 | append!(r7.ancestors, [r2, r3]) 86 | append!(r8.ancestors, [r3, r4]) 87 | append!(r5.parents, [r1, r2]) 88 | append!(r6.parents, [r1, r4]) 89 | append!(r7.parents, [r2, r3]) 90 | append!(r8.parents, [r3, r4]) 91 | R1 = RegionGraph([r1, r2, r3, r4, r5, r6, r7, r8]) 92 | @test !is_valid_region_graph(R1) 93 | 94 | r1 = Region([0, 1, 2, 4]) 95 | r2 = Region([0, 1, 3, 5]) 96 | r3 = Region([0, 2, 3, 6]) 97 | r4 = Region([0, 1], -1) 98 | r5 = Region([0, 2], -1) 99 | r6 = Region([0, 3], -1) 100 | r7 = Region([0], 1) 101 | append!(r1.subregions, [r4, r5, r7]) 102 | append!(r2.subregions, [r4, r6, r7]) 103 | append!(r3.subregions, [r5, r6, r7]) 104 | append!(r4.ancestors, [r1, r2]) 105 | append!(r5.ancestors, [r1, r3]) 106 | append!(r6.ancestors, [r2, r3]) 107 | append!(r7.ancestors, [r1, r2, r3, r4, r5, r6, r7]) 108 | append!(r4.parents, [r1, r2]) 109 | append!(r5.parents, [r1, r3]) 110 | append!(r6.parents, [r2, r3]) 111 | append!(r7.parents, [r4, r5, r6]) 112 | R1 = RegionGraph([r1, r2, r3, r4, r5, r6, r7]) 113 | # R2 = region_graph_from_base_nodes([[0, 1, 2, 4], [0, 1, 3, 5], [0, 2, 3, 6]]) 114 | # @test R1 == R2 115 | # @test is_valid_region_graph(R1) 116 | # @test R1 == remove_zero_overcounting_numbers(R1) 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /test/LDPC/MP_decoders_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "LDPC/MP_decoders.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Message Passing" begin 5 | # not the most robust test, but I find that if something doesn't work everything fails 6 | F = Oscar.Nemo.Native.GF(2); 7 | H = matrix(F, [1 1 0 1 1 0 0; 1 0 1 1 0 1 0; 0 1 1 1 0 0 1]); 8 | v = matrix(F, 7, 1, [1, 1, 0, 0, 0, 0, 0]); 9 | correct_v = UInt8.([1, 1, 1, 0, 0, 0, 0]); 10 | correct_e = UInt8.([0, 0, 1, 0, 0, 0, 0]); 11 | syn = H * v; 12 | p = 1/7; 13 | nm = BSC(p); 14 | 15 | # basic cases 16 | flag, out, iter, _ = sum_product(H, v, nm); 17 | @test flag == true && out == correct_v 18 | flag, out, iter, _ = sum_product_box_plus(H, v, nm); 19 | @test flag == true && out == correct_v 20 | flag, out, iter, _ = sum_product_syndrome(H, syn, nm); 21 | @test flag == true && out == correct_e 22 | flag, out, iter, _ = min_sum(H, v, nm); 23 | @test flag == true && out == correct_v 24 | flag, out, iter, _ = min_sum_syndrome(H, syn, nm); 25 | @test flag == true && out == correct_e 26 | flag, out, iter, _ = min_sum_with_correction(H, v, nm); 27 | @test flag == true && out == correct_v 28 | flag, out, iter, _ = min_sum_with_correction_syndrome(H, syn, nm); 29 | @test flag == true && out == correct_e 30 | # flag, out, iter = Gallager_A(H, v); 31 | # @test flag == true && out == correct_v 32 | # flag, out, iter = Gallager_B(H, v); 33 | # @test flag == true && out == correct_v 34 | 35 | # all use the same init and loop functions so it suffices to test the options for a single function 36 | # some options 37 | flag, out, iter, _ = sum_product(H, v, nm, schedule = :parallel); 38 | @test flag == true && out == correct_v 39 | flag, out, iter, _ = sum_product(H, v, nm, schedule = :serial); 40 | @test flag == true && out == correct_v 41 | # flag, out, iter, _ = sum_product(H, v, nm, schedule = :layered); 42 | # @test flag == true && out == correct_v 43 | # flag, out, iter, _ = sum_product(H, v, nm, schedule = :layered, rand_sched = true); 44 | # @test flag == true && out == correct_v 45 | # flag, out, iter, _ = sum_product(H, v, nm, erasures = [rand(1:7)]); 46 | @test flag == true && out == correct_v 47 | flag, out, iter, _ = min_sum(H, v, nm, erasures = [rand(1:7)]); 48 | @test flag == true && out == correct_v 49 | # TODO this one fails for some reason 50 | flag, out, iter, _ = min_sum_with_correction(H, v, nm, erasures = [rand(1:7)]); 51 | @test_broken flag == true && out == correct_v 52 | # not particularly creative... 53 | temp = log((1 - p) / p); 54 | chn_inits = zeros(Float64, length(v)); 55 | @inbounds for i in 1:nrows(v) 56 | iszero(v[i]) ? (chn_inits[i] = temp;) : (chn_inits[i] = -temp;) 57 | end 58 | flag, out, iter, _ = sum_product(H, v, nm, chn_inits = chn_inits); 59 | @test flag == true && out == correct_v 60 | attenuation = 0.6 61 | flag, out, iter, _ = min_sum(H, v, nm, attenuation = 0.6); 62 | @test flag == true && out == correct_v 63 | flag, out, iter, _ = min_sum_with_correction(H, v, nm, attenuation = 0.6); 64 | @test flag == true && out == correct_v 65 | 66 | # decimation 67 | # decimated_bits_values = [(1, base_ring(v)(1))]; 68 | # flag, out, iter, _ = sum_product_decimation(H, v, nm, decimated_bits_values); flag 69 | # @test flag == true && out == correct_v 70 | # flag, out, iter, _ = min_sum_decimation(H, v, nm, decimated_bits_values); 71 | # @test flag == true && out == correct_v 72 | # flag, out, iter, _ = min_sum_correction_decimation(H, v, nm, decimated_bits_values); 73 | # @test flag == true && out == correct_v 74 | 75 | # other noise models 76 | # nm_BEC = BEC(p); 77 | # nm_G = BAWGNC(p); 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /test/LDPC/codes_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "LDPC/codes.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | # example from Ryan & Lin 5 | F = Oscar.Nemo.Native.GF(2) 6 | H = matrix(F, [ 7 | 1 1 1 1 0 0 0 0 0 0; 8 | 1 0 0 0 1 1 1 0 0 0; 9 | 0 1 0 0 1 0 0 1 1 0; 10 | 0 0 1 0 0 1 0 1 0 1; 11 | 0 0 0 1 0 0 1 0 1 1]) 12 | C = LDPCCode(H) 13 | @test column_row_bounds(C) == (2, 4) 14 | # @test rate(C) == 3 / 5 15 | @test is_regular(C) 16 | @test unique!(variable_degree_distribution(C)) == [2] 17 | @test unique(check_degree_distribution(C)) == [4] 18 | R = parent(variable_degree_polynomial(C)) 19 | x = gen(R) 20 | @test variable_degree_polynomial(C) == x 21 | @test check_degree_polynomial(C) == x^3 22 | end 23 | -------------------------------------------------------------------------------- /test/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f" 3 | Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" 4 | DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" 5 | Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" 6 | FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" 7 | Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" 8 | JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" 9 | LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 10 | Oscar = "f1435218-dba5-11e9-1e4d-f1a5fab5fc13" 11 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 12 | SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 13 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 14 | StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 15 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 16 | TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" 17 | -------------------------------------------------------------------------------- /test/Quantum/decoders/OFT_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Quantum/decoders/OTF.jl" begin 2 | using Random, Oscar, CodingTheory 3 | 4 | @testset "Ordered Tanner Forest" begin 5 | # first define Ton's Julia transpilation of the original Python 6 | function get_indices(H::Matrix{UInt8}, ordered_indices::Vector{Int} = collect(1:size(H, 2))) 7 | # We generate the linked_list 8 | m = size(H, 1) 9 | linked_list = ones(Int, 2 * m) 10 | for i in 1:m 11 | linked_list[2 * i - 1] = i 12 | end 13 | 14 | # Initialize an to hold the results, the True elements will have their probabilities updated to a very low value. 15 | result_indices = falses(size(H, 2)) 16 | 17 | # Iterate over the columns in the specified order 18 | for col in ordered_indices 19 | # println("col $col") 20 | # Get the rows that have True in the current column 21 | # TODO, this can be simplified by using a sparse matrix instead of a PCM, following line is too expensive. 22 | true_rows = findall(row -> isone(H[row, col]), 1:size(H, 1)) 23 | 24 | adding_index = false 25 | growing_depth = false 26 | row_list = Int[] 27 | max_depth = 0 28 | root = -1 29 | 30 | for true_row in true_rows 31 | index = find(linked_list, true_row) 32 | if !(index in row_list) 33 | push!(row_list, index) 34 | if linked_list[2 * index] > max_depth 35 | root = index 36 | growing_depth = false 37 | max_depth = linked_list[2 * index] 38 | elseif linked_list[2 * index] == max_depth 39 | growing_depth = true 40 | end 41 | else 42 | adding_index = true 43 | break 44 | end 45 | end 46 | 47 | if adding_index 48 | result_indices[col] = true 49 | else 50 | for index in row_list 51 | linked_list[2 * index - 1] = root 52 | end 53 | end 54 | if growing_depth 55 | linked_list[2 * root] += 1 56 | end 57 | # println(linked_list) 58 | end 59 | 60 | return result_indices 61 | end 62 | 63 | function find(linked_list::Vector{Int}, index::Int) 64 | while linked_list[2 * index - 1] != index 65 | index = linked_list[2 * index - 1] 66 | end 67 | return index 68 | end 69 | 70 | # check it against the code in this library 71 | for S in [SteaneCode(), Q15RM(), RotatedSurfaceCode(3), RotatedSurfaceCode(5), RotatedSurfaceCode(7), GrossCode()] 72 | H_Int = CodingTheory._Flint_matrix_to_Julia_T_matrix(X_stabilizers(S), UInt8); 73 | ordering = shuffle(1:S.n); 74 | var_adj_list = [Int[] for _ in 1:size(H_Int, 2)]; 75 | for r in 1:size(H_Int, 1) 76 | for c in 1:size(H_Int, 2) 77 | if !iszero(H_Int[r, c]) 78 | push!(var_adj_list[c], r) 79 | end 80 | end 81 | end 82 | E = sort(CodingTheory._select_erased_columns(H_Int, ordering, var_adj_list)); 83 | T = findall(x -> x == true, get_indices(H_Int, ordering)); 84 | @test E == T 85 | # test = E == T 86 | # println(test) 87 | # if !test 88 | # println(ordering) 89 | # println(E) 90 | # println(T) 91 | # end 92 | end 93 | end 94 | end 95 | -------------------------------------------------------------------------------- /test/Quantum/homological_measurements_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Quantum/homological_measurements.jl" begin 2 | using Oscar 3 | using CodingTheory 4 | 5 | @testset "Homological Measurements" begin 6 | n = rand(4:2:30) 7 | M = zeros(Int, n, n) 8 | for i in 1:n - 1 9 | M[i, i] = M[i, i + 1] = 1 10 | end 11 | M[n, 1] = M[n, n] = 1 12 | @test Cheeger_constant(M) == 4 / n 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /test/Quantum/misc_lit_codes_test.jl: -------------------------------------------------------------------------------- 1 | # misc codes from the literature 2 | @testitem "Quantum/misc_lit_codes.jl" begin 3 | using Oscar 4 | using CodingTheory 5 | 6 | @testset "Misc Codes From Literature" begin 7 | # TODO codes from "LRESC" paper, make tests (long range _ surface code?) 8 | # # the dual of any [3, 2, 2] code is a [3, 1, 3] repetition code 9 | # # but we'll build this the GAP way anyway 10 | # C_GAP = GAP.Globals.BestKnownLinearCode(3, 2, GAP.Globals.GF(2)); 11 | # G = GAP.Globals.GeneratorMat(C_GAP); 12 | # y = [GAP.Globals.Int(G[i, j]) for i in 1:2, j in 1:3]; 13 | # C32 = LinearCode(y, 2); 14 | # R4 = RepetitionCode(2, 4); 15 | # seed1 = concatenate(C32, R4) 16 | # LRESC1 = HypergraphProductCode(parity_check_matrix(seed1), parity_check_matrix(seed1)) 17 | 18 | # # unclear as to which [6, 2, 4] code they used here 19 | # C_GAP = GAP.Globals.BestKnownLinearCode(6, 2, GAP.Globals.GF(2)); 20 | # G = GAP.Globals.GeneratorMat(C_GAP); 21 | # y = [GAP.Globals.Int(G[i, j]) for i in 1:2, j in 1:6]; 22 | # C62 = LinearCode(y, 2) 23 | # R2 = RepetitionCode(2, 2); 24 | # seed2 = concatenate(C62, R2) 25 | # LRESC2 = HypergraphProductCode(parity_check_matrix(seed2), parity_check_matrix(seed2)) 26 | 27 | # # they either could have used this code or the extended Hamming code below 28 | # C_GAP = GAP.Globals.BestKnownLinearCode(8, 4, GAP.Globals.GF(2)); 29 | # G = GAP.Globals.GeneratorMat(C_GAP); 30 | # y = [GAP.Globals.Int(G[i, j]) for i in 1:4, j in 1:8]; 31 | # C84 = LinearCode(y, 2) 32 | # R3 = RepetitionCode(2, 3); 33 | # seed3 = concatenate(C84, R3) 34 | # LRESC3 = HypergraphProductCode(parity_check_matrix(seed3), parity_check_matrix(seed3)) 35 | 36 | # ext_Ham = extend(HammingCode(2, 3)) 37 | # seed3_alt = concatenate(ext_Ham, R3) 38 | # LRESC3_alt = HypergraphProductCode(parity_check_matrix(seed3_alt), parity_check_matrix(seed3_alt)) 39 | 40 | # julia> are_permutation_equivalent(C84, ext_Ham) 41 | # (false, missing) 42 | 43 | 44 | 45 | 46 | 47 | # radial codes 48 | # using StatsBase, Graphs, Oscar, CodingTheory 49 | # F = Oscar.Nemo.Native.GF(2) 50 | # S, x = polynomial_ring(F, :x) 51 | # l = 5 52 | # R, _ = residue_ring(S, x^l - 1) 53 | # A1 = matrix(R, 3, 3, 54 | # [x^3, x^2, x, 55 | # x^4, x^1, x^4, 56 | # x, x^2, x^3]) 57 | # A2 = matrix(R, 3, 3, 58 | # [x^3, x^3, 1, 59 | # x, 1, x, 60 | # x^4, x^2, 1]) 61 | # code = LiftedProductCode(A1, A2) 62 | # # [[90, 8]]_2 CSS stabilizer code 63 | # # julia> check_weights(code) 64 | # # (w_X, q_X, w_Z, q_Z) = (6, 3, 6, 3) 65 | # L_X = LDPCCode(code.X_stabs); 66 | # G_X, _, _ = Tanner_graph(L_X); 67 | # D_X = DiGraph(G_X); 68 | # L_X_cycles = CodingTheory._modified_hawick_james(D_X, 12); 69 | # countmap(length.(L_X_cycles)) 70 | # # Dict{Int64, Int64} with 3 entries: 71 | # # 6 => 48 72 | # # 10 => 4842 73 | # # 8 => 777 74 | # L_Z = LDPCCode(code.Z_stabs); 75 | # G_Z, _, _ = Tanner_graph(L_Z); 76 | # D_Z = DiGraph(G_Z); 77 | # L_Z_cycles = CodingTheory._modified_hawick_james(D_Z, 12); 78 | # countmap(length.(L_Z_cycles)) 79 | # # Dict{Int64, Int64} with 3 entries: 80 | # # 6 => 20 81 | # # 10 => 4074 82 | # # 8 => 678 83 | 84 | # l = 11 85 | # R, _ = residue_ring(S, x^l - 1) 86 | # A1 = matrix(R, 4, 4, 87 | # [x^10, x^10, x, x^6, 88 | # x^4, x^7, x^5, x^2, 89 | # x^8, x^10, x^6, x^9, 90 | # x, x^6, 1, x^6]) 91 | # A2 = matrix(R, 4, 4, 92 | # [x^9, x^5, x^8, x^3, 93 | # x^5, x^4, x, 1, 94 | # 1, x^4, x^6, x^10, 95 | # x^2, x^8, x^4, x^2]) 96 | # code = LiftedProductCode(A1, A2) 97 | # # [[352, 18]]_2 CSS stabilizer code 98 | # # julia> check_weights(code) 99 | # # (w_X, q_X, w_Z, q_Z) = (8, 4, 8, 4) 100 | # L_X = LDPCCode(code.X_stabs); 101 | # G_X, _, _ = Tanner_graph(L_X); 102 | # D_X = DiGraph(G_X); 103 | # L_X_cycles = CodingTheory._modified_hawick_james(D_X, 12); 104 | # countmap(length.(L_X_cycles)) 105 | # # Dict{Int64, Int64} with 3 entries: 106 | # # 6 => 96 107 | # # 10 => 61668 108 | # # 8 => 3970 109 | # L_Z = LDPCCode(code.Z_stabs); 110 | # G_Z, _, _ = Tanner_graph(L_Z); 111 | # D_Z = DiGraph(G_Z); 112 | # L_Z_cycles = CodingTheory._modified_hawick_james(D_Z, 12); 113 | # countmap(length.(L_Z_cycles)) 114 | # # Dict{Int64, Int64} with 3 entries: 115 | # # 6 => 72 116 | # # 10 => 60787 117 | # # 8 => 3954 118 | end 119 | end 120 | -------------------------------------------------------------------------------- /test/Quantum/quantum_MC_ids_test.jl: -------------------------------------------------------------------------------- 1 | # TODO: fix 2 | # @testset "QWEMacWId" begin 3 | # using CodingTheory 4 | 5 | # # basic - too symmetric in X, Y, Z to determine errors in formula 6 | # Q = SteaneCode() 7 | # WEstabs = CodingTheory._weightenumeratorBFQ(Q.stabs, Q.charvec, missing) 8 | # WEnorm = CodingTheory._weightenumeratorBFQ(Q.dualgens, Q.charvec, parent(WEstabs.polynomial)) 9 | # WEnormMacW = MacWilliams_identity(Q, WEstabs) 10 | # WEstabsMacW = MacWilliams_identity(Q, WEnorm, true) 11 | # @test WEnormMacW == WEnorm 12 | # @test WEstabsMacW == WEstabs 13 | 14 | # # non-CSS - also too symmetric in X, Y, Z 15 | # Q = Q513() 16 | # WEstabs = CodingTheory._weightenumeratorBFQ(Q.stabs, Q.charvec, missing) 17 | # WEnorm = CodingTheory._weightenumeratorBFQ(Q.dualgens, Q.charvec, parent(WEstabs.polynomial)) 18 | # WEnormMacW = MacWilliams_identity(Q, WEstabs) 19 | # WEstabsMacW = MacWilliams_identity(Q, WEnorm, true) 20 | # @test WEnormMacW == WEnorm 21 | # @test WEstabsMacW == WEstabs 22 | 23 | # # k > 1 - magically also too symmetric in X, Y, Z 24 | # Q = Q823() 25 | # WEstabs = CodingTheory._weightenumeratorBFQ(Q.stabs, Q.charvec, missing) 26 | # WEnorm = CodingTheory._weightenumeratorBFQ(Q.dualgens, Q.charvec, parent(WEstabs.polynomial)) 27 | # WEnormMacW = MacWilliams_identity(Q, WEstabs) 28 | # WEstabsMacW = MacWilliams_identity(Q, WEnorm, true) 29 | # @test WEnormMacW == WEnorm 30 | # @test WEstabsMacW == WEstabs 31 | 32 | # # # k > 1 33 | # # Q = Q1573() 34 | # # WEstabs = CodingTheory._weightenumeratorBFQ(Q.stabs, Q.charvec, missing) 35 | # # WEnorm = CodingTheory._weightenumeratorBFQ(Q.dualgens, Q.charvec, parent(WEstabs.polynomial)) 36 | # # WEnormMacW = MacWilliams_identity(Q, WEstabs) 37 | # # WEstabsMacW = MacWilliams_identity(Q, WEnorm, true) 38 | # # @test WEnormMacW == WEnorm 39 | # # @test WEstabsMacW == WEstabs 40 | 41 | # # popular - non-symmetric, detected error in X and Z terms being switched in MacWilliams_identity 42 | # Q = Q15RM() 43 | # WEstabs = CodingTheory._weightenumeratorBFQ(Q.stabs, Q.charvec, missing) 44 | # WEnorm = CodingTheory._weightenumeratorBFQ(Q.dualgens, Q.charvec, parent(WEstabs.polynomial)) 45 | # WEnormMacW = MacWilliams_identity(Q, WEstabs) 46 | # WEstabsMacW = MacWilliams_identity(Q, WEnorm, true) 47 | # @test WEnormMacW == WEnorm 48 | # @test WEstabsMacW == WEstabs 49 | # end 50 | -------------------------------------------------------------------------------- /test/Quantum/stabilizer_code_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Quantum/stabilizer_code.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Stabilizer code" begin 5 | Q = Q1573() 6 | logs = logicals(Q) 7 | new_stab = logs[1][2] + logs[2][2] 8 | Q2 = augment(Q, new_stab, verbose = false) 9 | Q3 = expurgate(Q2, [9], verbose = false) 10 | @test are_equivalent(Q, Q3) 11 | 12 | # basic tests 13 | @test is_CSS_T_code(SteaneCode()) == false 14 | @test is_CSS_T_code(Q1513()) 15 | @test is_CSS_T_code(Q1573()) == false 16 | @test is_CSS_T_code(SmallestInterestingColorCode()) 17 | 18 | # examples in https://arxiv.org/abs/1910.09333 19 | # Example 2 - [[6, 2, 2]], transversal T implements logical identity 20 | G = matrix(Oscar.Nemo.Native.GF(2), 4, 12, [ 21 | 1 1 1 1 1 1 0 0 0 0 0 0 22 | 0 0 0 0 0 0 1 1 0 0 0 0 23 | 0 0 0 0 0 0 0 0 1 1 0 0 24 | 0 0 0 0 0 0 0 0 0 0 1 1]) 25 | S = StabilizerCode(G) 26 | @test is_CSS_T_code(S) 27 | 28 | # Example 4/5 - [[16, 3, 2]], transversal T implements logical CCZ (up to logical Paulis) 29 | X = matrix(Oscar.Nemo.Native.GF(2), 3, 16,[ 30 | 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0; 31 | 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0; 32 | 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1]) 33 | Z = matrix(Oscar.Nemo.Native.GF(2), 10, 16, [ 34 | 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0; 35 | 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0; 36 | 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0; 37 | 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0; 38 | 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0; 39 | 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0; 40 | 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0; 41 | 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0; 42 | 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1; 43 | 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1]) 44 | S = CSSCode(X, Z) 45 | @test is_CSS_T_code(S) 46 | 47 | # Example 6 - [[64, 15, 4]], transversal T realizes a logical diagonal gate at the 3rd level that is a product of elementary gates 48 | C1 = ReedMullerCode(2, 6) 49 | C2 = ReedMullerCode(1, 6) 50 | S = CSSCode(C1, C2) 51 | @test is_CSS_T_code(S) 52 | 53 | # Example 7 - [[128, 21, 4]], transversal T realizes a logical diagonal gate at the 3rd level that is a product of elementary gates 54 | C1 = ReedMullerCode(2, 7) 55 | C2 = ReedMullerCode(1, 7) 56 | S = CSSCode(C1, C2) 57 | @test is_CSS_T_code(S) 58 | @test is_triorthogonal(C1.G) 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /test/Quantum/subsystem_code_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "Quantum/subsystem_code.jl" begin 2 | using Oscar, CodingTheory 3 | 4 | @testset "Stabilizer Subsystem code" begin 5 | # Poulin, "Stabilizer Formalism for Operator Quantum Error Correction", (2008) 6 | # [[9, 1, 4, 3]] gauged Shor code 7 | S = ["XXXXXXIII", "XXXIIIXXX", "ZZIZZIZZI","IZZIZZIZZ"] 8 | # these are the {X, Z} pairings 9 | G_ops = ["IZZIIIIII", "IIXIIIIIX", "IIIIZZIII", "IIIIIXIIX", "ZZIIIIIII", "XIIIIIXII", "IIIZZIIII", "IIIXIIXII"] 10 | G = S ∪ G_ops 11 | L = ["ZZZZZZZZZ", "XXXXXXXXX"] 12 | Q = SubsystemCode(G) 13 | @test length(Q) == 9 14 | @test dimension(Q) == 1 15 | @test Q.r == 4 16 | @test_broken minimum_distance(Q) == 3 17 | @test LogicalTrait(typeof(Q)) == HasLogicals() 18 | @test GaugeTrait(typeof(Q)) == HasGauges() 19 | 20 | Q2 = SubsystemCode(S, L, G_ops) 21 | @test are_equivalent(Q, Q2) 22 | 23 | # # TODO: BaconShorCode 24 | Q3 = BaconShorCode(3, 3) 25 | 26 | F = Oscar.Nemo.Native.GF(2) 27 | A = matrix(F, 3, 3, ones(Int, 3, 3)) 28 | Q4 = BravyiBaconShorCode(A) 29 | @test dimension(Q4) == rank(A) 30 | # # TODO: add a test here on the min distances 31 | # min d should be min(row wts, col wts) 32 | @test are_equivalent(Q3, Q4) 33 | end 34 | 35 | # # Klappenecker and Sarvepalli (2007) give a CSS construction equivalent to Bacon-Shor 36 | 37 | end 38 | -------------------------------------------------------------------------------- /test/chain_complex_test.jl: -------------------------------------------------------------------------------- 1 | # @testitem "chain_complex.jl" begin 2 | using Oscar 3 | using CodingTheory 4 | using CodingTheory: CTFieldTypes, CTFieldElem , CTMatrixTypes, CTPolyRing, CTPolyRingElem, CTGroupAlgebra , CTChainComplex 5 | 6 | struct ChainComplex{T <: CTMatrixTypes} 7 | F::CTFieldTypes 8 | length::UInt8 9 | boundaries::Vector{T} 10 | end 11 | 12 | """ 13 | ChainComplex(chain::Vector{T}) where T <: CTMatrixTypes 14 | 15 | Return a chain complex based on the boundary maps in `chain`. 16 | """ 17 | function ChainComplex(chain::Vector{T}) where T <: CTMatrixTypes 18 | F = base_ring(chain[1]) 19 | all(x -> base_ring(x) == F, chain) || throw(ArgumentError("All inputs must be over the same base ring")) 20 | # println([size(mat) for mat in chain]) 21 | 22 | # check to make sure matrices define a valid chain complex 23 | len = length(chain) 24 | # this is one place people may actually not index linearly 25 | for i in 1:len - 1 26 | iszero(chain[i] * chain[i + 1]) || throw(ArgumentError("Boundary maps must satisfy `iszero(chain[i] * chain[i + 1])`")) 27 | end 28 | return ChainComplex{T}(F, len + 1, chain) 29 | end 30 | 31 | """ 32 | ChainComplex(F::CTFieldTypes, len::Integer, boundaries::Vector{T}) where T <: CTMatrixTypes 33 | 34 | Return the chain complex based on the input data. 35 | """ 36 | ChainComplex(F::CTFieldTypes, len::Integer, boundaries::Vector{T}) where T <: CTMatrixTypes = ChainComplex{T}(F, len, boundaries) 37 | 38 | """ 39 | cochain(chain::ChainComplex) 40 | 41 | Return the dual of the chain complex. 42 | """ 43 | cochain(chain::ChainComplex) = ChainComplex([transpose(∂) for ∂ in reverse(chain.boundaries)]) 44 | 45 | """ 46 | ⊗(chain_A::ChainComplex{T}, chain_B::ChainComplex{T}) where T <: CTMatrixTypes 47 | tensor_product(chain_A::ChainComplex{T}, chain_B::ChainComplex{T}) where T <: CTMatrixTypes 48 | 49 | Return the total complex of the tensor product of the two chains. 50 | """ 51 | function ⊗(chain_A::ChainComplex{T}, chain_B::ChainComplex{T}) where T <: CTMatrixTypes 52 | chain_A.F == chain_B.F || throw(ArgumentError("Both chains must be over the same base ring")) 53 | 54 | identity_maps_A = [[identity_matrix(chain_A.F, nrows(mat)) for mat in chain_A.boundaries]; identity_matrix(chain_A.F, ncols(chain_A.boundaries[end]))] 55 | identity_maps_B = [[identity_matrix(chain_A.F, nrows(mat)) for mat in chain_B.boundaries]; identity_matrix(chain_A.F, ncols(chain_B.boundaries[end]))] 56 | boundaries = Vector{T}() 57 | n_max = chain_A.length + chain_B.length - 2 58 | 59 | ns = [[(i, n - 1 - i) for i in 0:chain_A.length - 1 if n - 1 - i in 0:chain_B.length - 1] for n in 1:chain_A.length + chain_B.length - 2] 60 | for (n, indices) in reverse(collect(enumerate(ns))) 61 | num_cols = n == n_max ? ncols(chain_A.boundaries[end]) * ncols(chain_B.boundaries[end]) : nrows(boundaries[1]) 62 | ∂ = zero_matrix(chain_A.F, 0, num_cols) 63 | for (i, j) in indices 64 | temp = if i == chain_A.length - 1 65 | temp2 = (-1)^i * identity_maps_A[i + 1] ⊗ chain_B.boundaries[j + 1] 66 | hcat(zero_matrix(chain_A.F, nrows(temp2), num_cols - ncols(temp2)), temp2) 67 | elseif j == chain_B.length - 1 68 | temp2 = chain_A.boundaries[i + 1] ⊗ identity_maps_B[j + 1] 69 | hcat(temp2, zero_matrix(chain_A.F, nrows(temp2), num_cols - ncols(temp2))) 70 | else 71 | temp2 = chain_A.boundaries[i + 1] ⊗ identity_maps_B[j + 1] 72 | temp3 = (-1)^i * identity_maps_A[i + 1] ⊗ chain_B.boundaries[j + 1] 73 | num_cols1 = 0 74 | for l in j + 2:chain_B.length - 1 75 | k = n - l + 1 76 | if k in eachindex(chain_A.boundaries) 77 | num_cols1 += nrows(chain_A.boundaries[k]) * ncols(chain_B.boundaries[l]) 78 | end 79 | end 80 | num_cols2 = num_cols - num_cols1 - ncols(temp2) - ncols(temp3) 81 | hcat(zero_matrix(chain_A.F, nrows(temp2), num_cols1), temp3, temp2, zero_matrix(chain_A.F, nrows(temp2), num_cols2)) 82 | end 83 | ∂ = vcat(∂, temp) 84 | end 85 | pushfirst!(boundaries, ∂) 86 | end 87 | 88 | return ChainComplex(boundaries) 89 | end 90 | tensor_product(chain_A::ChainComplex, chain_B::ChainComplex) = ⊗(chain_A, chain_B) 91 | 92 | # TODO: better chain complex tests 93 | # these tests are simply to check that it runs at all 94 | # @test !isnothing(tensor_product(ChainComplex(Q15RM()), ChainComplex(Q1573()))) 95 | # @test !isnothing(distance_balancing(Q15RM(), RepetitionCode(2,4))) 96 | # end 97 | -------------------------------------------------------------------------------- /test/iterators_test.jl: -------------------------------------------------------------------------------- 1 | @testitem "iterators.jl" begin 2 | @testset "SubsetGrayCode iterates over all weight k subsets of {1,..,n} (single iterator)" begin 3 | len = 7 4 | weight = 5 5 | sgc = CodingTheory.SubsetGrayCode(len, weight, UInt(21), UInt(0)) 6 | all_subsets_gray = fill(fill(0, weight), length(sgc)) 7 | subset = collect(1:sgc.k) 8 | state = (subset, 1, fill(-1, 3)) 9 | for i in 1:length(sgc) 10 | all_subsets_gray[i] = deepcopy(subset) 11 | next = iterate(sgc, state) 12 | isnothing(next) && break 13 | (_, state) = next 14 | (subset, _, _) = state 15 | end 16 | sort!(all_subsets_gray) 17 | all_subsets_hecke = CodingTheory.Oscar.subsets(collect(1:len), weight) 18 | sort!(all_subsets_hecke) 19 | @test length(all_subsets_gray) == 21 20 | @test all_subsets_gray == all_subsets_hecke 21 | end 22 | 23 | function pushOrDel(a::Set{T}, b::T...) where T <: Any 24 | c = deepcopy(a) 25 | pushOrDel!(c,b) 26 | return c 27 | end 28 | 29 | function pushOrDel!(a::Set{T}, b::T...) where T <: Any 30 | for elem in b 31 | if elem in a 32 | delete!(a, elem) 33 | else 34 | push!(a, elem) 35 | end 36 | end 37 | return nothing 38 | end 39 | 40 | @testset "Rank/Unrank functions" begin 41 | subset1 = Vector{UInt}([1, 2, 3]) # a subset of weight 3 42 | k1 = UInt(3) 43 | n1 = UInt(5) 44 | rank1 = CodingTheory._subset_rank(subset1, k1) 45 | @test rank1 == 1 46 | result1 = zeros(Int, k1) 47 | CodingTheory._subset_unrank!(UInt128(rank1), n1, result1) 48 | @test result1 == subset1 49 | 50 | subset2 = UInt.([1, 3, 5]) 51 | k2 = UInt(3) 52 | n2 = UInt(5) 53 | rank2 = CodingTheory._subset_rank(subset2, k2) 54 | @test rank2 == 8 55 | result2 = zeros(Int, k2) 56 | CodingTheory._subset_unrank!(UInt128(rank2), n2, result2) 57 | @test result2 == subset2 58 | 59 | k3 = UInt(3) 60 | n3 = UInt(5) 61 | result3 = zeros(Int, k3) 62 | results = Set{Vector{UInt64}}() 63 | bin = binomial(n3, k3) 64 | for i::BigInt in collect(1: bin) 65 | CodingTheory._subset_unrank!(UInt128(i), n3, result3) 66 | pushOrDel!(results, deepcopy(Vector{UInt64}(result3))) 67 | end 68 | all_subsets_hecke = Set(CodingTheory.Hecke.subsets(collect(1:n3), Int(k3))) 69 | @test results == all_subsets_hecke 70 | end 71 | end -------------------------------------------------------------------------------- /test/runtests.jl: -------------------------------------------------------------------------------- 1 | using Oscar 2 | using CodingTheory 3 | using TestItemRunner 4 | 5 | if get(ENV, "GPU_TESTS", "") != "true" 6 | println("skipping gpu tests (set GPU_TESTS = true to test gpu)") 7 | end 8 | 9 | # filter for the test 10 | test_filter = ti -> begin 11 | exclude = Symbol[] 12 | if get(ENV, "JET_TEST", "") != "true" 13 | push!(exclude, :jet) 14 | end 15 | if !(VERSION >= v"1.10") 16 | push!(exclude, :doctests) 17 | push!(exclude, :aqua) 18 | end 19 | 20 | if get(ENV, "GPU_TESTS", "") != "true" 21 | push!(exclude, :gpu) 22 | end 23 | 24 | if !(Base.Sys.islinux() & (Int === Int64)) 25 | push!(exclude, :bitpack) 26 | end 27 | 28 | return all(!in(exclude), ti.tags) 29 | end 30 | 31 | # unit tests need to be deterministic for debugging so we should set the seed before running the whole test suite 32 | println("Random.seed initialized to 0") 33 | CodingTheory.Random.seed!(0) 34 | 35 | println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...") 36 | 37 | @run_package_tests filter = test_filter 38 | 39 | # TODO: should setup test for traits 40 | # TODO: add tests for _standardformstabilizer 41 | # TODO: add tests for _logicalsstandardform 42 | -------------------------------------------------------------------------------- /test/testcases.jl: -------------------------------------------------------------------------------- 1 | **************************** 2 | linearcode.jl 3 | **************************** 4 | # we can preform several standard methods of building new codes from old ones 5 | # direct sum 6 | D = C ⊕ C; 7 | generatormatrix(D) 8 | D = directsum(C, C); 9 | generatormatrix(D) 10 | # direct product 11 | D = C ⊗ C; 12 | generatormatrix(D) 13 | D = directproduct(C, C); 14 | generatormatrix(D) 15 | D = tensorproduct(C, C); 16 | generatormatrix(D) 17 | # the most common form of extending a code is to add parity check column to right of generator matrix 18 | D = extend(C); 19 | length(D) 20 | generatormatrix(D) 21 | F3, _ = FiniteField(3, 1, "α"); 22 | # M2 = MatrixSpace(Nemo.GF(3), 2, 4); #- ex page 15 23 | G2 = matrix(F3, [1 0 1 1; 0 1 1 -1]); 24 | C2 = LinearCode(G2); 25 | generatormatrix(extend(C2)) 26 | paritycheckmatrix(extend(C2)) 27 | # in cases such as this it is often useful to keep track of the original generator matrix which 28 | # was used to generate the code. can also do this for the parity check matrix. in cases where this 29 | # does not make sense, the normal generator or parity check matrix is returned 30 | paritycheckmatrix(D) 31 | # puncturing deletes columns from a generator matrix 32 | C2 = puncture(D, [length(D)]); 33 | isequivalent(C, C2) 34 | generatormatrix(C) == generatormatrix(C2) 35 | # to expurgate a code is to delete rows from generator matrix and then remove any potentially resulting zero columns 36 | D = expurgate(C, [dimension(C)]); 37 | length(D) 38 | dimension(D) 39 | generatormatrix(D) 40 | # to augment is to add rows to the generator matrix 41 | # in this example we are going to first add the all 1's vector to the code, which is common 42 | # we note that the all 1's vector is actually already in the code so the code 43 | # shouldn't change 44 | # M = MatrixSpace(Nemo.GF(2), 1, 7); 45 | v = matrix(F, [1 for i in 1:7]') 46 | v ∈ C 47 | D = augment(C, v); 48 | generatormatrix(D) == generatormatrix(C) 49 | v = matrix(F, [1 0 1 0 1 1 1]) 50 | v ∈ C 51 | D = augment(C, v); 52 | generatormatrix(D) 53 | # to shorten is to expurgate then puncture 54 | D = shorten(C, [length(C)]); 55 | generatormatrix(D) 56 | originalgeneratormatrix(D) == generatormatrix(C) 57 | # M2 = MatrixSpace(Nemo.GF(2), 3, 6); 58 | G2 = matrix(F, [1 0 0 1 1 1; 0 1 0 1 1 1; 0 0 1 1 1 1]); 59 | C2 = LinearCode(G2); 60 | generatormatrix(shorten(C2, [5, 6])) 61 | # the most common form of lengthening a code it to augment the all 1's vector and then extend 62 | D = lengthen(C); 63 | generatormatrix(D) 64 | # the (u | u + v)- or Plotkin construction 65 | # M2 = MatrixSpace(Nemo.GF(2), 3, 4); 66 | # M3 = MatrixSpace(Nemo.GF(2), 1, 4); 67 | G2 = matrix(F, [1 0 1 0; 0 1 0 1; 0 0 1 1]); 68 | G3 = matrix(F, [1 1 1 1]); 69 | C2 = LinearCode(G2); 70 | C3 = LinearCode(G3); 71 | generatormatrix(uuplusv(C2, C3)) #- ex p. 19 72 | 73 | 74 | 75 | **************************** 76 | cyclotomic.jl 77 | **************************** 78 | # ord_n(q) 79 | q = 2; 80 | n = 15; 81 | b = 3; 82 | δ = 4; 83 | ord(n, q) 84 | # at the moment this comes back sorted so one can easily record a coset representative 85 | coset = cyclotomiccoset(3, q, n, false) 86 | cyclotomiccoset(3, q, n, true) 87 | allcyclotomiccosets(q, n, true) 88 | dualqcosets(q, n, [coset]) 89 | complementqcosets(q, n, [coset]) 90 | # pairings 91 | qcosetpairings(q, n) 92 | # find all in a range 93 | qcosettable(10, 13, q) 94 | 95 | 96 | **************************** 97 | cycliccode.jl 98 | **************************** 99 | G = matrix(F, [1 0 0 0 0 1 1; 100 | 0 1 0 0 1 0 1; 101 | 0 0 1 0 1 1 0; 102 | 0 0 0 1 1 1 1]); 103 | D = LinearCode(G); 104 | CD = directsum(C, D); 105 | generatormatrix(CD) 106 | # the generator matrix of a cyclic code is kept in cyclic form but the standard form is of course always available 107 | generatormatrix(C) 108 | generatormatrix(C, true) 109 | # note how the previous code auto detected that it was a BCH code and returned an object of type BCHCode 110 | complement(C) 111 | # the above is equivalent to 112 | B = BCHCode(q, n, δ, b) 113 | C == B 114 | # the optional offset parameter is set to 0 by default 115 | BCHCode(q, n, δ) 116 | # for cyclic codes, we can 117 | C ∩ B == C 118 | B = BCHCode(q, n, δ - 1, b + 4) 119 | D = C ∩ B # check later that this is == repetition code 120 | C + B 121 | 122 | 123 | # Remove? 124 | We will only be concerned with cyclic Reed-Solomon codes, but the more general, and original, definition of Reed-Solomon codes will lead us into the final family of codes we will use in this work. Let $\mathcal{P}_k(x)$ denote the set of polynomials of degree less than $k$ in $\mathbb{F}_{p^m}[x]$. The Reed-Solomon code of length $n \leq p^m$ and dimension $k < n$ is given by 125 | 126 | $$\mathrm{RS}_{p^m}(n, k) = \{ (f(\alpha_1), \dots, f(\alpha_n)) \mid f(x) \in \mathcal{P}_k(x)\},$$ 127 | 128 | where $\alpha_i \in \mathbb{F}_{p^m}$. The most common case $n = p^m$ is the extended code of the cyclic definition, but only the case $n = p^m -1$ is, in general, cyclic. The proof of this is direct application of the Chinese Remainder Theorem. --------------------------------------------------------------------------------