From 7735432683698e6707e9bde2bbcb93cabfcbe322 Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Sat, 18 Nov 2023 16:24:49 -0800 Subject: [PATCH] Add designated initializers to all gate data --- src/stim/circuit/gate_data.cc | 26 --- src/stim/circuit/gate_data.h | 26 +-- src/stim/circuit/gate_data_annotations.cc | 123 +++++------ src/stim/circuit/gate_data_blocks.cc | 20 +- src/stim/circuit/gate_data_collapsing.cc | 237 +++++++++++---------- src/stim/circuit/gate_data_controlled.cc | 208 +++++++++--------- src/stim/circuit/gate_data_hada.cc | 60 +++--- src/stim/circuit/gate_data_heralded.cc | 44 ++-- src/stim/circuit/gate_data_noisy.cc | 184 ++++++++-------- src/stim/circuit/gate_data_pair_measure.cc | 99 ++++----- src/stim/circuit/gate_data_pauli.cc | 80 +++---- src/stim/circuit/gate_data_period_3.cc | 40 ++-- src/stim/circuit/gate_data_period_4.cc | 120 +++++------ src/stim/circuit/gate_data_pp.cc | 148 ++++++------- src/stim/circuit/gate_data_swaps.cc | 100 ++++----- src/stim/mem/bitword_256_avx.h | 3 +- 16 files changed, 745 insertions(+), 773 deletions(-) diff --git a/src/stim/circuit/gate_data.cc b/src/stim/circuit/gate_data.cc index c73812cfb..d10fbcd52 100644 --- a/src/stim/circuit/gate_data.cc +++ b/src/stim/circuit/gate_data.cc @@ -149,32 +149,6 @@ const Gate &Gate::inverse() const { throw std::out_of_range(inv_name + " has no inverse."); } -Gate::Gate() : name(nullptr) { -} - -Gate::Gate( - const char *name, - GateType gate_id, - GateType best_inverse_gate, - uint8_t arg_count, - GateFlags flags, - const char *category, - const char *help, - FixedCapVector, 4>, 4> unitary_data, - FixedCapVector flow_data, - const char *h_s_cx_m_r_decomposition) - : name(name), - flags(flags), - id(gate_id), - arg_count(arg_count), - best_candidate_inverse_id(best_inverse_gate), - category(category), - help(help), - unitary_data(unitary_data), - flow_data(flow_data), - h_s_cx_m_r_decomposition(h_s_cx_m_r_decomposition) { -} - void GateDataMap::add_gate(bool &failed, const Gate &gate) { assert((size_t)gate.id < NUM_DEFINED_GATES); const char *c = gate.name; diff --git a/src/stim/circuit/gate_data.h b/src/stim/circuit/gate_data.h index 1d74db16e..9b201ac46 100644 --- a/src/stim/circuit/gate_data.h +++ b/src/stim/circuit/gate_data.h @@ -208,21 +208,19 @@ enum GateFlags : uint16_t { }; struct Gate { - /// === core gate data used in main tasks such as sampling === /// The canonical name of the gate, used when printing it to a circuit file. - const char *name; - /// Bit-packed data describing details of the gate. - GateFlags flags; + const char *name = nullptr; /// The gate's type, such as stim::GateType::X or stim::GateType::MRZ. GateType id; + /// The id of the gate inverse to this one, or at least the closest thing to an inverse. + /// Set to GateType::NOT_A_GATE for gates with no inverse. + GateType best_candidate_inverse_id; /// The number of parens arguments the gate expects (e.g. X_ERROR takes 1, PAULI_CHANNEL_1 takes 3). /// Set to stim::ARG_COUNT_SYGIL_ANY to indicate any number is allowed (e.g. DETECTOR coordinate data). uint8_t arg_count; + /// Bit-packed data describing details of the gate. + GateFlags flags; - /// === extended gate data used in secondary tasks such as exporting to other formats === - /// The id of the gate inverse to this one, or at least the closest thing to an inverse. - /// Set to GateType::NOT_A_GATE for gates with no inverse. - GateType best_candidate_inverse_id; /// A word describing what sort of gate this is. const char *category; /// Prose summary of what the gate is, how it fits into Stim, and how to use it. @@ -243,18 +241,6 @@ struct Gate { inline bool operator!=(const Gate &other) const { return id != other.id; } - Gate(); - Gate( - const char *name, - GateType gate_id, - GateType best_inverse_gate, - uint8_t arg_count, - GateFlags flags, - const char *category, - const char *help, - FixedCapVector, 4>, 4> unitary_data, - FixedCapVector flow_data, - const char *h_s_cx_m_r_decomposition); const Gate &inverse() const; diff --git a/src/stim/circuit/gate_data_annotations.cc b/src/stim/circuit/gate_data_annotations.cc index 0f04b144c..0a3e5a485 100644 --- a/src/stim/circuit/gate_data_annotations.cc +++ b/src/stim/circuit/gate_data_annotations.cc @@ -20,13 +20,14 @@ void GateDataMap::add_gate_data_annotations(bool &failed) { add_gate( failed, Gate{ - "DETECTOR", - GateType::DETECTOR, - GateType::DETECTOR, - ARG_COUNT_SYGIL_ANY, - (GateFlags)(GATE_ONLY_TARGETS_MEASUREMENT_RECORD | GATE_IS_NOT_FUSABLE | GATE_HAS_NO_EFFECT_ON_QUBITS), - "Z_Annotations", - R"MARKDOWN( + .name = "DETECTOR", + .id = GateType::DETECTOR, + .best_candidate_inverse_id = GateType::DETECTOR, + .arg_count = ARG_COUNT_SYGIL_ANY, + .flags = + (GateFlags)(GATE_ONLY_TARGETS_MEASUREMENT_RECORD | GATE_IS_NOT_FUSABLE | GATE_HAS_NO_EFFECT_ON_QUBITS), + .category = "Z_Annotations", + .help = R"MARKDOWN( Annotates that a set of measurements can be used to detect errors, because the set's parity should be deterministic. Note that it is not necessary to say whether the measurement set's parity is even or odd; all that matters is that the @@ -96,22 +97,22 @@ Parens Arguments: DETECTOR(0, 3) rec[-1] } )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "OBSERVABLE_INCLUDE", - GateType::OBSERVABLE_INCLUDE, - GateType::OBSERVABLE_INCLUDE, - 1, - (GateFlags)(GATE_ONLY_TARGETS_MEASUREMENT_RECORD | GATE_IS_NOT_FUSABLE | GATE_ARGS_ARE_UNSIGNED_INTEGERS | - GATE_HAS_NO_EFFECT_ON_QUBITS), - "Z_Annotations", - R"MARKDOWN( + .name = "OBSERVABLE_INCLUDE", + .id = GateType::OBSERVABLE_INCLUDE, + .best_candidate_inverse_id = GateType::OBSERVABLE_INCLUDE, + .arg_count = 1, + .flags = (GateFlags)(GATE_ONLY_TARGETS_MEASUREMENT_RECORD | GATE_IS_NOT_FUSABLE | + GATE_ARGS_ARE_UNSIGNED_INTEGERS | GATE_HAS_NO_EFFECT_ON_QUBITS), + .category = "Z_Annotations", + .help = R"MARKDOWN( Adds measurement records to a specified logical observable. A potential point of confusion here is that Stim's notion of a logical observable is nothing more than a set of @@ -167,21 +168,21 @@ Parens Arguments: # ...and the one before that. OBSERVABLE_INCLUDE(1) rec[-2] )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "TICK", - GateType::TICK, - GateType::TICK, - 0, - (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_TAKES_NO_TARGETS | GATE_HAS_NO_EFFECT_ON_QUBITS), - "Z_Annotations", - R"MARKDOWN( + .name = "TICK", + .id = GateType::TICK, + .best_candidate_inverse_id = GateType::TICK, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_TAKES_NO_TARGETS | GATE_HAS_NO_EFFECT_ON_QUBITS), + .category = "Z_Annotations", + .help = R"MARKDOWN( Annotates the end of a layer of gates, or that time is advancing. This instruction is not necessary, it has no effect on simulations, but it can be used by tools that are transforming or @@ -213,21 +214,21 @@ Parens Arguments: # Empty time step. TICK )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "QUBIT_COORDS", - GateType::QUBIT_COORDS, - GateType::QUBIT_COORDS, - ARG_COUNT_SYGIL_ANY, - (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_HAS_NO_EFFECT_ON_QUBITS), - "Z_Annotations", - R"MARKDOWN( + .name = "QUBIT_COORDS", + .id = GateType::QUBIT_COORDS, + .best_candidate_inverse_id = GateType::QUBIT_COORDS, + .arg_count = ARG_COUNT_SYGIL_ANY, + .flags = (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_HAS_NO_EFFECT_ON_QUBITS), + .category = "Z_Annotations", + .help = R"MARKDOWN( Annotates the location of a qubit. Coordinates are not required and have no effect on simulations, but can be useful to tools consuming the circuit. For @@ -258,21 +259,21 @@ Parens Arguments: QUBIT_COORDS(1, 0) 2 QUBIT_COORDS(1, 1) 3 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "SHIFT_COORDS", - GateType::SHIFT_COORDS, - GateType::SHIFT_COORDS, - ARG_COUNT_SYGIL_ANY, - (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_TAKES_NO_TARGETS | GATE_HAS_NO_EFFECT_ON_QUBITS), - "Z_Annotations", - R"MARKDOWN( + .name = "SHIFT_COORDS", + .id = GateType::SHIFT_COORDS, + .best_candidate_inverse_id = GateType::SHIFT_COORDS, + .arg_count = ARG_COUNT_SYGIL_ANY, + .flags = (GateFlags)(GATE_IS_NOT_FUSABLE | GATE_TAKES_NO_TARGETS | GATE_HAS_NO_EFFECT_ON_QUBITS), + .category = "Z_Annotations", + .help = R"MARKDOWN( Accumulates offsets that affect qubit coordinates and detector coordinates. Note: when qubit/detector coordinates use fewer dimensions than SHIFT_COORDS, the offsets from the additional dimensions @@ -307,21 +308,21 @@ Parens Arguments: SHIFT_COORDS(0, 1) # Advance 2nd coordinate to track loop iterations. } )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "MPAD", - GateType::MPAD, - GateType::MPAD, - 0, - GATE_PRODUCES_RESULTS, - "Z_Annotations", - R"MARKDOWN( + .name = "MPAD", + .id = GateType::MPAD, + .best_candidate_inverse_id = GateType::MPAD, + .arg_count = 0, + .flags = GATE_PRODUCES_RESULTS, + .category = "Z_Annotations", + .help = R"MARKDOWN( Pads the measurement record with the listed measurement results. This can be useful for ensuring measurements are aligned to word boundaries, or that the @@ -344,8 +345,8 @@ of measured qubits varies. # Append a series of results to the measurement record. MPAD 0 0 1 0 1 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); } diff --git a/src/stim/circuit/gate_data_blocks.cc b/src/stim/circuit/gate_data_blocks.cc index 097cfdbd4..7d47f564d 100644 --- a/src/stim/circuit/gate_data_blocks.cc +++ b/src/stim/circuit/gate_data_blocks.cc @@ -20,13 +20,13 @@ void GateDataMap::add_gate_data_blocks(bool &failed) { add_gate( failed, Gate{ - "REPEAT", - GateType::REPEAT, - GateType::REPEAT, - 0, - (GateFlags)(GATE_IS_BLOCK | GATE_IS_NOT_FUSABLE), - "Y_Control Flow", - R"MARKDOWN( + .name = "REPEAT", + .id = GateType::REPEAT, + .best_candidate_inverse_id = GateType::REPEAT, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_BLOCK | GATE_IS_NOT_FUSABLE), + .category = "Y_Control Flow", + .help = R"MARKDOWN( Repeats the instructions in its body N times. Currently, repetition counts of 0 are not allowed because they create corner cases with ambiguous resolutions. @@ -55,8 +55,8 @@ Parens Arguments: DETECTOR rec[-1] rec[-3] } )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); } diff --git a/src/stim/circuit/gate_data_collapsing.cc b/src/stim/circuit/gate_data_collapsing.cc index 135b4c650..3f9a8b896 100644 --- a/src/stim/circuit/gate_data_collapsing.cc +++ b/src/stim/circuit/gate_data_collapsing.cc @@ -22,14 +22,14 @@ void GateDataMap::add_gate_data_collapsing(bool &failed) { add_gate( failed, Gate{ - "MX", - GateType::MX, - GateType::MX, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MX", + .id = GateType::MX, + .best_candidate_inverse_id = GateType::MX, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( X-basis measurement. Projects each target qubit into `|+>` or `|->` and reports its value (false=`|+>`, true=`|->`). @@ -61,9 +61,9 @@ Parens Arguments: # Perform multiple noisy measurements. Each measurement fails independently with 2% probability. MX(0.02) 2 3 5 )MARKDOWN", - {}, - {"X -> rec[-1]", "X -> +X"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"X -> rec[-1]", "X -> +X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 M 0 H 0 @@ -73,14 +73,14 @@ H 0 add_gate( failed, Gate{ - "MY", - GateType::MY, - GateType::MY, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MY", + .id = GateType::MY, + .best_candidate_inverse_id = GateType::MY, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Y-basis measurement. Projects each target qubit into `|i>` or `|-i>` and reports its value (false=`|i>`, true=`|-i>`). @@ -112,9 +112,9 @@ Parens Arguments: # Perform multiple noisy measurements. Each measurement fails independently with 2% probability. MY(0.02) 2 3 5 )MARKDOWN", - {}, - {"Y -> rec[-1]", "Y -> +Y"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"Y -> rec[-1]", "Y -> +Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -128,14 +128,14 @@ S 0 add_gate( failed, Gate{ - "M", - GateType::M, - GateType::M, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "M", + .id = GateType::M, + .best_candidate_inverse_id = GateType::M, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Z-basis measurement. Projects each target qubit into `|0>` or `|1>` and reports its value (false=`|0>`, true=`|1>`). @@ -170,9 +170,9 @@ Parens Arguments: # Perform multiple noisy measurements. Each measurement fails independently with 2% probability. MZ(0.02) 2 3 5 )MARKDOWN", - {}, - {"Z -> rec[-1]", "Z -> +Z"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"Z -> rec[-1]", "Z -> +Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( M 0 )CIRCUIT", }); @@ -183,14 +183,14 @@ M 0 add_gate( failed, Gate{ - "MRX", - GateType::MRX, - GateType::MRX, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MRX", + .id = GateType::MRX, + .best_candidate_inverse_id = GateType::MRX, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( X-basis demolition measurement (optionally noisy). Projects each target qubit into `|+>` or `|->`, reports its value (false=`|+>`, true=`|->`), then resets to `|+>`. @@ -223,9 +223,9 @@ Parens Arguments: # Perform multiple noisy demolition measurements. Each measurement result is flipped independently with 2% probability. MRX(0.02) 2 3 5 )MARKDOWN", - {}, - {"X -> rec[-1]", "1 -> +X"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"X -> rec[-1]", "1 -> +X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 M 0 R 0 @@ -236,14 +236,14 @@ H 0 add_gate( failed, Gate{ - "MRY", - GateType::MRY, - GateType::MRY, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MRY", + .id = GateType::MRY, + .best_candidate_inverse_id = GateType::MRY, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Y-basis demolition measurement (optionally noisy). Projects each target qubit into `|i>` or `|-i>`, reports its value (false=`|i>`, true=`|-i>`), then resets to `|i>`. @@ -276,9 +276,9 @@ Parens Arguments: # Perform multiple noisy demolition measurements. Each measurement result is flipped independently with 2% probability. MRY(0.02) 2 3 5 )MARKDOWN", - {}, - {"Y -> rec[-1]", "1 -> +Y"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"Y -> rec[-1]", "1 -> +Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -293,14 +293,14 @@ S 0 add_gate( failed, Gate{ - "MR", - GateType::MR, - GateType::MR, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MR", + .id = GateType::MR, + .best_candidate_inverse_id = GateType::MR, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Z-basis demolition measurement (optionally noisy). Projects each target qubit into `|0>` or `|1>`, reports its value (false=`|0>`, true=`|1>`), then resets to `|0>`. @@ -336,9 +336,9 @@ Parens Arguments: # Perform multiple noisy demolition measurements. Each measurement result is flipped independently with 2% probability. MRZ(0.02) 2 3 5 )MARKDOWN", - {}, - {"Z -> rec[-1]", "1 -> +Z"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"Z -> rec[-1]", "1 -> +Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( M 0 R 0 )CIRCUIT", @@ -350,13 +350,13 @@ R 0 add_gate( failed, Gate{ - "RX", - GateType::RX, - GateType::MRX, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "RX", + .id = GateType::RX, + .best_candidate_inverse_id = GateType::MRX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( X-basis reset. Forces each target qubit into the `|+>` state by silently measuring it in the X basis and applying a `Z` gate if it ended up in the `|->` state. @@ -376,9 +376,9 @@ Parens Arguments: # Result multiple qubits into the |+> state. RX 2 3 5 )MARKDOWN", - {}, - {"1 -> +X"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"1 -> +X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 R 0 H 0 @@ -388,13 +388,13 @@ H 0 add_gate( failed, Gate{ - "RY", - GateType::RY, - GateType::MRY, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "RY", + .id = GateType::RY, + .best_candidate_inverse_id = GateType::MRY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Y-basis reset. Forces each target qubit into the `|i>` state by silently measuring it in the Y basis and applying an `X` gate if it ended up in the `|-i>` state. @@ -414,9 +414,9 @@ Parens Arguments: # Result multiple qubits into the |i> state. RY 2 3 5 )MARKDOWN", - {}, - {"1 -> +Y"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"1 -> +Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -430,13 +430,13 @@ S 0 add_gate( failed, Gate{ - "R", - GateType::R, - GateType::MR, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "R", + .id = GateType::R, + .best_candidate_inverse_id = GateType::MR, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_RESET), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Z-basis reset. Forces each target qubit into the `|0>` state by silently measuring it in the Z basis and applying an `X` gate if it ended up in the `|1>` state. @@ -459,9 +459,9 @@ Parens Arguments: # Reset multiple qubits into the |0> state. RZ 2 3 5 )MARKDOWN", - {}, - {"1 -> +Z"}, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = {"1 -> +Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( R 0 )CIRCUIT", }); @@ -471,14 +471,14 @@ R 0 add_gate( failed, Gate{ - "MPP", - GateType::MPP, - GateType::MPP, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_PRODUCES_RESULTS | GATE_IS_NOISY | GATE_TARGETS_PAULI_STRING | GATE_TARGETS_COMBINERS | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Collapsing Gates", - R"MARKDOWN( + .name = "MPP", + .id = GateType::MPP, + .best_candidate_inverse_id = GateType::MPP, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_PRODUCES_RESULTS | GATE_IS_NOISY | GATE_TARGETS_PAULI_STRING | + GATE_TARGETS_COMBINERS | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Collapsing Gates", + .help = R"MARKDOWN( Measure Pauli products. Parens Arguments: @@ -508,20 +508,21 @@ Parens Arguments: MPP(0.001) Z1*Z2 X1*X2 )MARKDOWN", - {}, - { - "XYZ__ -> rec[-2]", - "___XX -> rec[-1]", - "X____ -> X____", - "_Y___ -> _Y___", - "__Z__ -> __Z__", - "___X_ -> ___X_", - "____X -> ____X", - "ZZ___ -> ZZ___", - "_XX__ -> _XX__", - "___ZZ -> ___ZZ", - }, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = + { + "XYZ__ -> rec[-2]", + "___XX -> rec[-1]", + "X____ -> X____", + "_Y___ -> _Y___", + "__Z__ -> __Z__", + "___X_ -> ___X_", + "____X -> ____X", + "ZZ___ -> ZZ___", + "_XX__ -> _XX__", + "___ZZ -> ___ZZ", + }, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 1 1 1 H 0 1 3 4 CX 2 0 1 0 4 3 diff --git a/src/stim/circuit/gate_data_controlled.cc b/src/stim/circuit/gate_data_controlled.cc index aa77f351d..4f5be99c3 100644 --- a/src/stim/circuit/gate_data_controlled.cc +++ b/src/stim/circuit/gate_data_controlled.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_controlled(bool &failed) { add_gate( failed, Gate{ - "XCX", - GateType::XCX, - GateType::XCX, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "XCX", + .id = GateType::XCX, + .best_candidate_inverse_id = GateType::XCX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The X-controlled X gate. First qubit is the control, second qubit is the target. @@ -46,12 +46,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f, 0.5f, 0.5f, -0.5f}, - {0.5f, 0.5f, -0.5f, 0.5f}, - {0.5f, -0.5f, 0.5f, 0.5f}, - {-0.5f, 0.5f, 0.5f, 0.5f}}, - {"+XI", "+ZX", "+IX", "+XZ"}, - R"CIRCUIT( + .unitary_data = + {{0.5f, 0.5f, 0.5f, -0.5f}, + {0.5f, 0.5f, -0.5f, 0.5f}, + {0.5f, -0.5f, 0.5f, 0.5f}, + {-0.5f, 0.5f, 0.5f, 0.5f}}, + .flow_data = {"+XI", "+ZX", "+IX", "+XZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 CNOT 0 1 H 0 @@ -61,13 +62,13 @@ H 0 add_gate( failed, Gate{ - "XCY", - GateType::XCY, - GateType::XCY, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "XCY", + .id = GateType::XCY, + .best_candidate_inverse_id = GateType::XCY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The X-controlled Y gate. First qubit is the control, second qubit is the target. @@ -83,12 +84,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f, 0.5f, -0.5f * i, 0.5f * i}, - {0.5f, 0.5f, 0.5f * i, -0.5f * i}, - {0.5f * i, -0.5f * i, 0.5f, 0.5f}, - {-0.5f * i, 0.5f * i, 0.5f, 0.5f}}, - {"+XI", "+ZY", "+XX", "+XZ"}, - R"CIRCUIT( + .unitary_data = + {{0.5f, 0.5f, -0.5f * i, 0.5f * i}, + {0.5f, 0.5f, 0.5f * i, -0.5f * i}, + {0.5f * i, -0.5f * i, 0.5f, 0.5f}, + {-0.5f * i, 0.5f * i, 0.5f, 0.5f}}, + .flow_data = {"+XI", "+ZY", "+XX", "+XZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 1 S 1 @@ -102,13 +104,13 @@ S 1 add_gate( failed, Gate{ - "XCZ", - GateType::XCZ, - GateType::XCZ, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "XCZ", + .id = GateType::XCZ, + .best_candidate_inverse_id = GateType::XCZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The X-controlled Z gate. Applies a Z gate to the target if the control is in the |-> state. Equivalently: negates the amplitude of the |->|1> state. @@ -143,9 +145,9 @@ Parens Arguments: # Bit flip qubits 7 and 8 conditioned on sweep configuration data. XCZ 7 sweep[5] 8 sweep[5] )MARKDOWN", - {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}}, - {"+XI", "+ZZ", "+XX", "+IZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}}, + .flow_data = {"+XI", "+ZZ", "+XX", "+IZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CNOT 1 0 )CIRCUIT", }); @@ -153,13 +155,13 @@ CNOT 1 0 add_gate( failed, Gate{ - "YCX", - GateType::YCX, - GateType::YCX, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "YCX", + .id = GateType::YCX, + .best_candidate_inverse_id = GateType::YCX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Y-controlled X gate. First qubit is the control, second qubit is the target. @@ -175,12 +177,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f, -i * 0.5f, 0.5f, i * 0.5f}, - {i * 0.5f, 0.5f, -i * 0.5f, 0.5f}, - {0.5f, i * 0.5f, 0.5f, -i * 0.5f}, - {-i * 0.5f, 0.5f, i * 0.5f, 0.5f}}, - {"+XX", "+ZX", "+IX", "+YZ"}, - R"CIRCUIT( + .unitary_data = + {{0.5f, -i * 0.5f, 0.5f, i * 0.5f}, + {i * 0.5f, 0.5f, -i * 0.5f, 0.5f}, + {0.5f, i * 0.5f, 0.5f, -i * 0.5f}, + {-i * 0.5f, 0.5f, i * 0.5f, 0.5f}}, + .flow_data = {"+XX", "+ZX", "+IX", "+YZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -194,13 +197,13 @@ H 1 add_gate( failed, Gate{ - "YCY", - GateType::YCY, - GateType::YCY, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "YCY", + .id = GateType::YCY, + .best_candidate_inverse_id = GateType::YCY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Y-controlled Y gate. First qubit is the control, second qubit is the target. @@ -216,12 +219,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f, -i * 0.5f, -i * 0.5f, 0.5f}, - {i * 0.5f, 0.5f, -0.5f, -i * 0.5f}, - {i * 0.5f, -0.5f, 0.5f, -i * 0.5f}, - {0.5f, i * 0.5f, i * 0.5f, 0.5f}}, - {"+XY", "+ZY", "+YX", "+YZ"}, - R"CIRCUIT( + .unitary_data = + {{0.5f, -i * 0.5f, -i * 0.5f, 0.5f}, + {i * 0.5f, 0.5f, -0.5f, -i * 0.5f}, + {i * 0.5f, -0.5f, 0.5f, -i * 0.5f}, + {0.5f, i * 0.5f, i * 0.5f, 0.5f}}, + .flow_data = {"+XY", "+ZY", "+YX", "+YZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -239,13 +243,13 @@ S 1 add_gate( failed, Gate{ - "YCZ", - GateType::YCZ, - GateType::YCZ, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "YCZ", + .id = GateType::YCZ, + .best_candidate_inverse_id = GateType::YCZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Y-controlled Z gate. Applies a Z gate to the target if the control is in the |-i> state. Equivalently: negates the amplitude of the |-i>|1> state. @@ -280,9 +284,9 @@ Parens Arguments: # Apply Y to qubits 7 and 8 conditioned on sweep configuration data. YCZ 7 sweep[5] 8 sweep[5] )MARKDOWN", - {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, -i}, {0, 0, i, 0}}, - {"+XZ", "+ZZ", "+YX", "+IZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, -i}, {0, 0, i, 0}}, + .flow_data = {"+XZ", "+ZZ", "+YX", "+IZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -294,13 +298,13 @@ S 0 add_gate( failed, Gate{ - "CX", - GateType::CX, - GateType::CX, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "CX", + .id = GateType::CX, + .best_candidate_inverse_id = GateType::CX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Z-controlled X gate. Applies an X gate to the target if the control is in the |1> state. Equivalently: negates the amplitude of the |1>|-> state. @@ -334,9 +338,9 @@ Parens Arguments: # Bit flip qubits 7 and 8 conditioned on sweep configuration data. CX sweep[5] 7 sweep[5] 8 )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}, - {"+XX", "+ZI", "+IX", "+ZZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 1, 0, 0}}, + .flow_data = {"+XX", "+ZI", "+IX", "+ZZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CNOT 0 1 )CIRCUIT", }); @@ -347,13 +351,13 @@ CNOT 0 1 add_gate( failed, Gate{ - "CY", - GateType::CY, - GateType::CY, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "CY", + .id = GateType::CY, + .best_candidate_inverse_id = GateType::CY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Z-controlled Y gate. Applies a Y gate to the target if the control is in the |1> state. Equivalently: negates the amplitude of the |1>|-i> state. @@ -387,9 +391,9 @@ Parens Arguments: # Apply Y to qubits 7 and 8 conditioned on sweep configuration data. CY sweep[5] 7 sweep[5] 8 )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, 0, -i}, {0, 0, 1, 0}, {0, i, 0, 0}}, - {"+XY", "+ZI", "+ZX", "+ZZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, 0, -i}, {0, 0, 1, 0}, {0, i, 0, 0}}, + .flow_data = {"+XY", "+ZI", "+ZX", "+ZZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 1 S 1 S 1 @@ -403,13 +407,13 @@ S 1 add_gate( failed, Gate{ - "CZ", - GateType::CZ, - GateType::CZ, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "CZ", + .id = GateType::CZ, + .best_candidate_inverse_id = GateType::CZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS | GATE_CAN_TARGET_BITS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( The Z-controlled Z gate. Applies a Z gate to the target if the control is in the |1> state. Equivalently: negates the amplitude of the |1>|1> state. @@ -446,9 +450,9 @@ Parens Arguments: # Apply Z to qubits 7 and 8 conditioned on sweep configuration data. CZ sweep[5] 7 8 sweep[5] )MARKDOWN", - {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, -1}}, - {"+XZ", "+ZI", "+ZX", "+IZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, -1}}, + .flow_data = {"+XZ", "+ZI", "+ZX", "+IZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 1 CNOT 0 1 H 1 diff --git a/src/stim/circuit/gate_data_hada.cc b/src/stim/circuit/gate_data_hada.cc index e10d761d2..ac00b654f 100644 --- a/src/stim/circuit/gate_data_hada.cc +++ b/src/stim/circuit/gate_data_hada.cc @@ -25,13 +25,13 @@ void GateDataMap::add_gate_data_hada(bool &failed) { add_gate( failed, Gate{ - "H", - GateType::H, - GateType::H, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "H", + .id = GateType::H, + .best_candidate_inverse_id = GateType::H, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( The Hadamard gate. Swaps the X and Z axes. @@ -43,9 +43,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{s, s}, {s, -s}}, - {"+Z", "+X"}, - R"CIRCUIT( + .unitary_data = {{s, s}, {s, -s}}, + .flow_data = {"+Z", "+X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 )CIRCUIT", }); @@ -55,13 +55,13 @@ H 0 add_gate( failed, Gate{ - "H_XY", - GateType::H_XY, - GateType::H_XY, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "H_XY", + .id = GateType::H_XY, + .best_candidate_inverse_id = GateType::H_XY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( A variant of the Hadamard gate that swaps the X and Y axes (instead of X and Z). Parens Arguments: @@ -72,9 +72,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0, s - i * s}, {s + i * s, 0}}, - {"+Y", "-Z"}, - R"CIRCUIT( + .unitary_data = {{0, s - i * s}, {s + i * s, 0}}, + .flow_data = {"+Y", "-Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 S 0 @@ -86,13 +86,13 @@ S 0 add_gate( failed, Gate{ - "H_YZ", - GateType::H_YZ, - GateType::H_YZ, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "H_YZ", + .id = GateType::H_YZ, + .best_candidate_inverse_id = GateType::H_YZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( A variant of the Hadamard gate that swaps the Y and Z axes (instead of X and Z). Parens Arguments: @@ -103,9 +103,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{s, -i * s}, {i * s, -s}}, - {"-X", "+Y"}, - R"CIRCUIT( + .unitary_data = {{s, -i * s}, {i * s, -s}}, + .flow_data = {"-X", "+Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 H 0 diff --git a/src/stim/circuit/gate_data_heralded.cc b/src/stim/circuit/gate_data_heralded.cc index 2e43f0106..a398d5dd2 100644 --- a/src/stim/circuit/gate_data_heralded.cc +++ b/src/stim/circuit/gate_data_heralded.cc @@ -20,14 +20,14 @@ void GateDataMap::add_gate_data_heralded(bool &failed) { add_gate( failed, Gate{ - "HERALDED_ERASE", - GateType::HERALDED_ERASE, - GateType::HERALDED_ERASE, - 1, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | - GATE_PRODUCES_RESULTS), - "F_Noise Channels", - R"MARKDOWN( + .name = "HERALDED_ERASE", + .id = GateType::HERALDED_ERASE, + .best_candidate_inverse_id = GateType::HERALDED_ERASE, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | + GATE_PRODUCES_RESULTS), + .category = "F_Noise Channels", + .help = R"MARKDOWN( The heralded erasure noise channel. Whether or not this noise channel fires is recorded into the measurement @@ -94,22 +94,22 @@ Pauli Mixture: DETECTOR rec[-4] DETECTOR rec[-5] )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "HERALDED_PAULI_CHANNEL_1", - GateType::HERALDED_PAULI_CHANNEL_1, - GateType::HERALDED_PAULI_CHANNEL_1, - 4, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | - GATE_PRODUCES_RESULTS), - "F_Noise Channels", - R"MARKDOWN( + .name = "HERALDED_PAULI_CHANNEL_1", + .id = GateType::HERALDED_PAULI_CHANNEL_1, + .best_candidate_inverse_id = GateType::HERALDED_PAULI_CHANNEL_1, + .arg_count = 4, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | + GATE_PRODUCES_RESULTS), + .category = "F_Noise Channels", + .help = R"MARKDOWN( A heralded error channel that applies biased noise. This error records a bit into the measurement record, indicating whether @@ -176,8 +176,8 @@ Pauli Mixture: DETECTOR rec[-3] # Did the herald on qubit 1 fire? DETECTOR rec[-4] # Did the herald on qubit 0 fire? )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); } diff --git a/src/stim/circuit/gate_data_noisy.cc b/src/stim/circuit/gate_data_noisy.cc index afc94def7..60daf2dc1 100644 --- a/src/stim/circuit/gate_data_noisy.cc +++ b/src/stim/circuit/gate_data_noisy.cc @@ -20,13 +20,13 @@ void GateDataMap::add_gate_data_noisy(bool &failed) { add_gate( failed, Gate{ - "DEPOLARIZE1", - GateType::DEPOLARIZE1, - GateType::DEPOLARIZE1, - 1, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "F_Noise Channels", - R"MARKDOWN( + .name = "DEPOLARIZE1", + .id = GateType::DEPOLARIZE1, + .best_candidate_inverse_id = GateType::DEPOLARIZE1, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "F_Noise Channels", + .help = R"MARKDOWN( The single qubit depolarizing channel. Applies a single-qubit depolarizing error with the given probability. @@ -64,21 +64,21 @@ Pauli Mixture: # Maximally mix qubits 0 through 2 DEPOLARIZE1(0.75) 0 1 2 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "DEPOLARIZE2", - GateType::DEPOLARIZE2, - GateType::DEPOLARIZE2, - 1, - (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAIRS), - "F_Noise Channels", - R"MARKDOWN( + .name = "DEPOLARIZE2", + .id = GateType::DEPOLARIZE2, + .best_candidate_inverse_id = GateType::DEPOLARIZE2, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAIRS), + .category = "F_Noise Channels", + .help = R"MARKDOWN( The two qubit depolarizing channel. Applies a two-qubit depolarizing error with the given probability. @@ -126,21 +126,21 @@ Pauli Mixture: # Maximally mix qubits 0 through 3 DEPOLARIZE2(0.9375) 0 1 2 3 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "X_ERROR", - GateType::X_ERROR, - GateType::X_ERROR, - 1, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "F_Noise Channels", - R"MARKDOWN( + .name = "X_ERROR", + .id = GateType::X_ERROR, + .best_candidate_inverse_id = GateType::X_ERROR, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "F_Noise Channels", + .help = R"MARKDOWN( Applies a Pauli X with a given probability. Parens Arguments: @@ -156,21 +156,21 @@ Pauli Mixture: 1-p: I p : X )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "Y_ERROR", - GateType::Y_ERROR, - GateType::Y_ERROR, - 1, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "F_Noise Channels", - R"MARKDOWN( + .name = "Y_ERROR", + .id = GateType::Y_ERROR, + .best_candidate_inverse_id = GateType::Y_ERROR, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "F_Noise Channels", + .help = R"MARKDOWN( Applies a Pauli Y with a given probability. Parens Arguments: @@ -186,21 +186,21 @@ Pauli Mixture: 1-p: I p : Y )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "Z_ERROR", - GateType::Z_ERROR, - GateType::Z_ERROR, - 1, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "F_Noise Channels", - R"MARKDOWN( + .name = "Z_ERROR", + .id = GateType::Z_ERROR, + .best_candidate_inverse_id = GateType::Z_ERROR, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "F_Noise Channels", + .help = R"MARKDOWN( Applies a Pauli Z with a given probability. Parens Arguments: @@ -216,21 +216,21 @@ Pauli Mixture: 1-p: I p : Z )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "PAULI_CHANNEL_1", - GateType::PAULI_CHANNEL_1, - GateType::PAULI_CHANNEL_1, - 3, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "F_Noise Channels", - R"MARKDOWN( + .name = "PAULI_CHANNEL_1", + .id = GateType::PAULI_CHANNEL_1, + .best_candidate_inverse_id = GateType::PAULI_CHANNEL_1, + .arg_count = 3, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "F_Noise Channels", + .help = R"MARKDOWN( A single qubit Pauli error channel with explicitly specified probabilities for each case. Parens Arguments: @@ -257,21 +257,21 @@ Pauli Mixture: py: Y pz: Z )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "PAULI_CHANNEL_2", - GateType::PAULI_CHANNEL_2, - GateType::PAULI_CHANNEL_2, - 15, - (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAIRS), - "F_Noise Channels", - R"MARKDOWN( + .name = "PAULI_CHANNEL_2", + .id = GateType::PAULI_CHANNEL_2, + .best_candidate_inverse_id = GateType::PAULI_CHANNEL_2, + .arg_count = 15, + .flags = (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAIRS), + .category = "F_Noise Channels", + .help = R"MARKDOWN( A two qubit Pauli error channel with explicitly specified probabilities for each case. Parens Arguments: @@ -326,22 +326,22 @@ Pauli Mixture: pzy: ZY pzz: ZZ )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate( failed, Gate{ - "E", - GateType::E, - GateType::E, - 1, - (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAULI_STRING | - GATE_IS_NOT_FUSABLE), - "F_Noise Channels", - R"MARKDOWN( + .name = "E", + .id = GateType::E, + .best_candidate_inverse_id = GateType::E, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAULI_STRING | + GATE_IS_NOT_FUSABLE), + .category = "F_Noise Channels", + .help = R"MARKDOWN( Probabilistically applies a Pauli product error with a given probability. Sets the "correlated error occurred flag" to true if the error occurred. Otherwise sets the flag to false. @@ -365,22 +365,22 @@ Parens Arguments: ELSE_CORRELATED_ERROR(0.25) Z2 Z3 ELSE_CORRELATED_ERROR(0.33333333333) X1 Y2 Z3 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); add_gate_alias(failed, "CORRELATED_ERROR", "E"); add_gate( failed, Gate{ - "ELSE_CORRELATED_ERROR", - GateType::ELSE_CORRELATED_ERROR, - GateType::ELSE_CORRELATED_ERROR, - 1, - (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAULI_STRING | - GATE_IS_NOT_FUSABLE), - "F_Noise Channels", - R"MARKDOWN( + .name = "ELSE_CORRELATED_ERROR", + .id = GateType::ELSE_CORRELATED_ERROR, + .best_candidate_inverse_id = GateType::ELSE_CORRELATED_ERROR, + .arg_count = 1, + .flags = (GateFlags)(GATE_IS_NOISY | GATE_ARGS_ARE_DISJOINT_PROBABILITIES | GATE_TARGETS_PAULI_STRING | + GATE_IS_NOT_FUSABLE), + .category = "F_Noise Channels", + .help = R"MARKDOWN( Probabilistically applies a Pauli product error with a given probability, unless the "correlated error occurred flag" is set. If the error occurs, sets the "correlated error occurred flag" to true. Otherwise leaves the flag alone. @@ -409,8 +409,8 @@ Parens Arguments: ELSE_CORRELATED_ERROR(0.25) Z2 Z3 ELSE_CORRELATED_ERROR(0.33333333333) X1 Y2 Z3 )MARKDOWN", - {}, - {}, - nullptr, + .unitary_data = {}, + .flow_data = {}, + .h_s_cx_m_r_decomposition = nullptr, }); } diff --git a/src/stim/circuit/gate_data_pair_measure.cc b/src/stim/circuit/gate_data_pair_measure.cc index dcfe9124c..7ede6538c 100644 --- a/src/stim/circuit/gate_data_pair_measure.cc +++ b/src/stim/circuit/gate_data_pair_measure.cc @@ -21,14 +21,14 @@ void GateDataMap::add_gate_data_pair_measure(bool &failed) { add_gate( failed, Gate{ - "MXX", - GateType::MXX, - GateType::MXX, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Pair Measurement Gates", - R"MARKDOWN( + .name = "MXX", + .id = GateType::MXX, + .best_candidate_inverse_id = GateType::MXX, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Pair Measurement Gates", + .help = R"MARKDOWN( Two-qubit X basis parity measurement. This operation measures whether pairs of qubits are in the {|++>,|-->} subspace or in the @@ -71,14 +71,15 @@ Parens Arguments: # Each measurement has an independent 2% chance of being recorded wrong. MXX(0.02) 2 3 5 7 11 19 17 4 )MARKDOWN", - {}, - { - "X_ -> +X_", - "_X -> +_X", - "ZZ -> +ZZ", - "XX -> rec[-1]", - }, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = + { + "X_ -> +X_", + "_X -> +_X", + "ZZ -> +ZZ", + "XX -> rec[-1]", + }, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CX 0 1 H 0 M 0 @@ -90,14 +91,14 @@ CX 0 1 add_gate( failed, Gate{ - "MYY", - GateType::MYY, - GateType::MYY, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Pair Measurement Gates", - R"MARKDOWN( + .name = "MYY", + .id = GateType::MYY, + .best_candidate_inverse_id = GateType::MYY, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Pair Measurement Gates", + .help = R"MARKDOWN( Two-qubit Y basis parity measurement. This operation measures whether pairs of qubits are in the {|ii>,|jj>} subspace or in the @@ -140,14 +141,15 @@ Parens Arguments: # Each measurement has an independent 2% chance of being recorded wrong. MYY(0.02) 2 3 5 7 11 19 17 4 )MARKDOWN", - {}, - { - "XX -> +XX", - "Y_ -> +Y_", - "_Y -> +_Y", - "YY -> rec[-1]", - }, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = + { + "XX -> +XX", + "Y_ -> +Y_", + "_Y -> +_Y", + "YY -> rec[-1]", + }, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 1 CX 0 1 H 0 @@ -162,14 +164,14 @@ S 0 1 add_gate( failed, Gate{ - "MZZ", - GateType::MZZ, - GateType::MZZ, - ARG_COUNT_SYGIL_ZERO_OR_ONE, - (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | - GATE_ARGS_ARE_DISJOINT_PROBABILITIES), - "L_Pair Measurement Gates", - R"MARKDOWN( + .name = "MZZ", + .id = GateType::MZZ, + .best_candidate_inverse_id = GateType::MZZ, + .arg_count = ARG_COUNT_SYGIL_ZERO_OR_ONE, + .flags = (GateFlags)(GATE_TARGETS_PAIRS | GATE_PRODUCES_RESULTS | GATE_IS_NOISY | + GATE_ARGS_ARE_DISJOINT_PROBABILITIES), + .category = "L_Pair Measurement Gates", + .help = R"MARKDOWN( Two-qubit Z basis parity measurement. This operation measures whether pairs of qubits are in the {|00>,|11>} subspace or in the @@ -212,14 +214,15 @@ Parens Arguments: # Each measurement has an independent 2% chance of being recorded wrong. MZZ(0.02) 2 3 5 7 11 19 17 4 )MARKDOWN", - {}, - { - "XX -> XX", - "Z_ -> +Z_", - "_Z -> +_Z", - "ZZ -> rec[-1]", - }, - R"CIRCUIT( + .unitary_data = {}, + .flow_data = + { + "XX -> XX", + "Z_ -> +Z_", + "_Z -> +_Z", + "ZZ -> rec[-1]", + }, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CX 0 1 M 1 CX 0 1 diff --git a/src/stim/circuit/gate_data_pauli.cc b/src/stim/circuit/gate_data_pauli.cc index 8bcf6512c..73822d04c 100644 --- a/src/stim/circuit/gate_data_pauli.cc +++ b/src/stim/circuit/gate_data_pauli.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_pauli(bool &failed) { add_gate( failed, Gate{ - "I", - GateType::I, - GateType::I, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "A_Pauli Gates", - R"MARKDOWN( + .name = "I", + .id = GateType::I, + .best_candidate_inverse_id = GateType::I, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "A_Pauli Gates", + .help = R"MARKDOWN( The identity gate. Does nothing to the target qubits. @@ -42,9 +42,9 @@ Parens Arguments: Qubits to do nothing to. )MARKDOWN", - {{1, 0}, {0, 1}}, - {"+X", "+Z"}, - R"CIRCUIT( + .unitary_data = {{1, 0}, {0, 1}}, + .flow_data = {"+X", "+Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( # (no operations) )CIRCUIT", }); @@ -52,13 +52,13 @@ Parens Arguments: add_gate( failed, Gate{ - "X", - GateType::X, - GateType::X, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "A_Pauli Gates", - R"MARKDOWN( + .name = "X", + .id = GateType::X, + .best_candidate_inverse_id = GateType::X, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "A_Pauli Gates", + .help = R"MARKDOWN( The Pauli X gate. The bit flip gate. @@ -70,9 +70,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0, 1}, {1, 0}}, - {"+X", "-Z"}, - R"CIRCUIT( + .unitary_data = {{0, 1}, {1, 0}}, + .flow_data = {"+X", "-Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 S 0 @@ -83,13 +83,13 @@ H 0 add_gate( failed, Gate{ - "Y", - GateType::Y, - GateType::Y, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "A_Pauli Gates", - R"MARKDOWN( + .name = "Y", + .id = GateType::Y, + .best_candidate_inverse_id = GateType::Y, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "A_Pauli Gates", + .help = R"MARKDOWN( The Pauli Y gate. Parens Arguments: @@ -100,9 +100,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0, -i}, {i, 0}}, - {"-X", "-Z"}, - R"CIRCUIT( + .unitary_data = {{0, -i}, {i, 0}}, + .flow_data = {"-X", "-Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 H 0 @@ -115,13 +115,13 @@ H 0 add_gate( failed, Gate{ - "Z", - GateType::Z, - GateType::Z, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "A_Pauli Gates", - R"MARKDOWN( + .name = "Z", + .id = GateType::Z, + .best_candidate_inverse_id = GateType::Z, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "A_Pauli Gates", + .help = R"MARKDOWN( The Pauli Z gate. The phase flip gate. @@ -133,9 +133,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{1, 0}, {0, -1}}, - {"-X", "+Z"}, - R"CIRCUIT( + .unitary_data = {{1, 0}, {0, -1}}, + .flow_data = {"-X", "+Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 )CIRCUIT", diff --git a/src/stim/circuit/gate_data_period_3.cc b/src/stim/circuit/gate_data_period_3.cc index aaa71dc9f..d212737dc 100644 --- a/src/stim/circuit/gate_data_period_3.cc +++ b/src/stim/circuit/gate_data_period_3.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_period_3(bool &failed) { add_gate( failed, Gate{ - "C_XYZ", - GateType::C_XYZ, - GateType::C_ZYX, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "C_XYZ", + .id = GateType::C_XYZ, + .best_candidate_inverse_id = GateType::C_ZYX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Right handed period 3 axis cycling gate, sending X -> Y -> Z -> X. Parens Arguments: @@ -41,9 +41,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f - i * 0.5f, -0.5f - 0.5f * i}, {0.5f - 0.5f * i, 0.5f + 0.5f * i}}, - {"Y", "X"}, - R"CIRCUIT( + .unitary_data = {{0.5f - i * 0.5f, -0.5f - 0.5f * i}, {0.5f - 0.5f * i, 0.5f + 0.5f * i}}, + .flow_data = {"Y", "X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -54,13 +54,13 @@ H 0 add_gate( failed, Gate{ - "C_ZYX", - GateType::C_ZYX, - GateType::C_XYZ, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "C_ZYX", + .id = GateType::C_ZYX, + .best_candidate_inverse_id = GateType::C_XYZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Left handed period 3 axis cycling gate, sending Z -> Y -> X -> Z. Parens Arguments: @@ -71,9 +71,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f + i * 0.5f, 0.5f + 0.5f * i}, {-0.5f + 0.5f * i, 0.5f - 0.5f * i}}, - {"Z", "Y"}, - R"CIRCUIT( + .unitary_data = {{0.5f + i * 0.5f, 0.5f + 0.5f * i}, {-0.5f + 0.5f * i, 0.5f - 0.5f * i}}, + .flow_data = {"Z", "Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 )CIRCUIT", diff --git a/src/stim/circuit/gate_data_period_4.cc b/src/stim/circuit/gate_data_period_4.cc index 7433fa55b..6f1299362 100644 --- a/src/stim/circuit/gate_data_period_4.cc +++ b/src/stim/circuit/gate_data_period_4.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_period_4(bool &failed) { add_gate( failed, Gate{ - "SQRT_X", - GateType::SQRT_X, - GateType::SQRT_X_DAG, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_X", + .id = GateType::SQRT_X, + .best_candidate_inverse_id = GateType::SQRT_X_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Principal square root of X gate. Phases the amplitude of |-> by i. @@ -42,9 +42,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f + 0.5f * i, 0.5f - 0.5f * i}, {0.5f - 0.5f * i, 0.5f + 0.5f * i}}, - {"+X", "-Y"}, - R"CIRCUIT( + .unitary_data = {{0.5f + 0.5f * i, 0.5f - 0.5f * i}, {0.5f - 0.5f * i, 0.5f + 0.5f * i}}, + .flow_data = {"+X", "-Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 H 0 @@ -54,13 +54,13 @@ H 0 add_gate( failed, Gate{ - "SQRT_X_DAG", - GateType::SQRT_X_DAG, - GateType::SQRT_X, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_X_DAG", + .id = GateType::SQRT_X_DAG, + .best_candidate_inverse_id = GateType::SQRT_X, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Adjoint of the principal square root of X gate. Phases the amplitude of |-> by -i. @@ -72,9 +72,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f - 0.5f * i, 0.5f + 0.5f * i}, {0.5f + 0.5f * i, 0.5f - 0.5f * i}}, - {"+X", "+Y"}, - R"CIRCUIT( + .unitary_data = {{0.5f - 0.5f * i, 0.5f + 0.5f * i}, {0.5f + 0.5f * i, 0.5f - 0.5f * i}}, + .flow_data = {"+X", "+Y"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 H 0 S 0 @@ -84,13 +84,13 @@ S 0 add_gate( failed, Gate{ - "SQRT_Y", - GateType::SQRT_Y, - GateType::SQRT_Y_DAG, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_Y", + .id = GateType::SQRT_Y, + .best_candidate_inverse_id = GateType::SQRT_Y_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Principal square root of Y gate. Phases the amplitude of |-i> by i. @@ -102,9 +102,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f + 0.5f * i, -0.5f - 0.5f * i}, {0.5f + 0.5f * i, 0.5f + 0.5f * i}}, - {"-Z", "+X"}, - R"CIRCUIT( + .unitary_data = {{0.5f + 0.5f * i, -0.5f - 0.5f * i}, {0.5f + 0.5f * i, 0.5f + 0.5f * i}}, + .flow_data = {"-Z", "+X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 H 0 @@ -114,13 +114,13 @@ H 0 add_gate( failed, Gate{ - "SQRT_Y_DAG", - GateType::SQRT_Y_DAG, - GateType::SQRT_Y, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_Y_DAG", + .id = GateType::SQRT_Y_DAG, + .best_candidate_inverse_id = GateType::SQRT_Y, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Adjoint of the principal square root of Y gate. Phases the amplitude of |-i> by -i. @@ -132,9 +132,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{0.5f - 0.5f * i, 0.5f - 0.5f * i}, {-0.5f + 0.5f * i, 0.5f - 0.5f * i}}, - {"+Z", "-X"}, - R"CIRCUIT( + .unitary_data = {{0.5f - 0.5f * i, 0.5f - 0.5f * i}, {-0.5f + 0.5f * i, 0.5f - 0.5f * i}}, + .flow_data = {"+Z", "-X"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 S 0 S 0 @@ -144,13 +144,13 @@ S 0 add_gate( failed, Gate{ - "S", - GateType::S, - GateType::S_DAG, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "S", + .id = GateType::S, + .best_candidate_inverse_id = GateType::S_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Principal square root of Z gate. Phases the amplitude of |1> by i. @@ -162,9 +162,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{1, 0}, {0, i}}, - {"+Y", "+Z"}, - R"CIRCUIT( + .unitary_data = {{1, 0}, {0, i}}, + .flow_data = {"+Y", "+Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 )CIRCUIT", }); @@ -174,13 +174,13 @@ S 0 add_gate( failed, Gate{ - "S_DAG", - GateType::S_DAG, - GateType::S, - 0, - (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), - "B_Single Qubit Clifford Gates", - R"MARKDOWN( + .name = "S_DAG", + .id = GateType::S_DAG, + .best_candidate_inverse_id = GateType::S, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_SINGLE_QUBIT_GATE | GATE_IS_UNITARY), + .category = "B_Single Qubit Clifford Gates", + .help = R"MARKDOWN( Adjoint of the principal square root of Z gate. Phases the amplitude of |1> by -i. @@ -192,9 +192,9 @@ Parens Arguments: Qubits to operate on. )MARKDOWN", - {{1, 0}, {0, -i}}, - {"-Y", "+Z"}, - R"CIRCUIT( + .unitary_data = {{1, 0}, {0, -i}}, + .flow_data = {"-Y", "+Z"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 diff --git a/src/stim/circuit/gate_data_pp.cc b/src/stim/circuit/gate_data_pp.cc index 00f4168c9..f3a60c25c 100644 --- a/src/stim/circuit/gate_data_pp.cc +++ b/src/stim/circuit/gate_data_pp.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_pp(bool &failed) { add_gate( failed, Gate{ - "SQRT_XX", - GateType::SQRT_XX, - GateType::SQRT_XX_DAG, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_XX", + .id = GateType::SQRT_XX, + .best_candidate_inverse_id = GateType::SQRT_XX_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the XX observable by i. Parens Arguments: @@ -41,12 +41,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f + 0.5f * i, 0, 0, 0.5f - 0.5f * i}, - {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, - {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, - {0.5f - 0.5f * i, 0, 0, 0.5f + 0.5f * i}}, - {"+XI", "-YX", "+IX", "-XY"}, - R"CIRCUIT( + .unitary_data = + {{0.5f + 0.5f * i, 0, 0, 0.5f - 0.5f * i}, + {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, + {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, + {0.5f - 0.5f * i, 0, 0, 0.5f + 0.5f * i}}, + .flow_data = {"+XI", "-YX", "+IX", "-XY"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 CNOT 0 1 H 1 @@ -59,13 +60,13 @@ H 1 add_gate( failed, Gate{ - "SQRT_XX_DAG", - GateType::SQRT_XX_DAG, - GateType::SQRT_XX, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_XX_DAG", + .id = GateType::SQRT_XX_DAG, + .best_candidate_inverse_id = GateType::SQRT_XX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the XX observable by -i. Parens Arguments: @@ -76,12 +77,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f - 0.5f * i, 0, 0, 0.5f + 0.5f * i}, - {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, - {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, - {0.5f + 0.5f * i, 0, 0, 0.5f - 0.5f * i}}, - {"+XI", "+YX", "+IX", "+XY"}, - R"CIRCUIT( + .unitary_data = + {{0.5f - 0.5f * i, 0, 0, 0.5f + 0.5f * i}, + {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, + {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, + {0.5f + 0.5f * i, 0, 0, 0.5f - 0.5f * i}}, + .flow_data = {"+XI", "+YX", "+IX", "+XY"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 CNOT 0 1 H 1 @@ -99,13 +101,13 @@ H 1 add_gate( failed, Gate{ - "SQRT_YY", - GateType::SQRT_YY, - GateType::SQRT_YY_DAG, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_YY", + .id = GateType::SQRT_YY, + .best_candidate_inverse_id = GateType::SQRT_YY_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the YY observable by i. Parens Arguments: @@ -116,12 +118,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f + 0.5f * i, 0, 0, -0.5f + 0.5f * i}, - {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, - {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, - {-0.5f + 0.5f * i, 0, 0, 0.5f + 0.5f * i}}, - {"-ZY", "+XY", "-YZ", "+YX"}, - R"CIRCUIT( + .unitary_data = + {{0.5f + 0.5f * i, 0, 0, -0.5f + 0.5f * i}, + {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, + {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, + {-0.5f + 0.5f * i, 0, 0, 0.5f + 0.5f * i}}, + .flow_data = {"-ZY", "+XY", "-YZ", "+YX"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -143,13 +146,13 @@ S 1 add_gate( failed, Gate{ - "SQRT_YY_DAG", - GateType::SQRT_YY_DAG, - GateType::SQRT_YY, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_YY_DAG", + .id = GateType::SQRT_YY_DAG, + .best_candidate_inverse_id = GateType::SQRT_YY, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the YY observable by -i. Parens Arguments: @@ -160,12 +163,13 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{0.5f - 0.5f * i, 0, 0, -0.5f - 0.5f * i}, - {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, - {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, - {-0.5f - 0.5f * i, 0, 0, 0.5f - 0.5f * i}}, - {"+ZY", "-XY", "+YZ", "-YX"}, - R"CIRCUIT( + .unitary_data = + {{0.5f - 0.5f * i, 0, 0, -0.5f - 0.5f * i}, + {0, 0.5f - 0.5f * i, 0.5f + 0.5f * i, 0}, + {0, 0.5f + 0.5f * i, 0.5f - 0.5f * i, 0}, + {-0.5f - 0.5f * i, 0, 0, 0.5f - 0.5f * i}}, + .flow_data = {"+ZY", "-XY", "+YZ", "-YX"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -187,13 +191,13 @@ S 1 add_gate( failed, Gate{ - "SQRT_ZZ", - GateType::SQRT_ZZ, - GateType::SQRT_ZZ_DAG, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_ZZ", + .id = GateType::SQRT_ZZ, + .best_candidate_inverse_id = GateType::SQRT_ZZ_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the ZZ observable by i. Parens Arguments: @@ -204,9 +208,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, i, 0, 0}, {0, 0, i, 0}, {0, 0, 0, 1}}, - {"+YZ", "+ZI", "+ZY", "+IZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, i, 0, 0}, {0, 0, i, 0}, {0, 0, 0, 1}}, + .flow_data = {"+YZ", "+ZI", "+ZY", "+IZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 1 CNOT 0 1 H 1 @@ -218,13 +222,13 @@ S 1 add_gate( failed, Gate{ - "SQRT_ZZ_DAG", - GateType::SQRT_ZZ_DAG, - GateType::SQRT_ZZ, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SQRT_ZZ_DAG", + .id = GateType::SQRT_ZZ_DAG, + .best_candidate_inverse_id = GateType::SQRT_ZZ, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Phases the -1 eigenspace of the ZZ observable by -i. Parens Arguments: @@ -235,9 +239,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, -i, 0, 0}, {0, 0, -i, 0}, {0, 0, 0, 1}}, - {"-YZ", "+ZI", "-ZY", "+IZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, -i, 0, 0}, {0, 0, -i, 0}, {0, 0, 0, 1}}, + .flow_data = {"-YZ", "+ZI", "-ZY", "+IZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 1 CNOT 0 1 H 1 diff --git a/src/stim/circuit/gate_data_swaps.cc b/src/stim/circuit/gate_data_swaps.cc index f46326165..26f03fe8f 100644 --- a/src/stim/circuit/gate_data_swaps.cc +++ b/src/stim/circuit/gate_data_swaps.cc @@ -24,13 +24,13 @@ void GateDataMap::add_gate_data_swaps(bool &failed) { add_gate( failed, Gate{ - "SWAP", - GateType::SWAP, - GateType::SWAP, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SWAP", + .id = GateType::SWAP, + .best_candidate_inverse_id = GateType::SWAP, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Swaps two qubits. Parens Arguments: @@ -41,9 +41,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}, - {"+IX", "+IZ", "+XI", "+ZI"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}, + .flow_data = {"+IX", "+IZ", "+XI", "+ZI"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CNOT 0 1 CNOT 1 0 CNOT 0 1 @@ -53,13 +53,13 @@ CNOT 0 1 add_gate( failed, Gate{ - "ISWAP", - GateType::ISWAP, - GateType::ISWAP_DAG, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "ISWAP", + .id = GateType::ISWAP, + .best_candidate_inverse_id = GateType::ISWAP_DAG, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Swaps two qubits and phases the -1 eigenspace of the ZZ observable by i. Equivalent to `SWAP` then `CZ` then `S` on both targets. @@ -71,9 +71,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, i, 0}, {0, i, 0, 0}, {0, 0, 0, 1}}, - {"+ZY", "+IZ", "+YZ", "+ZI"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, i, 0}, {0, i, 0, 0}, {0, 0, 0, 1}}, + .flow_data = {"+ZY", "+IZ", "+YZ", "+ZI"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( H 0 CNOT 0 1 CNOT 1 0 @@ -86,13 +86,13 @@ S 0 add_gate( failed, Gate{ - "ISWAP_DAG", - GateType::ISWAP_DAG, - GateType::ISWAP, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "ISWAP_DAG", + .id = GateType::ISWAP_DAG, + .best_candidate_inverse_id = GateType::ISWAP, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( Swaps two qubits and phases the -1 eigenspace of the ZZ observable by -i. Equivalent to `SWAP` then `CZ` then `S_DAG` on both targets. @@ -104,9 +104,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, -i, 0}, {0, -i, 0, 0}, {0, 0, 0, 1}}, - {"-ZY", "+IZ", "-YZ", "+ZI"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, -i, 0}, {0, -i, 0, 0}, {0, 0, 0, 1}}, + .flow_data = {"-ZY", "+IZ", "-YZ", "+ZI"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( S 0 S 0 S 0 @@ -123,13 +123,13 @@ H 0 add_gate( failed, Gate{ - "CXSWAP", - GateType::CXSWAP, - GateType::SWAPCX, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "CXSWAP", + .id = GateType::CXSWAP, + .best_candidate_inverse_id = GateType::SWAPCX, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( A combination CX-then-SWAP gate. This gate is kak-equivalent to the iswap gate, but preserves X/Z noise bias. @@ -141,9 +141,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}}, - {"+XX", "+IZ", "+XI", "+ZZ"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}}, + .flow_data = {"+XX", "+IZ", "+XI", "+ZZ"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CNOT 1 0 CNOT 0 1 )CIRCUIT", @@ -152,13 +152,13 @@ CNOT 0 1 add_gate( failed, Gate{ - "SWAPCX", - GateType::SWAPCX, - GateType::CXSWAP, - 0, - (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), - "C_Two Qubit Clifford Gates", - R"MARKDOWN( + .name = "SWAPCX", + .id = GateType::SWAPCX, + .best_candidate_inverse_id = GateType::CXSWAP, + .arg_count = 0, + .flags = (GateFlags)(GATE_IS_UNITARY | GATE_TARGETS_PAIRS), + .category = "C_Two Qubit Clifford Gates", + .help = R"MARKDOWN( A combination SWAP-then-CX gate. This gate is kak-equivalent to the iswap gate, but preserves X/Z noise bias. @@ -170,9 +170,9 @@ Parens Arguments: Qubit pairs to operate on. )MARKDOWN", - {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 0}}, - {"+IX", "+ZZ", "+XX", "+ZI"}, - R"CIRCUIT( + .unitary_data = {{1, 0, 0, 0}, {0, 0, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 0}}, + .flow_data = {"+IX", "+ZZ", "+XX", "+ZI"}, + .h_s_cx_m_r_decomposition = R"CIRCUIT( CNOT 0 1 CNOT 1 0 )CIRCUIT", diff --git a/src/stim/mem/bitword_256_avx.h b/src/stim/mem/bitword_256_avx.h index b5d5591d7..027d2ede5 100644 --- a/src/stim/mem/bitword_256_avx.h +++ b/src/stim/mem/bitword_256_avx.h @@ -140,8 +140,7 @@ struct bitword<256> { } inline uint16_t popcount() const { - return std::popcount(u64[0]) + std::popcount(u64[1]) + std::popcount(u64[2]) + - (uint16_t)std::popcount(u64[3]); + return std::popcount(u64[0]) + std::popcount(u64[1]) + std::popcount(u64[2]) + (uint16_t)std::popcount(u64[3]); } inline bitword<256> shifted(int offset) const {