Skip to content

Commit 85caafe

Browse files
committed
qdistrnd for css stab code returns flint row vec for logical now
1 parent dcfa293 commit 85caafe

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

src/Quantum/weight_dist.jl

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -804,24 +804,6 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsCSS,
804804

805805
n = S.n
806806
if which == :full
807-
# verbose && println("Bounding the full distance")
808-
# stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S), Int)
809-
# _rref_no_col_swap_binary!(stabs)
810-
# stabs = _remove_empty(stabs, :rows)
811-
# logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S), Int)
812-
# operators_to_reduce = vcat(stabs, logs)
813-
# check_against = permutedims(logs[:, [n + 1:2n; 1:n]])
814-
# curr_l_bound = S.l_bound
815-
# verbose && println("Starting lower bound: $curr_l_bound")
816-
817-
# # this is done in the constructor but the logical is not stored at the time
818-
# # so must redo here
819-
# mat = _rref_no_col_swap_binary(operators_to_reduce)
820-
# anti = mat * check_against .% order(field(S))
821-
# log_locations = findall(!iszero(anti[i, :]) for i in axes(anti, 1))
822-
# curr_u_bound, index = findmin(row_wts_symplectic(mat[log_locations, :]))
823-
# found = mat[log_locations[index], :]
824-
# verbose && println("Starting upper bound: $curr_u_bound")
825807
upperx, foundx = random_information_set_minimum_distance_bound!(HasNoGauges(), IsCSS(), HasLogicals(), S, :X, dressed, max_iters, verbose)
826808
upperz, foundz = random_information_set_minimum_distance_bound!(HasNoGauges(), IsCSS(), HasLogicals(), S, :Z, dressed, max_iters, verbose)
827809
if upperx <= upperz
@@ -832,25 +814,23 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsCSS,
832814
return upperz, foundz
833815
end
834816
else
835-
verbose && println("Bounding the X-distance")
836-
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S)[:, (which == :X ? (1:n) : (n + 1:2n))], Int)
817+
if verbose && which == :X
818+
verbose && println("Bounding the X-distance")
819+
elseif verbose && which == :Z
820+
verbose && println("Bounding the Z-distance")
821+
end
822+
stabs = _Flint_matrix_to_Julia_T_matrix(stabilizers(S)[:, (which == :X ? (1:n) : (n + 1:2n))], UInt8)
837823
_rref_no_col_swap_binary!(stabs)
838824
stabs = _remove_empty(stabs, :rows)
839-
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S)[:, (which == :X ? (1:n) : (n + 1:2n))], Int)
825+
logs = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S)[:, (which == :X ? (1:n) : (n + 1:2n))], UInt8)
840826
logs = _remove_empty(logs, :rows)
841827
operators_to_reduce = vcat(stabs, logs)
842-
check_against = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S)[:, (which == :X ? (n + 1:2n) : (1:n))], Int)
828+
check_against = _Flint_matrix_to_Julia_T_matrix(logicals_matrix(S)[:, (which == :X ? (n + 1:2n) : (1:n))], UInt8)
843829
check_against = permutedims(_remove_empty(check_against, :rows))
844830
curr_l_bound = S.l_bound_dx
845831
verbose && println("Starting lower bound: $curr_l_bound")
846-
847-
# this is done in the constructor but the logical is not stored at the time
848-
# so must redo here
849-
mat = _rref_no_col_swap_binary(operators_to_reduce)
850-
anti = mat * check_against .% 2
851-
log_locations = findall(!iszero(anti[i, :]) for i in axes(anti, 1))
852-
curr_u_bound, index = findmin(count(!iszero, mat[log_locations[i], :]) for i in eachindex(log_locations))
853-
found = mat[log_locations[index], :]
832+
curr_u_bound, index = findmin(count(!iszero, logs[i, :]) for i in 1:size(logs, 1))
833+
found = logs[index, :]
854834
verbose && println("Starting upper bound: $curr_u_bound")
855835
end
856836

@@ -870,7 +850,14 @@ function random_information_set_minimum_distance_bound!(::HasNoGauges, ::IsCSS,
870850
S.u_bound_dz = uppers[loc]
871851
end
872852
verbose && println("Ending $max_iters iterations with an upper bound of $(uppers[loc])")
873-
return uppers[loc], founds[loc]
853+
flint_mat_found = if which == :full
854+
matrix(field(S), permutedims(founds[loc]))
855+
elseif which == :X
856+
matrix(field(S), [permutedims(founds[loc]) zeros(Int, 1, n)])
857+
else
858+
matrix(field(S), [zeros(Int, 1, n) permutedims(founds[loc])])
859+
end
860+
return uppers[loc], flint_mat_found
874861
end
875862

876863
function random_information_set_minimum_distance_bound!(::HasGauges, ::IsNotCSS, ::HasLogicals,

0 commit comments

Comments
 (0)