Skip to content

Commit

Permalink
Fix: fixed iterations for bp decoder and added additional tests (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna-praneet authored Apr 7, 2024
1 parent 6c6cb2d commit 1df6933
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/decoders/belief_propagation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function decode!(decoder::BeliefPropagationDecoder, syndrome::AbstractVector) #
end

converged = false
for iter::Int in decoder.max_iters
for iter::Int in 1:decoder.max_iters
for i in 1:decoder.s
temp::Float64 = (-1) ^ syndrome[i]
for k::Int in nzrange(decoder.sparse_HT, i)
Expand Down
31 changes: 31 additions & 0 deletions test/test_bp_decoder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,40 @@ using LDPCDecoders
return ler
end

function test_ldpcdecoder()
H = LDPCDecoders.parity_check_matrix(1000,10,9);
decoder = LDPCDecoders.BeliefPropagationDecoder(H, 0.01, 100);
count = 0
for _ in 1:1000
error = rand(1000) .< 0.01;
syndrome = (H * error) .% 2;
guess, success = LDPCDecoders.decode!(decoder, syndrome);
count += error == guess
end
return 1-count/1000
end

function test_ldpcdecoder_old()
H = LDPCDecoders.parity_check_matrix(1000,10,9);
decoder = LDPCDecoders.BeliefPropagationDecoder(H, 0.01, 100);
count = 0
for _ in 1:1000
error = rand(1000) .< 0.01;
syndrome = (H * error) .% 2;
LDPCDecoders.reset!(decoder)
LDPCDecoders.syndrome_decode!(decoder, decoder.scratch, syndrome)
count += error == decoder.scratch.err
end
return 1-count/1000
end


@test test_bp_decoder()

# There is a low possibility of these tests failing
@test test_bp_decoder_batch() < 0.005
@test test_deprecated_syndrome_decoder() < 0.005

@test test_ldpcdecoder() < 0.001
@test test_ldpcdecoder_old() < 0.001
end

0 comments on commit 1df6933

Please sign in to comment.