Skip to content

Commit

Permalink
implementation of Gottesman aka Quantum Hamming Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz committed Mar 11, 2024
1 parent 38aa86f commit e50a44b
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/ecc/codes/qhamming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,31 @@ function parity_checks(c::QHamming)

Hx[2, :] .= false

for i in 3:(rows - 1)
for a in 1:cols
Hx[i, a] = (a == 0) || (a % 2 == 0)
for a in 1:cols
Hx[3, a] = (a == 0) || (a % 2 == 0)
end

for row in 4:rows
for col in 1:cols
k = row - 3
m = 2^(c.j - k)
n = 2^(c.j - k)
if (col - 1) % (m + n) < m
if col % 2 == 0
Hx[row, col] = 1
else
Hx[row, col] = 0
end
else
if col % 2 == 0
Hx[row, col] = 0
else
Hx[row, col] = 1
end
end
end
end

for a in 1:cols
Hx[rows, a] = (a % 4 == 0) || (a % 4 == 1) ? 0 : 1
end
Expand Down

0 comments on commit e50a44b

Please sign in to comment.