Skip to content

Commit

Permalink
without custom MACOS repair command
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumgizmos committed Nov 23, 2023
1 parent 0b9f198 commit 908fdfd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
CIBW_BUILD: "${{ matrix.os_dist.dist }}"
MACOSX_DEPLOYMENT_TARGET: "10.15"
CIBW_ARCHS_MACOS: "arm64 x86_64"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} -v {wheel}
# CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} -v {wheel}
strategy:
fail-fast: false
matrix:
Expand Down
80 changes: 24 additions & 56 deletions python_test/test_scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import ldpc.codes
import ldpc.code_util

import scipy.sparse

import numpy as np
import ldpc.codes
from ldpc import BpDecoder
Expand All @@ -11,79 +13,45 @@
from ldpc.monte_carlo_simulation import MonteCarloBscSimulation
import ldpc.mod2

if __name__ == "__main__":

H = ldpc.codes.rep_code(5)
error_rate = 0.001
dec = BpOsdDecoder(H, error_rate=error_rate, max_iter = 0, bp_method="product_sum", input_vector_type = "syndrome", osd_method="osd_e", osd_order = 1)
assert dec.osd_order == 1
from qec.codes import ToricCode

span = ldpc.mod2.row_span(ldpc.codes.rep_code(5))
print(span.toarray())

H = ldpc.codes.hamming_code(3)

d = ldpc.mod2.compute_exact_code_distance(H)

print(d)

import numpy as np
import ldpc.codes
from ldpc import BeliefFindDecoder
if __name__ == "__main__":

H = ldpc.codes.ring_code(3)

## The
bf = BeliefFindDecoder(
H,
error_rate = 0.1,
bp_method = 'product_sum',
max_iter = 1,
schedule = 'serial',
uf_method = True, # If uf_method is set to False, union-find clusters are solved using a peeling decoder
bits_per_step = 1 ## this is the number of bits by which clusters are expanded in each growth step
)

error = np.random.randint(size=H.shape[0], low=0, high=2).astype(np.uint8)
syndrome = H@error % 2


print(f"Syndrome: {syndrome.__repr__()}")
H1 = ldpc.codes.hamming_code(3)
H2 = ldpc.codes.hamming_code(3)

decoding = bf.decode(syndrome)
print(f"Decoding: {decoding}")
decoding_syndrome = H@decoding % 2
print(f"Decoding syndrome: {decoding_syndrome}")
H3 = scipy.sparse.hstack([H1, scipy.sparse.csr_matrix((H1.shape[0], H2.shape[1]))])
H4 = scipy.sparse.hstack([scipy.sparse.csr_matrix((H2.shape[0], H1.shape[1])), H2])

H = scipy.sparse.vstack([H3, H4]).astype(np.uint8)

H5 = scipy.sparse.csr_matrix((H.shape[0], H.shape[1]))


vec= np.zeros(H.shape[1]).astype(np.uint8)
vec[[6,7]] = 1
vec = scipy.sparse.csr_matrix(vec)

# syndrome
H = scipy.sparse.vstack([H, vec])

print(H.toarray())


# H = np.array([[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0],
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
# [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1],
# [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
# [0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0],
# [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
# [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0],
# [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0],
# [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0]])

c1 = H[:,:7]
c2 = H[:,7:]

# n,k,d = ldpc.code_util.compute_code_parameters(H,timeout_seconds=0.1)
# print(f"n = {n}, k = {k}, d = {d}")
# print(c1.toarray())
# print(c2.toarray())

# # exit(22)
# print(vec.toarray())


# for _ in range(10000):
# H = ldpc.codes.random_binary_code(8,15,4, variance=1)
# n,k,d = ldpc.code_util.compute_code_parameters(H,timeout_seconds=0.001)
plu1 = ldpc.mod2.PluDecomposition(c1)
plu2 = ldpc.mod2.PluDecomposition(c2)

# if d > 4:
# print(f"n = {n}, k = {k}, d = {d}")
# print(H.toarray().__repr__())
print(plu1.U.toarray())
print(plu2.L.toarray())

0 comments on commit 908fdfd

Please sign in to comment.