17#ifndef _RESET_STATE_H_
18#define _RESET_STATE_H_
32template <
typename Time = Types::time_type>
45 const std::vector<bool> &resetTargets = {})
46 :
IOperation<Time>(delay), qubits(qubits), resetTargets(resetTargets) {}
58 void Execute(
const std::shared_ptr<Simulators::ISimulator> &sim,
62 sim->ApplyReset(qubits);
66 for (
size_t qi = 0; qi < resetTargets.size() && qi < qubits.size(); ++qi) {
67 if (resetTargets[qi]) {
68 xgate.SetQubit(qubits[qi]);
69 xgate.Execute(sim, state);
71 if (sim->SupportsMPSSwapOptimization()) {
72 const auto counter = sim->GetGatesCounter();
74 sim->SetGatesCounter(counter - 1);
98 const std::vector<bool> &resetTgts = {}) {
100 resetTargets = resetTgts;
126 std::shared_ptr<IOperation<Time>>
Clone()
const override {
127 return std::make_shared<Reset<Time>>(
150 std::shared_ptr<IOperation<Time>>
Remap(
151 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
152 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
154 auto newOp = this->
Clone();
156 for (
size_t i = 0; i < qubits.size(); ++i) {
157 const auto qubitit = qubitsMap.find(qubits[i]);
158 if (qubitit != qubitsMap.end())
159 std::static_pointer_cast<Reset<Time>>(newOp)->
SetQubit(i,
186 if (index < qubits.size()) qubits[index] = qubit;
191 std::vector<bool> resetTargets;
Time GetDelay() const
Get the delay of the operation.
IOperation(Types::time_type delay=0)
The state class that stores the classical state of a quantum circuit execution.
void SetQubits(const Types::qubits_vector &qs, const std::vector< bool > &resetTgts={})
Set the qubits to reset and the values to reset them to.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
Reset(const Types::qubits_vector &qubits={}, Time delay=0, const std::vector< bool > &resetTargets={})
Construct a new Reset object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the operation.
void SetQubit(size_t index, Types::qubit_t qubit)
Set the qubit to reset.
OperationType GetType() const override
Get the type of operation.
const Types::qubits_vector & GetQubits() const
Get the qubits to reset.
bool IsClifford() const override
Checks if the operation is a Clifford one.
std::shared_ptr< IOperation< Time > > Remap(const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
Get a shared pointer to a remapped operation.
const std::vector< bool > & GetResetTargets() const
Get the values to reset the qubits to.
Types::qubits_vector AffectedQubits() const override
Get the qubits affected by this operation.
OperationType
The type of operations.
@ kReset
reset, no result in 'state', just apply measurement, then apply not on all qubits that were measured ...
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
uint_fast64_t qubit_t
The type of a qubit.