Skip to content

Commit 63834db

Browse files
committed
fixed some qdistrnd bugs
1 parent 3040118 commit 63834db

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Quantum/weight_dist.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,10 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsCSS,
798798
# this is done in the constructor but the logical is not stored at the time
799799
# so must redo here
800800
mat = _rref_no_col_swap(operators_to_reduce)
801-
anti = mat * check_against
802-
curr_u_bound, index = findmin(row_wts_symplectic(mat[findall(!iszero(anti[i, :]) for i in axes(anti, 1)), :]))
803-
found = operators_to_reduce[index, :]
801+
anti = mat * check_against .% order(field(S))
802+
log_locations = findall(!iszero(anti[i, :]) for i in axes(anti, 1))
803+
curr_u_bound, index = findmin(row_wts_symplectic(mat[log_locations, :]))
804+
found = mat[log_locations[index], :]
804805
verbose && println("Starting upper bound: $curr_u_bound")
805806
elseif which == :X
806807
verbose && println("Bounding the X-distance")
@@ -950,19 +951,21 @@ function _RIS_bound_loop!(operators_to_reduce, check_against, curr_l_bound::Int,
950951
perm2 = [perm; perm .+ n]
951952
perm_ops = operators_to_reduce[:, perm2]
952953
_rref_no_col_swap!(perm_ops)
953-
LinearAlgebra.mul!(log_test, perm_ops, check_against[perm2, :])
954+
ops = perm_ops[:, invperm(perm2)]
955+
LinearAlgebra.mul!(log_test, ops, check_against)
956+
log_test .%= 2
954957
for i in axes(log_test, 1)
955958
# then perm_ops[i, :] is a logical
956959
if any(!iszero, log_test[i, :])
957960
w = 0
958961
@inbounds for j in 1:n
959-
iszero(perm_ops[i, j] % 2) && iszero(perm_ops[i, j + n] % 2) || (w += 1;)
962+
!iszero(ops[i, j] % 2) && !iszero(ops[i, j + n] % 2) || (w += 1;)
960963
end
961964

962965
if uppers[t] > w
963966
uppers[t] = w
964967
# maybe use invpermute! here?
965-
founds[t] .= perm_ops[i, invperm(perm2)]
968+
founds[t] .= ops[i, :]
966969
verbose && println("Adjusting upper bound: $w")
967970
if curr_l_bound == w
968971
verbose && println("Found a logical that matched the lower bound of $curr_l_bound")
@@ -989,18 +992,19 @@ function _RIS_bound_loop!(operators_to_reduce, check_against, curr_l_bound::Int,
989992
perm2 = [perm; perm .+ n]
990993
perm_ops = operators_to_reduce[:, perm2]
991994
_rref_no_col_swap!(perm_ops)
992-
LinearAlgebra.mul!(log_test, perm_ops, check_against[perm2, :])
995+
LinearAlgebra.mul!(log_test, ops, check_against)
996+
log_test .%= 2
993997
for i in axes(log_test, 1)
994998
# then perm_ops[i, :] is a logical
995999
if any(!iszero, log_test[i, :])
9961000
w = 0
9971001
@inbounds for j in 1:n
998-
iszero(perm_ops[i. j]) && iszero(perm_ops[i, j + n]) || (w += 1;)
1002+
!iszero(ops[i, j] % 2) && !iszero(ops[i, j + n] % 2) || (w += 1;)
9991003
end
10001004

10011005
if upper_temp > w
10021006
upper_temp = w
1003-
found_temp = perm_ops[i, invperm!(perm2)]
1007+
found_temp = ops[i, :]
10041008
verbose && println("Adjusting upper bound: $w")
10051009
if curr_l_bound == w
10061010
verbose && println("Found a logical that matched the lower bound of $curr_l_bound")

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ end
13111311
function _Pauli_string_to_symplectic(str::T) where T <: Union{String, Vector{Char}}
13121312
n = length(str)
13131313
# F = GF(2, 1, :ω)
1314-
F = GF(2)
1314+
F = Oscar.Nemo.Native.GF(2)
13151315
sym = zero_matrix(F, 1, 2 * n)
13161316
for (i, c) in enumerate(str)
13171317
if c == 'X'

0 commit comments

Comments
 (0)