Skip to content

Commit

Permalink
more unitary-vs-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Oct 28, 2024
1 parent 7fbc125 commit 5e86b67
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/stim/gates/gates.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ TEST_EACH_WORD_SIZE_W(gate_data, decompositions_are_correct, {

TEST_EACH_WORD_SIZE_W(gate_data, unitary_inverses_are_correct, {
for (const auto &g : GATE_DATA.items) {
if (g.flags & GATE_IS_UNITARY) {
if (g.has_known_unitary_matrix()) {
auto g_t_inv = g.tableau<W>().inverse(false);
auto g_inv_t = GATE_DATA[g.best_candidate_inverse_id].tableau<W>();
EXPECT_EQ(g_t_inv, g_inv_t) << g.name;
Expand Down
2 changes: 1 addition & 1 deletion src/stim/simulators/error_analyzer.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ TEST_EACH_WORD_SIZE_W(ErrorAnalyzer, unitary_gates_match_frame_simulator, {
data.push_back(GateTarget::qubit(k));
}
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
e.undo_gate({gate.id, {}, data});
f.do_gate({gate.inverse().id, {}, data});
for (size_t q = 0; q < 16; q++) {
Expand Down
2 changes: 1 addition & 1 deletion src/stim/simulators/frame_simulator.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool is_bulk_frame_operation_consistent_with_tableau(const Gate &gate) {

TEST_EACH_WORD_SIZE_W(FrameSimulator, bulk_operations_consistent_with_tableau_data, {
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
EXPECT_TRUE(is_bulk_frame_operation_consistent_with_tableau<W>(gate)) << gate.name;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/stim/simulators/graph_simulator.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ TEST(graph_simulator, all_unitary_gates_work) {
SpanRef<GateTarget> t1 = t2;
t1.ptr_end--;
for (const auto &gate : GATE_DATA.items) {
if (!(gate.flags & GATE_IS_UNITARY)) {
if (!gate.has_known_unitary_matrix()) {
continue;
}
Circuit circuit;
Expand Down
2 changes: 1 addition & 1 deletion src/stim/simulators/sparse_rev_frame_tracker.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static std::vector<GateTarget> qubit_targets(const std::vector<uint32_t> &target
TEST_EACH_WORD_SIZE_W(SparseUnsignedRevFrameTracker, fuzz_all_unitary_gates_vs_tableau, {
auto rng = INDEPENDENT_TEST_RNG();
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
size_t n = (gate.flags & GATE_TARGETS_PAIRS) ? 2 : 1;
SparseUnsignedRevFrameTracker tracker_gate(n + 3, 0, 0);
for (size_t q = 0; q < n; q++) {
Expand Down
2 changes: 1 addition & 1 deletion src/stim/simulators/tableau_simulator.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ TEST_EACH_WORD_SIZE_W(TableauSimulator, unitary_gates_consistent_with_tableau_da
auto t = Tableau<W>::random(10, rng);
TableauSimulator<W> sim(INDEPENDENT_TEST_RNG(), 10);
for (const auto &gate : GATE_DATA.items) {
if (!(gate.flags & GATE_IS_UNITARY)) {
if (!gate.has_known_unitary_matrix()) {
continue;
}
sim.inv_state = t;
Expand Down
2 changes: 1 addition & 1 deletion src/stim/stabilizers/pauli_string_ref.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TEST_EACH_WORD_SIZE_W(pauli_string, do_instruction_agrees_with_tableau_sim, {
sim.inv_state = Tableau<W>::random(sim.inv_state.num_qubits, sim.rng);

for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
check_pauli_string_do_instruction_agrees_with_tableau_sim<W>(gate, sim);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/stim/stabilizers/tableau.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ TEST_EACH_WORD_SIZE_W(tableau, str, {

TEST_EACH_WORD_SIZE_W(tableau, gate_tableau_data_vs_unitary_data, {
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
EXPECT_TRUE(tableau_agrees_with_unitary<W>(gate.tableau<W>(), gate.unitary())) << gate.name;
}
}
})

TEST_EACH_WORD_SIZE_W(tableau, inverse_data, {
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
auto &inv_gate = gate.inverse();
auto tab = gate.tableau<W>();
auto inv_tab = inv_gate.tableau<W>();
Expand Down Expand Up @@ -1163,7 +1163,7 @@ TEST_EACH_WORD_SIZE_W(tableau, unitary_big_endian, {

TEST_EACH_WORD_SIZE_W(tableau, unitary_vs_gate_data, {
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
std::vector<std::complex<float>> flat_expected;
for (const auto &row : gate.unitary()) {
flat_expected.insert(flat_expected.end(), row.begin(), row.end());
Expand Down
4 changes: 2 additions & 2 deletions src/stim/util_top/stabilizers_vs_amplitudes.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace stim;

TEST_EACH_WORD_SIZE_W(conversions, unitary_to_tableau_vs_gate_data, {
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
EXPECT_EQ(unitary_to_tableau<W>(gate.unitary(), true), gate.tableau<W>()) << gate.name;
}
}
Expand All @@ -20,7 +20,7 @@ TEST_EACH_WORD_SIZE_W(conversions, tableau_to_unitary_vs_gate_data, {
VectorSimulator v1(2);
VectorSimulator v2(2);
for (const auto &gate : GATE_DATA.items) {
if (gate.flags & GATE_IS_UNITARY) {
if (gate.has_known_unitary_matrix()) {
auto actual = tableau_to_unitary<W>(gate.tableau<W>(), true);
auto expected = gate.unitary();
v1.state.clear();
Expand Down

0 comments on commit 5e86b67

Please sign in to comment.