27namespace GreedyPauliSimp {
55 : string_(string), sign_(sign) {
63 "SingleNode cannot be constructed with identity strings.");
71 const unsigned& a = tqe.
a;
72 const unsigned& b = tqe.
b;
80 const unsigned& a = tqe.
a;
81 const unsigned& b = tqe.
b;
99 std::vector<unsigned> sqs;
100 for (
unsigned i = 0; i <
string_.size(); i++) {
103 TKET_ASSERT(!sqs.empty());
104 std::vector<TQE> tqes;
105 tqes.reserve(sqs.size() * (sqs.size() - 1) * 2);
106 for (
unsigned i = 0; i < sqs.size() - 1; i++) {
107 for (
unsigned j = i + 1; j < sqs.size(); j++) {
108 const auto& tqe_types =
110 for (
const TQEType& tt : tqe_types) {
111 tqes.push_back({tt, sqs[i], sqs[j]});
119 for (
unsigned i = 0; i <
string_.size(); i++) {
131 std::vector<Pauli> z_string, std::vector<Pauli> x_string,
bool z_sign,
133 : z_string_(z_string),
142 for (
unsigned i = 0; i <
z_string_.size(); i++) {
161 return static_cast<unsigned>(
167 const unsigned& a = tqe.
a;
168 const unsigned& b = tqe.
b;
175 CommuteType new_a_type = get_pauli_pair_commute_type(new_z_p0, new_x_p0);
176 CommuteType new_b_type = get_pauli_pair_commute_type(new_z_p1, new_x_p1);
181 unsigned new_anti_commutes =
183 unsigned new_commutes =
185 int anti_commute_increase = new_anti_commutes - old_anti_commutes;
186 int commute_increase = new_commutes - old_commutes;
187 return static_cast<int>(1.5 * anti_commute_increase + commute_increase);
192 const unsigned& a = tqe.
a;
193 const unsigned& b = tqe.
b;
200 CommuteType new_a_type = get_pauli_pair_commute_type(new_z_p0, new_x_p0);
201 CommuteType new_b_type = get_pauli_pair_commute_type(new_z_p1, new_x_p1);
206 unsigned new_anti_commutes =
208 unsigned new_commutes =
210 int anti_commute_increase = new_anti_commutes - old_anti_commutes;
211 int commute_increase = new_commutes - old_commutes;
248 std::vector<TQE> tqes;
250 std::vector<unsigned> sqs;
254 TKET_ASSERT(!sqs.empty());
255 for (
unsigned i = 0; i < sqs.size() - 1; i++) {
256 for (
unsigned j = i + 1; j < sqs.size(); j++) {
257 std::vector<TQEType> tqe_types;
265 tqe_types = AA_TO_CC_MAP.at(
269 tqe_types = AC_TO_AI_MAP.at(
275 tqe_types = AC_TO_AI_MAP.at(
283 tqe_types = CC_TO_IC_OR_CI_MAP.at(
287 for (
const TQEType& tt : tqe_types) {
288 tqes.push_back({tt, a, b});
312 std::vector<std::tuple<std::vector<Pauli>,
bool,
Expr>> rotations,
313 std::vector<unsigned> cond_bits,
unsigned cond_value)
314 : rotations_(rotations), cond_bits_(cond_bits), cond_value_(cond_value) {
316 for (
const std::tuple<std::vector<Pauli>,
bool,
Expr>& rot :
rotations_) {
318 std::get<0>(rot).size() -
319 std::count(std::get<0>(rot).begin(), std::get<0>(rot).end(),
Pauli::I);
326 int total_increase = 0;
327 for (
const std::tuple<std::vector<Pauli>,
bool,
Expr>& rot :
rotations_) {
329 const unsigned& a = tqe.
a;
330 const unsigned& b = tqe.
b;
331 Pauli p0 = std::get<0>(rot)[a];
332 Pauli p1 = std::get<0>(rot)[b];
335 return total_increase;
339 for (std::tuple<std::vector<Pauli>,
bool,
Expr>& rot :
rotations_) {
341 const unsigned& a = tqe.
a;
342 const unsigned& b = tqe.
b;
343 Pauli p0 = std::get<0>(rot)[a];
344 Pauli p1 = std::get<0>(rot)[b];
350 std::get<0>(rot)[a] = new_p0;
351 std::get<0>(rot)[b] = new_p1;
354 std::get<1>(rot) = !std::get<1>(rot);
360 std::vector<std::pair<UnitID, BitType>> bits_info;
364 std::vector<std::vector<Pauli>> strings;
365 for (
const std::tuple<std::vector<Pauli>,
bool,
Expr>& rot :
rotations_) {
366 strings.push_back(std::get<0>(rot));
368 return {strings, bits_info};
372 for (
const auto& rot : other.
rotations()) {
375 std::get<0>(rot).size() -
376 std::count(std::get<0>(rot).begin(), std::get<0>(rot).end(),
Pauli::I);
382 std::vector<Pauli> z_string, std::vector<Pauli> x_string,
bool z_sign,
383 bool x_sign,
unsigned qubit_index)
384 :
ACPairNode(z_string, x_string, z_sign, x_sign),
385 qubit_index_(qubit_index) {}
393 : args_(args), op_(op) {}
396 std::vector<std::pair<UnitID, BitType>> bits_info;
400 return {{}, bits_info};
413 std::vector<Pauli> z_string, std::vector<Pauli> x_string,
bool z_sign,
415 :
ACPairNode(z_string, x_string, z_sign, x_sign) {}
Location holding a bit or qubit of information.
Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWA...
OpType
Named operation types.
Pauli
Symbols for the Pauli operators (and identity)
SymEngine::Expression Expr
Representation of a phase as a multiple of .
std::shared_ptr< const Op > Op_ptr