Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Apr 9, 2024
1 parent edf0d4a commit 05f6037
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/stim/stabilizers/pauli_string_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,9 @@ template <bool reverse_order>
void PauliStringRef<W>::do_ZCX(const CircuitInstruction &inst) {
const auto &targets = inst.targets;
assert((targets.size() & 1) == 0);
for (size_t k = 0; k < inst.targets.size(); k += 2) {
size_t k2 = reverse_order ? inst.targets.size() - 2 - k : k;
size_t q1 = inst.targets[k2].data, q2 = inst.targets[k2 + 1].data;
for (size_t k = 0; k < targets.size(); k += 2) {
size_t k2 = reverse_order ? targets.size() - 2 - k : k;
size_t q1 = targets[k2].data, q2 = targets[k2 + 1].data;
do_single_cx(inst, q1, q2);
}
}
Expand All @@ -895,9 +895,9 @@ template <bool reverse_order>
void PauliStringRef<W>::do_ZCY(const CircuitInstruction &inst) {
const auto &targets = inst.targets;
assert((targets.size() & 1) == 0);
for (size_t k = 0; k < inst.targets.size(); k += 2) {
size_t k2 = reverse_order ? inst.targets.size() - 2 - k : k;
size_t q1 = inst.targets[k2].data, q2 = inst.targets[k2 + 1].data;
for (size_t k = 0; k < targets.size(); k += 2) {
size_t k2 = reverse_order ? targets.size() - 2 - k : k;
size_t q1 = targets[k2].data, q2 = targets[k2 + 1].data;
do_single_cy(inst, q1, q2);
}
}
Expand All @@ -916,9 +916,9 @@ template <bool reverse_order>
void PauliStringRef<W>::do_SWAP(const CircuitInstruction &inst) {
const auto &targets = inst.targets;
assert((targets.size() & 1) == 0);
for (size_t k = 0; k < inst.targets.size(); k += 2) {
size_t k2 = reverse_order ? inst.targets.size() - 2 - k : k;
size_t q1 = inst.targets[k2].data, q2 = inst.targets[k2 + 1].data;
for (size_t k = 0; k < targets.size(); k += 2) {
size_t k2 = reverse_order ? targets.size() - 2 - k : k;
size_t q1 = targets[k2].data, q2 = targets[k2 + 1].data;
zs[q1].swap_with(zs[q2]);
xs[q1].swap_with(xs[q2]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/stim/util_top/dem_to_matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ std::map<SparseXorVec<DemTarget>, double> stim::dem_to_map(const DetectorErrorMo
buf.sorted_items.push_back(t);
}
}
size_t kept = xor_sort<DemTarget>(buf);
size_t kept = xor_sort<DemTarget>(buf.sorted_items);
buf.sorted_items.resize(kept);
auto q = instruction.arg_data[0];
auto &p = result[buf];
Expand Down

0 comments on commit 05f6037

Please sign in to comment.