Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding classical Reed-Muller Code #244

Merged
merged 12 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## v0.9.1 - 2024-03-20

- Implementedd the classical Reed-Muller code
- Implemented `iscss` function to identify whether a given code is known to be a CSS (Calderbank-Shor-Steane) code.

## v0.9.0 - 2024-03-19
Expand Down
2 changes: 2 additions & 0 deletions src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export parity_checks, parity_checks_x, parity_checks_z, iscss,
isdegenerate, faults_matrix,
naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit,
RepCode,
ReedMuller,
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
CSS,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
Toric, Gottesman,
Expand Down Expand Up @@ -345,4 +346,5 @@ include("codes/shorcode.jl")
include("codes/clevecode.jl")
include("codes/toric.jl")
include("codes/gottesman.jl")
include("codes/reedmullercode.jl")
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
end #module
31 changes: 31 additions & 0 deletions src/ecc/codes/reedmullercode.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
abstract type ClassicalCode end

struct ReedMuller <: ClassicalCode
r::Int
m::Int

function ReedMuller(r, m)
if r < 0 || m < 1
throw(ArgumentError("Invalid parameters: r must be non-negative and m must be positive"))
end
new(r, m)
end
end

function construct(m, i)
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
return repeat([fill(1, 2^(m - i - 1)); fill(0, 2^(m - i - 1))], outer = 2^i)
end

function vmult(vecs...)
return [reduce(*, a, init=1) for a in zip(vecs...)]
end

function parity_checks(c::ReedMuller)
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
r=c.r
m=c.m
rx = [construct(m, i) for i in 0:m - 1]
row_matrices = [reduce(vmult, [rx[i + 1] for i in S], init = ones(Int, 2^m)) for s in 0:r for S in combinations(0:m - 1, s)]
rows = length(row_matrices)
cols = length(row_matrices[1])
H = reshape(vcat(row_matrices...), cols, rows)'
end
4 changes: 4 additions & 0 deletions test/test_throws.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QuantumClifford
using QuantumClifford.ECC
using QuantumClifford: rank, mul_left!, mul_right!
using InteractiveUtils: subtypes

Expand Down Expand Up @@ -65,3 +66,6 @@ for m in [sMX,sMZ,sMY,sMRX,sMRZ,sMRY]
@test_throws ArgumentError m(0,1)
@test_throws ArgumentError m(-1,0)
end

@test_throws ArgumentError ReedMuller(-1, 3)
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
@test_throws ArgumentError ReedMuller(1, 0)
Loading