-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
564 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "QuantumClifford" | ||
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1" | ||
authors = ["Stefan Krastanov <[email protected]> and QuantumSavory community members"] | ||
version = "0.9.9" | ||
version = "0.9.10" | ||
|
||
[deps] | ||
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" | ||
|
@@ -24,6 +24,7 @@ SumTypes = "8e1ec7a9-0e02-4297-b0fe-6433085c89f2" | |
|
||
[weakdeps] | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21" | ||
LDPCDecoders = "3c486d74-64b9-4c60-8b1a-13a564e77efb" | ||
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
|
@@ -33,6 +34,7 @@ QuantumOpticsBase = "4f57444f-1401-5e15-980d-4471b28d5678" | |
|
||
[extensions] | ||
QuantumCliffordGPUExt = "CUDA" | ||
QuantumCliffordHeckeExt = "Hecke" | ||
QuantumCliffordLDPCDecodersExt = "LDPCDecoders" | ||
QuantumCliffordMakieExt = "Makie" | ||
QuantumCliffordPlotsExt = "Plots" | ||
|
@@ -46,14 +48,15 @@ Combinatorics = "1.0" | |
DataStructures = "0.18" | ||
DocStringExtensions = "0.9" | ||
Graphs = "1.9" | ||
Hecke = "0.28, 0.29, 0.30, 0.31, 0.32, 0.33" | ||
HostCPUFeatures = "0.1.6" | ||
ILog2 = "0.2.3" | ||
InteractiveUtils = "1.9" | ||
LDPCDecoders = "0.3.1" | ||
LinearAlgebra = "1.9" | ||
MacroTools = "0.5.9" | ||
Makie = "0.20, 0.21" | ||
Nemo = "0.42, 0.43, 0.44, 0.45, 0.46" | ||
Nemo = "^0.42.1, 0.43, 0.44, 0.45, 0.46" | ||
Plots = "1.38.0" | ||
PrecompileTools = "1.2" | ||
PyQDecoders = "0.2.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module QuantumCliffordHeckeExt | ||
|
||
using DocStringExtensions | ||
|
||
import QuantumClifford, LinearAlgebra | ||
import Hecke: Group, GroupElem, AdditiveGroup, AdditiveGroupElem, | ||
GroupAlgebra, GroupAlgebraElem, FqFieldElem, representation_matrix, dim, base_ring, | ||
multiplication_table, coefficients, abelian_group, group_algebra | ||
import Nemo: characteristic, matrix_repr, GF, ZZ | ||
|
||
import QuantumClifford.ECC: AbstractECC, CSS, ClassicalCode, | ||
hgp, code_k, code_n, code_s, iscss, parity_checks, parity_checks_x, parity_checks_z, parity_checks_xz, | ||
two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes | ||
|
||
include("types.jl") | ||
include("lifted.jl") | ||
include("lifted_product.jl") | ||
|
||
end # module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
""" | ||
$TYPEDEF | ||
Classical codes lifted over a group algebra, used for lifted product code construction ([panteleev2021degenerate](@cite), [panteleev2022asymptotically](@cite)) | ||
The parity-check matrix is constructed by applying `repr` to each element of `A`, | ||
which is mathematically a linear map from a group algebra element to a binary matrix. | ||
The size of the parity check matrix will enlarged with each element of `A` being inflated into a matrix. | ||
The procedure is called a lift [panteleev2022asymptotically](@cite). | ||
## Constructors | ||
A lifted code can be constructed via the following approaches: | ||
1. A matrix of group algebra elements. | ||
2. A matrix of group elements, where a group element will be considered as a group algebra element by assigning a unit coefficient. | ||
3. A matrix of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified. | ||
The default `GA` is the group algebra of `A[1, 1]`, the default representation `repr` is the permutation representation. | ||
## The representation function `repr` | ||
In this struct, we use the default representation function `default_repr` to convert a `GF(2)`-group algebra element to a binary matrix. | ||
The default representation, provided by `Hecke`, is the permutation representation. | ||
We also accept a custom representation function. | ||
Such a customization would be useful to reduce the number of bits required by the code construction. | ||
For example, if we use a D4 group for lifting, our default representation will be `8×8` permutation matrices, | ||
where 8 is the group's order. | ||
However, we can find a `4×4` matrix representation for the group, | ||
e.g. by using the typical [`2×2` representation](https://en.wikipedia.org/wiki/Dihedral_group) | ||
and converting it into binary representation by replacing "1" with the Pauli I, and "-1" with the Pauli X matrix. | ||
See also: [`LPCode`](@ref). | ||
$TYPEDFIELDS | ||
""" | ||
struct LiftedCode <: ClassicalCode | ||
"""the base matrix of the code, whose elements are in a group algebra.""" | ||
A::GroupAlgebraElemMatrix | ||
"""the group algebra for which elements in `A` are from.""" | ||
GA::GroupAlgebra | ||
""" | ||
a function that converts a group algebra element to a binary matrix; | ||
default to be the permutation representation for GF(2)-algebra.""" | ||
repr::Function | ||
|
||
function LiftedCode(A::GroupAlgebraElemMatrix; GA::GroupAlgebra=parent(A[1, 1]), repr::Function) | ||
all(elem.parent == GA for elem in A) || error("The base ring of all elements in the code must be the same as the group algebra") | ||
new(A, GA, repr) | ||
end | ||
end | ||
|
||
default_repr(y::GroupAlgebraElem{FqFieldElem, <: GroupAlgebra}) = Matrix((x -> Bool(Int(lift(ZZ, x)))).(representation_matrix(y))) | ||
|
||
""" | ||
`LiftedCode` constructor using the default `GF(2)` representation (coefficients converted to a permutation matrix by `representation_matrix` provided by Hecke). | ||
""" # TODO doctest example | ||
function LiftedCode(A::Matrix{GroupAlgebraElem{FqFieldElem, <: GroupAlgebra}}; GA::GroupAlgebra=parent(A[1,1])) | ||
!(characteristic(base_ring(A[1, 1])) == 2) && error("The default permutation representation applies only to GF(2) group algebra; otherwise, a custom representation function should be provided") | ||
LiftedCode(A; GA=GA, repr=default_repr) | ||
end | ||
|
||
# TODO document and doctest example | ||
function LiftedCode(group_elem_array::Matrix{<: GroupOrAdditiveGroupElem}; GA::GroupAlgebra=group_algebra(GF(2), parent(group_elem_array[1,1])), repr::Union{Function, Nothing}=nothing) | ||
A = zeros(GA, size(group_elem_array)...) | ||
for i in axes(group_elem_array, 1), j in axes(group_elem_array, 2) | ||
A[i, j] = GA[A[i, j]] | ||
end | ||
if repr === nothing | ||
return LiftedCode(A; GA=GA, repr=default_repr) | ||
else | ||
return LiftedCode(A; GA=GA, repr=repr) | ||
end | ||
end | ||
|
||
# TODO document and doctest example | ||
function LiftedCode(shift_array::Matrix{Int}, l::Int; GA::GroupAlgebra=group_algebra(GF(2), abelian_group(l))) | ||
A = zeros(GA, size(shift_array)...) | ||
for i in 1:size(shift_array, 1) | ||
for j in 1:size(shift_array, 2) | ||
A[i, j] = GA[shift_array[i, j]%l+1] | ||
end | ||
end | ||
return LiftedCode(A; GA=GA, repr=default_repr) | ||
end | ||
|
||
function lift(repr::Function, mat::GroupAlgebraElemMatrix) | ||
vcat([hcat([repr(mat[i, j]) for j in axes(mat, 2)]...) for i in axes(mat, 1)]...) | ||
end | ||
|
||
function parity_checks(c::LiftedCode) | ||
return lift(c.repr, c.A) | ||
end | ||
|
||
code_n(c::LiftedCode) = size(c.A, 2) * size(zero(c.GA), 2) | ||
|
||
code_s(c::LiftedCode) = size(c.A, 1) * size(zero(c.GA), 1) |
Oops, something went wrong.