| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | // Copyright 2019-2022 Cambridge Quantum Computing | |||
| 2 | // | |||
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |||
| 4 | // you may not use this file except in compliance with the License. | |||
| 5 | // You may obtain a copy of the License at | |||
| 6 | // | |||
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |||
| 8 | // | |||
| 9 | // Unless required by applicable law or agreed to in writing, software | |||
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | |||
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| 12 | // See the License for the specific language governing permissions and | |||
| 13 | // limitations under the License. | |||
| 14 | ||||
| 15 | #include "Circuit/Boxes.hpp" | |||
| 16 | #include "Converters.hpp" | |||
| 17 | #include "Converters/PhasePoly.hpp" | |||
| 18 | #include "Diagonalisation/Diagonalisation.hpp" | |||
| 19 | #include "Gate/Gate.hpp" | |||
| 20 | #include "PauliGadget.hpp" | |||
| 21 | ||||
| 22 | namespace tket { | |||
| 23 | ||||
| 24 | PauliGraph circuit_to_pauli_graph(const Circuit &circ); | |||
| 25 | Circuit pauli_graph_to_circuit(const PauliGraph &pg); | |||
| 26 | ||||
| 27 | 53 | PauliGraph circuit_to_pauli_graph(const Circuit &circ) { | ||
| 28 | 53 | for (const std::pair<const Qubit, Qubit> &pair : | ||
| 29 |
3/4✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 157 times.
✓ Branch 9 taken 52 times.
|
262 | circ.implicit_qubit_permutation()) { | |
| 30 |
3/4✓ Branch 1 taken 157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 156 times.
|
2/2✓ Decision 'true' taken 1 times.
✓ Decision 'false' taken 156 times.
|
157 | if (pair.first != pair.second) { |
| 31 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | throw ImplicitPermutationNotAllowed( | |
| 32 | "Cannot build a PauliGraph from circuits with implicit " | |||
| 33 | 2 | "permutations"); | ||
| 34 | } | |||
| 35 | 53 | } | ||
| 36 |
2/4✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 52 times.
✗ Branch 6 not taken.
|
104 | PauliGraph pg(circ.all_qubits(), circ.all_bits()); | |
| 37 |
6/10✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 777 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 776 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 777 times.
✓ Branch 14 taken 51 times.
|
0/1? Decision couldn't be analyzed.
|
828 | for (const Command &com : circ) { |
| 38 | 777 | const Op &op = *com.get_op_ptr(); | ||
| 39 |
1/2✓ Branch 1 taken 777 times.
✗ Branch 2 not taken.
|
777 | unit_vector_t args = com.get_args(); | |
| 40 |
1/2✓ Branch 1 taken 777 times.
✗ Branch 2 not taken.
|
777 | OpDesc od = op.get_desc(); | |
| 41 |
3/4✓ Branch 1 taken 777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
✓ Branch 4 taken 112 times.
|
2/2✓ Decision 'true' taken 665 times.
✓ Decision 'false' taken 112 times.
|
777 | if (od.is_gate()) { |
| 42 |
2/2✓ Branch 1 taken 664 times.
✓ Branch 2 taken 1 times.
|
665 | pg.apply_gate_at_end(static_cast<const Gate &>(op), args); | |
| 43 |
2/4✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
|
1/2✓ Decision 'true' taken 112 times.
✗ Decision 'false' not taken.
|
112 | } else if (od.type() == OpType::PauliExpBox) { |
| 44 | 112 | const PauliExpBox &peb = static_cast<const PauliExpBox &>(op); | ||
| 45 |
1/2✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | std::vector<Pauli> paulis = peb.get_paulis(); | |
| 46 |
1/2✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | Expr phase = peb.get_phase(); | |
| 47 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 112 times.
|
112 | if (args.size() != paulis.size()) |
| 48 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | throw std::logic_error("Incorrect Pauli tensor size for qubit count"); | |
| 49 | 112 | QubitPauliTensor qpt; | ||
| 50 |
2/2✓ Branch 1 taken 357 times.
✓ Branch 2 taken 112 times.
|
2/2✓ Decision 'true' taken 357 times.
✓ Decision 'false' taken 112 times.
|
469 | for (unsigned i = 0; i != args.size(); ++i) { |
| 51 |
4/5✓ Branch 1 taken 57 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 84 times.
✓ Branch 4 taken 81 times.
✗ Branch 5 not taken.
|
357 | switch (paulis[i]) { | |
| 52 |
1/1✓ Decision 'true' taken 57 times.
|
57 | case Pauli::I: | |
| 53 | 57 | break; | ||
| 54 |
1/1✓ Decision 'true' taken 135 times.
|
135 | case Pauli::X: | |
| 55 |
3/6✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
|
135 | qpt = qpt * pg.cliff_.get_xpauli(Qubit(args[i])); | |
| 56 | 135 | break; | ||
| 57 |
1/1✓ Decision 'true' taken 84 times.
|
84 | case Pauli::Y: | |
| 58 |
3/6✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 84 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 84 times.
✗ Branch 9 not taken.
|
84 | qpt = qpt * pg.cliff_.get_xpauli(Qubit(args[i])); | |
| 59 |
3/6✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 84 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 84 times.
✗ Branch 9 not taken.
|
84 | qpt = qpt * pg.cliff_.get_zpauli(Qubit(args[i])); | |
| 60 |
1/2✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
|
84 | qpt = i_ * qpt; | |
| 61 | 84 | break; | ||
| 62 |
1/1✓ Decision 'true' taken 81 times.
|
81 | case Pauli::Z: | |
| 63 |
3/6✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 81 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 81 times.
✗ Branch 9 not taken.
|
81 | qpt = qpt * pg.cliff_.get_zpauli(Qubit(args[i])); | |
| 64 | 81 | break; | ||
| 65 | } | |||
| 66 | } | |||
| 67 |
1/2✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | pg.apply_pauli_gadget_at_end(qpt, phase); | |
| 68 | 112 | } else | ||
| 69 | ✗ | throw BadOpType( | ||
| 70 | "Can only make a PauliGraph from a circuit of basic gates " | |||
| 71 | "and Paulis", | |||
| 72 | ✗ | od.type()); | ||
| 73 | 832 | } | ||
| 74 | 51 | return pg; | ||
| 75 | 1 | } | ||
| 76 | ||||
| 77 | 7 | Circuit pauli_graph_to_circuit_individually( | ||
| 78 | const PauliGraph &pg, CXConfigType cx_config) { | |||
| 79 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | Circuit circ; | |
| 80 |
3/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 22 times.
✓ Branch 9 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
29 | for (const Qubit &qb : pg.cliff_.get_qubits()) { |
| 81 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | circ.add_qubit(qb); | |
| 82 | 7 | } | ||
| 83 |
2/2✓ Branch 5 taken 14 times.
✓ Branch 6 taken 7 times.
|
2/2✓ Decision 'true' taken 14 times.
✓ Decision 'false' taken 7 times.
|
21 | for (const Bit &b : pg.bits_) { |
| 84 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | circ.add_bit(b); | |
| 85 | } | |||
| 86 |
5/8✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 75 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 68 times.
✓ Branch 11 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
75 | for (PauliGraph::TopSortIterator it = pg.begin(); it != pg.end(); ++it) { |
| 87 |
1/2✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
|
68 | PauliVert vert = *it; | |
| 88 |
1/2✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
|
68 | const QubitPauliTensor &pauli = pg.graph_[vert].tensor_; | |
| 89 |
1/2✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
|
68 | const Expr &angle = pg.graph_[vert].angle_; | |
| 90 |
3/6✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 68 times.
✗ Branch 9 not taken.
|
68 | append_single_pauli_gadget(circ, pauli, angle, cx_config); | |
| 91 | 7 | } | ||
| 92 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | Circuit cliff_circuit = tableau_to_circuit(pg.cliff_); | |
| 93 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | circ.append(cliff_circuit); | |
| 94 |
6/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
9 | for (auto it = pg.measures_.begin(); it != pg.measures_.end(); ++it) { |
| 95 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | circ.add_measure(it->left, it->right); | |
| 96 | } | |||
| 97 | 14 | return circ; | ||
| 98 | 7 | } | ||
| 99 | ||||
| 100 | 7 | Circuit pauli_graph_to_circuit_pairwise( | ||
| 101 | const PauliGraph &pg, CXConfigType cx_config) { | |||
| 102 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | Circuit circ; | |
| 103 |
3/4✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 8 taken 22 times.
✓ Branch 9 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
29 | for (const Qubit &qb : pg.cliff_.get_qubits()) { |
| 104 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | circ.add_qubit(qb); | |
| 105 | 7 | } | ||
| 106 |
2/2✓ Branch 5 taken 14 times.
✓ Branch 6 taken 7 times.
|
2/2✓ Decision 'true' taken 14 times.
✓ Decision 'false' taken 7 times.
|
21 | for (const Bit &b : pg.bits_) { |
| 107 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | circ.add_bit(b); | |
| 108 | } | |||
| 109 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | PauliGraph::TopSortIterator it = pg.begin(); | |
| 110 |
4/6✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 34 times.
✓ Branch 8 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
41 | while (it != pg.end()) { |
| 111 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | PauliVert vert0 = *it; | |
| 112 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | const QubitPauliTensor &pauli0 = pg.graph_[vert0].tensor_; | |
| 113 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | const Expr &angle0 = pg.graph_[vert0].angle_; | |
| 114 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | ++it; | |
| 115 |
3/6✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 34 times.
|
34 | if (it == pg.end()) { |
| 116 | ✗ | append_single_pauli_gadget(circ, pauli0, angle0, cx_config); | ||
| 117 | } else { | |||
| 118 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | PauliVert vert1 = *it; | |
| 119 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | const QubitPauliTensor &pauli1 = pg.graph_[vert1].tensor_; | |
| 120 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | const Expr &angle1 = pg.graph_[vert1].angle_; | |
| 121 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | ++it; | |
| 122 |
5/10✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 34 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 34 times.
✗ Branch 14 not taken.
|
34 | append_pauli_gadget_pair(circ, pauli0, angle0, pauli1, angle1, cx_config); | |
| 123 | } | |||
| 124 | } | |||
| 125 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | Circuit cliff_circuit = tableau_to_circuit(pg.cliff_); | |
| 126 |
1/2✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
|
7 | circ.append(cliff_circuit); | |
| 127 |
6/10✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7 times.
|
0/1? Decision couldn't be analyzed.
|
9 | for (auto it = pg.measures_.begin(); it != pg.measures_.end(); ++it) { |
| 128 |
3/6✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | circ.add_measure(it->left, it->right); | |
| 129 | } | |||
| 130 | 14 | return circ; | ||
| 131 | 7 | } | ||
| 132 | ||||
| 133 | /* Currently follows a greedy set-building method */ | |||
| 134 | 24 | Circuit pauli_graph_to_circuit_sets( | ||
| 135 | const PauliGraph &pg, CXConfigType cx_config) { | |||
| 136 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | Circuit circ; | |
| 137 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | const std::set<Qubit> qbs = pg.cliff_.get_qubits(); | |
| 138 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | Circuit spare_circ; | |
| 139 |
2/2✓ Branch 5 taken 80 times.
✓ Branch 6 taken 24 times.
|
2/2✓ Decision 'true' taken 80 times.
✓ Decision 'false' taken 24 times.
|
104 | for (const Qubit &qb : qbs) { |
| 140 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | circ.add_qubit(qb); | |
| 141 |
1/2✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
|
80 | spare_circ.add_qubit(qb); | |
| 142 | } | |||
| 143 |
2/2✓ Branch 5 taken 18 times.
✓ Branch 6 taken 24 times.
|
2/2✓ Decision 'true' taken 18 times.
✓ Decision 'false' taken 24 times.
|
42 | for (const Bit &b : pg.bits_) { |
| 144 |
1/2✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
|
18 | circ.add_bit(b); | |
| 145 | } | |||
| 146 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | PauliGraph::TopSortIterator it = pg.begin(); | |
| 147 |
4/6✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 50 times.
✓ Branch 8 taken 24 times.
|
0/1? Decision couldn't be analyzed.
|
74 | while (it != pg.end()) { |
| 148 |
2/4✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
|
50 | const PauliGadgetProperties &pgp = pg.graph_[*it]; | |
| 149 | 50 | QubitOperator gadget_map; | ||
| 150 |
2/4✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
|
50 | gadget_map[pgp.tensor_] = pgp.angle_; | |
| 151 |
1/2✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
|
50 | ++it; | |
| 152 |
4/6✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 24 times.
|
0/1? Decision couldn't be analyzed.
|
128 | while (it != pg.end()) { |
| 153 |
2/4✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 104 times.
✗ Branch 5 not taken.
|
104 | const PauliGadgetProperties &pauli_gadget = pg.graph_[*it]; | |
| 154 |
1/2✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
|
104 | QubitOperator::iterator pgs_iter = gadget_map.find(pauli_gadget.tensor_); | |
| 155 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 104 times.
|
104 | if (pgs_iter != gadget_map.end()) { |
| 156 | ✗ | insert_into_gadget_map(gadget_map, pauli_gadget); | ||
| 157 | } else { | |||
| 158 | 104 | bool commutes_with_all = true; | ||
| 159 |
2/2✓ Branch 5 taken 214 times.
✓ Branch 6 taken 78 times.
|
2/2✓ Decision 'true' taken 214 times.
✓ Decision 'false' taken 78 times.
|
292 | for (const std::pair<const QubitPauliTensor, Expr> &pv : gadget_map) { |
| 160 |
3/4✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 188 times.
|
2/2✓ Decision 'true' taken 26 times.
✓ Decision 'false' taken 188 times.
|
214 | if (!pauli_gadget.tensor_.commutes_with(pv.first)) { |
| 161 | 26 | commutes_with_all = false; | ||
| 162 | 26 | break; | ||
| 163 | } | |||
| 164 | } | |||
| 165 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 78 times.
|
2/2✓ Decision 'true' taken 78 times.
✓ Decision 'false' taken 26 times.
|
104 | if (!commutes_with_all) break; |
| 166 |
1/2✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
|
78 | insert_into_gadget_map(gadget_map, pauli_gadget); | |
| 167 | } | |||
| 168 |
1/2✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
|
78 | ++it; | |
| 169 | } | |||
| 170 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 37 times.
|
2/2✓ Decision 'true' taken 13 times.
✓ Decision 'false' taken 37 times.
|
50 | if (gadget_map.size() == 1) { |
| 171 | 13 | const std::pair<const QubitPauliTensor, Expr> &pgp0 = *gadget_map.begin(); | ||
| 172 |
2/4✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
|
13 | append_single_pauli_gadget(circ, pgp0.first, pgp0.second, cx_config); | |
| 173 |
2/2✓ Branch 1 taken 23 times.
✓ Branch 2 taken 14 times.
|
2/2✓ Decision 'true' taken 23 times.
✓ Decision 'false' taken 14 times.
|
37 | } else if (gadget_map.size() == 2) { |
| 174 | 23 | const std::pair<const QubitPauliTensor, Expr> &pgp0 = *gadget_map.begin(); | ||
| 175 | const std::pair<const QubitPauliTensor, Expr> &pgp1 = | |||
| 176 | 23 | *(++gadget_map.begin()); | ||
| 177 |
1/2✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
|
23 | append_pauli_gadget_pair( | |
| 178 |
4/8✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 23 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 23 times.
✗ Branch 11 not taken.
|
23 | circ, pgp0.first, pgp0.second, pgp1.first, pgp1.second, cx_config); | |
| 179 | } else { | |||
| 180 | 14 | std::list<std::pair<QubitPauliTensor, Expr>> gadgets; | ||
| 181 | 14 | for (const std::pair<const QubitPauliTensor, Expr> &qps_pair : | ||
| 182 |
2/2✓ Branch 4 taken 69 times.
✓ Branch 5 taken 14 times.
|
97 | gadget_map) { | |
| 183 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
69 | gadgets.push_back(qps_pair); | |
| 184 | } | |||
| 185 |
2/4✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
|
14 | Circuit cliff_circ = mutual_diagonalise(gadgets, qbs, cx_config); | |
| 186 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | circ.append(cliff_circ); | |
| 187 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | Circuit phase_poly_circ(spare_circ); | |
| 188 |
2/2✓ Branch 4 taken 69 times.
✓ Branch 5 taken 14 times.
|
2/2✓ Decision 'true' taken 69 times.
✓ Decision 'false' taken 14 times.
|
83 | for (const std::pair<QubitPauliTensor, Expr> &pgp : gadgets) { |
| 189 |
2/4✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
|
69 | append_single_pauli_gadget(phase_poly_circ, pgp.first, pgp.second); | |
| 190 | } | |||
| 191 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | PhasePolyBox ppbox(phase_poly_circ); | |
| 192 |
2/4✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 14 times.
✗ Branch 6 not taken.
|
14 | Circuit after_synth_circ = *ppbox.to_circuit(); | |
| 193 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
14 | circ.append(after_synth_circ); | |
| 194 |
2/4✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
|
14 | circ.append(cliff_circ.dagger()); | |
| 195 | 14 | } | ||
| 196 | 50 | } | ||
| 197 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | Circuit cliff_circuit = tableau_to_circuit(pg.cliff_); | |
| 198 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | circ.append(cliff_circuit); | |
| 199 |
6/10✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 30 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 24 times.
|
0/1? Decision couldn't be analyzed.
|
30 | for (auto it = pg.measures_.begin(); it != pg.measures_.end(); ++it) { |
| 200 |
3/6✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
|
6 | circ.add_measure(it->left, it->right); | |
| 201 | } | |||
| 202 | 48 | return circ; | ||
| 203 | 24 | } | ||
| 204 | ||||
| 205 | } // namespace tket | |||
| 206 |