From 8260983b6430ca868cdbeabdd7ac3158b5146806 Mon Sep 17 00:00:00 2001 From: James Wootton Date: Fri, 16 Feb 2024 09:16:28 +0100 Subject: [PATCH] fix extra logicals --- src/qiskit_qec/circuits/intern/arctools.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qiskit_qec/circuits/intern/arctools.cpp b/src/qiskit_qec/circuits/intern/arctools.cpp index d14ec7e5..92577821 100644 --- a/src/qiskit_qec/circuits/intern/arctools.cpp +++ b/src/qiskit_qec/circuits/intern/arctools.cpp @@ -1,4 +1,5 @@ #include "arctools.h" +#include bool is_cluster_neutral( std::vector> nodes, bool ignore_extra_logicals, bool minimal, @@ -172,23 +173,27 @@ std::vector check_nodes( } // see if we can find a color for which we have no extra logicals // and see what additional logicals are required - std::vector flipped_logicals; + std::set flipped_logicals; + std::set flipped_ng_logicals; std::vector extra_logicals; bool done = false; int j = 0; while (not done){ flipped_logicals = {}; - // see which logicals for this colour have not been given + flipped_ng_logicals = {}; + // see which logicals for this colour have been flipped for (auto & q: color_logicals[cs[j]]){ + flipped_logicals.insert(q); + // and which of those were not given if (given_logicals.find(q) == given_logicals.end()) { - flipped_logicals.push_back(q); + flipped_ng_logicals.insert(q); } } // see which extra logicals are given extra_logicals = {}; if (not ignore_extra_logicals) { - for (auto & q: color_logicals[cs[j]]){ - if (given_logicals.find(q) == given_logicals.end()) { + for (auto & q: given_logicals){ + if ((flipped_logicals.find(q) == flipped_logicals.end())) { extra_logicals.push_back(q); } } @@ -204,7 +209,7 @@ std::vector check_nodes( // construct output output.push_back(extra_logicals.size()==0); // neutral output.push_back(num_nodes[cs[j]]); // num_errors - for (auto & q: flipped_logicals){ + for (auto & q: flipped_ng_logicals){ output.push_back(q); }