diff --git a/src/ecc/codes/classical/hamming.jl b/src/ecc/codes/classical/hamming.jl index 6a187e5fa..2a39d815f 100644 --- a/src/ecc/codes/classical/hamming.jl +++ b/src/ecc/codes/classical/hamming.jl @@ -28,21 +28,21 @@ end using SparseArrays function parity_checks(h::Hamming) - n = 2 ^ h.r - 1 # Total number of columns + n = 2 ^ h.r - 1 rows = Int[] cols = Int[] - values = Int[] + vals = Int[] for j in 1:n columnsā±¼ = bitstring(j)[end - h.r + 1:end] for i in 1:h.r if parse(Int, columnsā±¼[i]) == 1 push!(rows, i) push!(cols, j) - push!(values, 1) + push!(vals, 1) end end end - H = sparse(rows, cols, values, h.r, n) + H = sparse(rows, cols, vals, h.r, n) return H end diff --git a/test/test_ecc_hamming.jl b/test/test_ecc_hamming.jl index 8df5dbbf2..51dbe98bc 100644 --- a/test/test_ecc_hamming.jl +++ b/test/test_ecc_hamming.jl @@ -21,7 +21,7 @@ end @testset "Testing Hamming codes properties" begin - r_vals = [3, 4, 5] + r_vals = [3, 4] for r in r_vals n = 2 ^ r - 1 k = 2 ^ r - 1 - r @@ -31,8 +31,8 @@ mat = matrix(GF(2), parity_checks(Hamming(r))) computed_rank = rank(mat) @test computed_rank == n - k - @test Hamming_bound(Hamming(r)) == true - @test Gilbert_Varshamov_bound(Hamming(r)) == true + @test hamming_bound(Hamming(r)) == true + @test gilbert_varshamov_bound(Hamming(r)) == true end # Example taken from [huffman2010fundamentals](@cite). @test Matrix{Bool}(parity_checks(Hamming(3))) == [0 0 0 1 1 1 1;