|
14 | 14 |
|
15 | 15 | #include "tket/Transformations/RzPhasedXSquash.hpp" |
16 | 16 |
|
| 17 | +#include <algorithm> |
17 | 18 | #include <memory> |
| 19 | +#include <tkassert/Assert.hpp> |
| 20 | +#include <vector> |
18 | 21 |
|
| 22 | +#include "tket/Circuit/Command.hpp" |
| 23 | +#include "tket/OpType/OpType.hpp" |
19 | 24 | #include "tket/Transformations/BasicOptimisation.hpp" |
20 | 25 | #include "tket/Transformations/Decomposition.hpp" |
21 | 26 | #include "tket/Transformations/PQPSquash.hpp" |
@@ -93,15 +98,20 @@ std::pair<Circuit, Gate_ptr> RzPhasedXSquasher::flush( |
93 | 98 | return {replacement, rz3_gate}; |
94 | 99 | } |
95 | 100 |
|
96 | | -Transform squash_1qb_to_Rz_PhasedX(bool always_squash_symbols) { |
97 | | - return Transform([always_squash_symbols](Circuit &circ) { |
| 101 | +Transform squash_1qb_to_Rz_PhasedX() { |
| 102 | + return Transform([](Circuit &circ) { |
98 | 103 | bool reverse = false; |
99 | 104 | bool success = decompose_ZX().apply(circ); |
100 | 105 | auto squasher = std::make_unique<RzPhasedXSquasher>(reverse); |
101 | | - return SingleQubitSquash( |
102 | | - std::move(squasher), circ, reverse, always_squash_symbols) |
103 | | - .squash() || |
104 | | - success; |
| 106 | + success = |
| 107 | + SingleQubitSquash(std::move(squasher), circ, reverse, true).squash() || |
| 108 | + success; |
| 109 | + // Assert that all the Rx gates resulting from decompose_ZX() have gone. |
| 110 | + std::vector<Command> cmds = circ.get_commands(); |
| 111 | + TKET_ASSERT(!std::any_of(cmds.begin(), cmds.end(), [](const Command &cmd) { |
| 112 | + return cmd.get_op_ptr()->get_type() == OpType::Rx; |
| 113 | + })); |
| 114 | + return success; |
105 | 115 | }); |
106 | 116 | } |
107 | 117 |
|
|
0 commit comments