Skip to content

Commit 0ae6b9d

Browse files
authored
Merge branch 'dev' into fa/add-Manifest-to-gitignore
2 parents beeb691 + b0526e0 commit 0ae6b9d

File tree

9 files changed

+595
-105
lines changed

9 files changed

+595
-105
lines changed

benchmarks/iterators_bench.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using CodingTheory
2+
using Oscar
3+
using LinearAlgebra
4+
using BenchmarkTools
5+
6+
function visit_all_subsets(mutate, g_len, v_weight, subset)
7+
if subset
8+
gi=CodingTheory.SubsetGrayCode(g_len, v_weight)
9+
else
10+
gi=CodingTheory.GrayCode(g_len, v_weight; mutate = mutate)
11+
end
12+
for subset in gi
13+
# BenchmarkTools can elide simple computations so we need to do some nontrivial calculation here.
14+
# In any realistic situation we need to look at least look at all entries of the vector.
15+
# Ill model the task of looking at the entries using the 'all' function
16+
Base.all(i->(i==0), subset)
17+
end
18+
return
19+
end
20+
21+
#=
22+
SubsetGrayCode and GrayCode appear to be in the same ballpark.
23+
GrayCode is faster, SubsetGrayCode uses less memory.
24+
25+
######
26+
# n=25, k=12, mutate=true
27+
######
28+
@benchmark visit_all_subsets(25, 12, false)
29+
BenchmarkTools.Trial: 54 samples with 1 evaluation.
30+
Range (min … max): 66.365 ms … 219.557 ms ┊ GC (min … max): 0.00% … 34.15%
31+
Time (median): 92.912 ms ┊ GC (median): 26.24%
32+
Time (mean ± σ): 93.526 ms ± 27.981 ms ┊ GC (mean ± σ): 19.78% ± 13.74%
33+
34+
▂▂ █▃
35+
███▅▅▁▁▁▁▄▁▁█████▁▁▄▁▁▁▁▄▁▁▁▁▁▅▁▁▁▁▁▁▁▁▁▄▁▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄ ▁
36+
66.4 ms Histogram: frequency by time 181 ms <
37+
38+
Memory estimate: 158.70 MiB, allocs estimate: 5200322.
39+
40+
BenchmarkTools.Trial: 65 samples with 1 evaluation.
41+
Range (min … max): 51.159 ms … 103.931 ms ┊ GC (min … max): 0.00% … 50.88%
42+
Time (median): 77.176 ms ┊ GC (median): 31.98%
43+
Time (mean ± σ): 77.271 ms ± 6.824 ms ┊ GC (mean ± σ): 31.52% ± 7.35%
44+
45+
█ ▁
46+
▃▃▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▅▆████▅▆▅▁▃▃▁▁▄▁▁▃▁▁▁▁▃ ▁
47+
51.2 ms Histogram: frequency by time 89.3 ms <
48+
49+
Memory estimate: 238.05 MiB, allocs estimate: 5200308.
50+
=#

benchmarks/weight_dist_bench.jl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using Oscar, CodingTheory
2+
using Combinatorics
3+
using LinearAlgebra
4+
using BenchmarkTools
5+
using Random
6+
using Dates
7+
include("benchmark_utils.jl")
8+
CodingTheory.Random.seed!(0)
9+
10+
function white_n70_k35(use_new, terse_description)
11+
F = Oscar.Nemo.Native.GF(2)
12+
mat = matrix(F, [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 1 0 1 1 1 0 1 0 1 1 1 1 0 1 1 0 1 1 0 0 1 0 0 1 1 0 1;
13+
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 0;
14+
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0;
15+
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 0;
44+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0;
45+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 0 1 1 1 0 0 0 1 0 0 1 1;
46+
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 1 0 1 0 0 0 0 1 1 1])
47+
48+
num_thrds = Threads.nthreads()
49+
println("Benchmarking with $num_thrds threads.")
50+
if use_new
51+
function_description = "_minimum_distance_BZ(codeN70K35,:Brouwer;false)"
52+
terse_description ? println(function_description) : println(benchmark_description(function_description))
53+
return @benchmark CodingTheory._minimum_distance_BZ(codeN70K35, info_set_alg = :Brouwer; verbose = false) setup = (codeN70K35=LinearCode($mat, false, false))
54+
else
55+
function_description = "_minimum_distance_enumeration_with_matrix_multiply(codeN70K35,:Brouwer;false)"
56+
terse_description ? println(function_description) : println(benchmark_description(function_description))
57+
return @benchmark CodingTheory._minimum_distance_enumeration_with_matrix_multiply(codeN70K35, info_set_alg = :Brouwer; verbose = false) setup = (codeN70K35=LinearCode($mat, false, false))
58+
end
59+
end
60+
61+
use_new=false
62+
t = white_n70_k35(use_new, true)
63+
t

src/Classical/linear_code.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ minimum_distance_upper_bound(C::AbstractLinearCode) = C.u_bound
344344
Return `true` if code is maximum distance separable (MDS).
345345
"""
346346
function is_MDS(C::AbstractLinearCode)
347-
ismissing(C.d) && minimum_distance(C)
347+
ismissing(C.d) && minimum_distance_Gray(C)
348348
return C.d == Singleton_bound(C.n, C.k)
349349
end
350350

@@ -671,8 +671,8 @@ end
671671
672672
Return the syndrome of `v` with respect to `C`.
673673
"""
674-
function syndrome(C::AbstractLinearCode, v::Union{CTMatrixTypes, Vector{Int}})
675-
w = isa(v, Vector{Int}) ? matrix(C.F, length(v), 1, v) : v
674+
function syndrome(C::AbstractLinearCode, v::Union{CTMatrixTypes, Vector{Int}, Vector{fpFieldElem}, Vector{FpFieldElem}})
675+
w = isa(v, Union{Vector{Int}, Vector{fpFieldElem}, Vector{FpFieldElem}}) ? matrix(C.F, length(v), 1, v) : v
676676
H = parity_check_matrix(C)
677677
nc = ncols(H)
678678
(size(w) != (nc, 1) && size(w) != (1, nc)) &&
@@ -693,7 +693,7 @@ end
693693
694694
Return whether or not `v` is a codeword of `C`.
695695
"""
696-
in(v::Union{CTMatrixTypes, Vector{Int}}, C::AbstractLinearCode) = iszero(syndrome(C, v))
696+
in(v::Union{CTMatrixTypes, Vector{Int}, Vector{fpFieldElem}, Vector{FpFieldElem}}, C::AbstractLinearCode) = iszero(syndrome(C, v))
697697

698698
"""
699699
⊆(C1::AbstractLinearCode, C2::AbstractLinearCode)

0 commit comments

Comments
 (0)