diff --git a/.gitignore b/.gitignore index ad93f02..8ec43fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Manifest.toml -.vscode/ \ No newline at end of file +.vscode/ +.DS_Store \ No newline at end of file diff --git a/src/LDPCDecoders.jl b/src/LDPCDecoders.jl index e996268..b2b84fe 100644 --- a/src/LDPCDecoders.jl +++ b/src/LDPCDecoders.jl @@ -14,7 +14,6 @@ export BeliefPropagationDecoder include("generator.jl") -include("util.jl") include("parity.jl") include("bp_decoder.jl") include("bp_simulator.jl") @@ -22,7 +21,7 @@ include("it_decoder.jl") include("parity_generator.jl") include("decoders/abstract_decoder.jl") -include("decoders/belief_propogation.jl") +include("decoders/belief_propagation.jl") include("syndrome_bp_decoder.jl") include("syndrome_simulator.jl") include("syndrome_it_decoder.jl") diff --git a/src/bp_decoder.jl b/src/bp_decoder.jl index 8cff52c..45ac915 100644 --- a/src/bp_decoder.jl +++ b/src/bp_decoder.jl @@ -86,7 +86,7 @@ function bp_decode(parity_check_matrix, received_message, error_rate, max_iterat message_c2v = zeros(num_checks, num_bits) initialise_checks!(parity_check_matrix, message_c2v, syndrome, num_vs, num_cs) - # Intialize llr for variable nodes + # Initialize llr for variable nodes vllr = llr.(received_message, error_rate) # Send message from variable to check nodes diff --git a/src/bp_simulator.jl b/src/bp_simulator.jl index 96ff540..3df4f7f 100644 --- a/src/bp_simulator.jl +++ b/src/bp_simulator.jl @@ -38,7 +38,7 @@ function bp_simulate(parity_check_matrix, generator_matrix, error_rate, max_tria # syndrome = (pcm * error) .% 2 - # Belief propogation decoder + # Belief propagation decoder decoded_message, success = bp_decode(received_message, parity_check_matrix, 0.1) println("decoded message = ", decoded_message) display(decoded_message) diff --git a/src/decoders/belief_propogation.jl b/src/decoders/belief_propagation.jl similarity index 100% rename from src/decoders/belief_propogation.jl rename to src/decoders/belief_propagation.jl diff --git a/src/syndrome_bp_decoder.jl b/src/syndrome_bp_decoder.jl index 346046e..e30a310 100644 --- a/src/syndrome_bp_decoder.jl +++ b/src/syndrome_bp_decoder.jl @@ -1,4 +1,4 @@ -# TODO: Depricated, to be removed. Only new implementation is required. +# TODO: Deprecated, to be removed. Only new implementation is required. function syndrome_decode(pcm, pcmT, syndrome, max_iters, channel_probs, b2c, c2b, log_probabs, error) # Get size of Parity check matrix @@ -6,7 +6,7 @@ function syndrome_decode(pcm, pcmT, syndrome, max_iters, channel_probs, b2c, c2b rows = rowvals(pcm) rowsT = rowvals(pcmT) - # Initiliase bit to check messages + # Initialize bit to check messages for j in 1:n for k in nzrange(pcm, j) i = rows[k] @@ -108,7 +108,7 @@ function syndrome_decode!(decoder::BeliefPropagationDecoder, setup::BeliefPropag rows = rowvals(decoder.sparse_H) rowsT = rowvals(decoder.sparse_HT) - # Initiliase bit to check messages + # Initialize bit to check messages for j in 1:n for k in nzrange(decoder.sparse_H, j) i = rows[k] diff --git a/src/syndrome_it_simulate.jl b/src/syndrome_it_simulate.jl index 6ee6171..512fc10 100644 --- a/src/syndrome_it_simulate.jl +++ b/src/syndrome_it_simulate.jl @@ -8,7 +8,7 @@ function syndrome_it_simulate(parity_check_matrix, physical_error_rate, max_tria @info "Simulating for $physical_error_rate for $max_trials trials" tenths = floor(max_trials/10) - # Initalization + # Initialization err = zeros(Bool, num_bits) votes = zeros(Int, num_bits) curr_syn = zeros(Bool, num_checks) diff --git a/src/syndrome_simulator.jl b/src/syndrome_simulator.jl index 523855b..532b7d3 100644 --- a/src/syndrome_simulator.jl +++ b/src/syndrome_simulator.jl @@ -10,7 +10,7 @@ function syndrome_simulate(parity_check_matrix, physical_error_rate, max_trials) @info "Simulating for $physical_error_rate for $max_trials trials" tenths = floor(max_trials/10) - # Initalization + # Initialization log_probabs = zeros(num_bits) channel_probabs = fill(physical_error_rate, num_bits) b2c = zeros(num_checks, num_bits) @@ -24,7 +24,7 @@ function syndrome_simulate(parity_check_matrix, physical_error_rate, max_trials) syndrome = (parity_check_matrix * error) .% 2 - # Belief propogation decoder + # Belief propagation decoder decoded_error, decoded = syndrome_decode(parity_check_matrix, parity_check_matrix_T, syndrome, 10, copy(channel_probabs), copy(b2c), copy(c2b), copy(log_probabs), copy(err)) if decoded == true diff --git a/src/util.jl b/src/util.jl deleted file mode 100644 index 6a31f24..0000000 --- a/src/util.jl +++ /dev/null @@ -1,58 +0,0 @@ -function base2(dec, length=0) - binary = bitstring(UInt(dec)) - binary = split(binary, "") - binary = [parse(Int, x) for x in binary] - n = size(binary, 1) - return binary[(n - length + 1):n] -end - -function row_echelon(matrix, full=false) - numrows, numcols = size(matrix) - pivot_row = 1 - pivot_col = [] - - the_matrix = matrix - for col in range(1,numcols) - if the_matrix[pivot_row, col] != 1 - swap_row_index = pivot_row + findmax(the_matrix[pivot_row:numrows, col]) - - if the_matrix[swap_row_index, col] == 1 - the_matrix[[swap_row_index, pivot_row]] = the_matrix[[pivot_row, swap_row_index]] - - transform_matrix[[swap_row_index, pivot_row]] = transform_matrix[[pivot_row, swap_row_index]] - end - - end - if the_matrix[pivot_row, col] - - if not full - elimination_range = [k for k in range(pivot_row + 1, num_rows)] - else - elimination_range = [k for k in range(1:num_rows) if k != pivot_row] - end - - for j in elimination_range - - if the_matrix[j, col] != 0 && pivot_row != j - - the_matrix[j] = (the_matrix[j] + the_matrix[pivot_row]) % 2 - - transform_matrix[j] = (transform_matrix[j] + transform_matrix[pivot_row]) % 2 - end - end - pivot_row += 1 - pivot_cols.append(col) - end - - if pivot_row >= numrows - break - end - end - # The rank is equal to the maximum pivot index - matrix_rank = pivot_row - row_esch_matrix = the_matrix - - return [row_esch_matrix, matrix_rank, transform_matrix, pivot_cols] -end - -