Skip to content

Commit

Permalink
fix JET warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
royess committed Nov 27, 2024
1 parent 2fad88e commit 1570a2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/decoders/belief_propagation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct BeliefPropagationDecoder <: AbstractDecoder
scratch::BeliefPropagationScratchSpace
end

function BeliefPropagationDecoder(H, per::Float64, max_iters::Int)
function BeliefPropagationDecoder(H::Union{SparseArrays.SparseMatrixCSC{Bool,Int}, BitMatrix}, per::Float64, max_iters::Int)
s, n = size(H)
sparse_H = sparse(H)
sparse_HT = sparse(H')
Expand Down Expand Up @@ -108,7 +108,7 @@ true
function decode!(decoder::BeliefPropagationDecoder, syndrome::AbstractVector) # TODO check if casting to bitarrays helps with performance -- if it does, set up warnings to the user for cases where they have not done the casting
reset!(decoder)
rows::Vector{Int} = rowvals(decoder.sparse_H);
rowsT::Vector{Int} = rowvals(decoder.sparse_HT);
rowsT::Vector{Int} = rowvals(decoder.sparse_HT);
setup = decoder.scratch

for j in 1:decoder.n
Expand Down Expand Up @@ -138,7 +138,7 @@ function decode!(decoder::BeliefPropagationDecoder, syndrome::AbstractVector) #

for j in 1:decoder.n
temp::Float64 = setup.channel_probs[j] / (1 - setup.channel_probs[j])

for k in nzrange(decoder.sparse_H, j)
setup.bit_2_check[rows[k],j] = temp
temp *= setup.check_2_bit[rows[k],j]
Expand Down Expand Up @@ -166,7 +166,7 @@ function decode!(decoder::BeliefPropagationDecoder, syndrome::AbstractVector) #

syndrome_decoded = (decoder.sparse_H * setup.err) .% 2
if all(syndrome_decoded .== syndrome)
converged = true
converged = true
break # Break if converged
end
end
Expand Down
6 changes: 4 additions & 2 deletions src/decoders/belief_propagation_osd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct BeliefPropagationOSDDecoder <: AbstractDecoder
osd_order::Int
end

function BeliefPropagationOSDDecoder(H, per::Float64, max_iters::Int; osd_order::Int=0)
function BeliefPropagationOSDDecoder(H::BitMatrix, per::Float64, max_iters::Int; osd_order::Int=0)
bp_decoder = BeliefPropagationDecoder(H, per, max_iters)
return BeliefPropagationOSDDecoder(bp_decoder, H, osd_order)
end
Expand Down Expand Up @@ -90,7 +90,9 @@ function osd(H, syndrome, bp_err, osd_order)
# try all possible errors on the first `osd_order` bits within `most_reliable_cols`
if x != 0
trial_err = BitArray([x >> i & 1 for i in 0:osd_order-1])
err[most_reliable_cols[1:osd_order]] = trial_err
for j in 1:osd_order
err[most_reliable_cols[j]] = trial_err[j]
end
end
# then based on the `most_reliable_cols` part of errors, compute the `least_reliable_cols` part of errors
for (i, j) in zip(least_reliable_rows, least_reliable_cols)
Expand Down

0 comments on commit 1570a2f

Please sign in to comment.