You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A QuantumState holds a quantum state (SparseArray data) and a measurement register (BasisVector measurementRegister).
I think this is wrong because a quantum state and a measurement register are different things. A quantum state should just contain a representation of the state, for example, as it does at the moment, via a data member of type SparseArray.
When we call Circuit::execute, we pass a QuantumState. But we already have a SimulationResultAccumulator around. And a SimulationResultAccumulator also holds a quantum state (QuantumState state) and a measurement register (absl::btree_map<state_string_t, count_t> measurements plus std::uint64_t measurementsCount.
Notice that the quantum state is reset for every simulation run. The SimulationResultAccumulator just uses the quantum state from the last execution.
We could probably go further and group a quantum state and a measurement register into a SimulationIterationResult. Then we would write the code above as:
std::variant<std::monostate, SimulationResult, SimulationError> execute
auto simulationResultAccumulator = SimulationResultAccumulator{};
while (iterations--) {
simulationIterationResult = circuit.execute(std::monostate{});
simulationResultAccumulator.appendMeasurement(simulationIterationResult.getMeasurementRegister());
}
core::SimulationResult &Circuit::execute(error_models::ErrorModel const &errorModel) const {
InstructionExecutor instruction_executor{};
if (auto *measure = std::get_if<Measure>(&instruction)) {
return instruction_executor(*measure); // every instruction returns a SimulationIterationResult
Even rewrite the accumulation as:
auto simulationResultAccumulator = ranges::accumulate(
ranges::iota(0, iterations-1),
SimulationResultAccumulator{}, [&circuit](auto &acc, auto _) {
simulationIterationResult = circuit.execute(std::monostate{});
acc.appendMeasurement(simulationIterationResult);
return acc;
});
The text was updated successfully, but these errors were encountered:
A QuantumState holds a quantum state (
SparseArray data
) and a measurement register (BasisVector measurementRegister
).I think this is wrong because a quantum state and a measurement register are different things. A quantum state should just contain a representation of the state, for example, as it does at the moment, via a
data
member of typeSparseArray
.When we call Circuit::execute, we pass a QuantumState. But we already have a SimulationResultAccumulator around. And a SimulationResultAccumulator also holds a quantum state (
QuantumState state
) and a measurement register (absl::btree_map<state_string_t, count_t> measurements
plusstd::uint64_t measurementsCount
.These lines:
could be turned into:
Notice that the quantum state is reset for every simulation run. The SimulationResultAccumulator just uses the quantum state from the last execution.
We could probably go further and group a quantum state and a measurement register into a SimulationIterationResult. Then we would write the code above as:
Even rewrite the accumulation as:
The text was updated successfully, but these errors were encountered: