9#ifndef _CIRCUIT_DELAY_H_
10#define _CIRCUIT_DELAY_H_
29template <
typename Time = Types::time_type>
39 ValidateDuration(duration);
47 void Execute(
const std::shared_ptr<Simulators::ISimulator> &sim,
94 std::shared_ptr<IOperation<Time>>
Clone()
const override {
95 return std::make_shared<Delay<Time>>(qubit_,
GetDuration());
98 std::shared_ptr<IOperation<Time>>
Remap(
99 const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
100 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
104 const auto it = qubitsMap.find(qubit_);
105 if (it != qubitsMap.end()) mappedQubit = it->second;
106 return std::make_shared<Delay<Time>>(mappedQubit,
GetDuration());
110 static void ValidateDuration(Time d) {
111 if (std::isnan(
static_cast<double>(d)) ||
112 std::isinf(
static_cast<double>(d)) ||
114 throw std::invalid_argument(
"Delay duration must be finite and nonnegative");
Time GetDuration() const
Get the delay duration.
bool IsClifford() const override
Checks if the operation is a Clifford one.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
Types::qubits_vector AffectedQubits() const override
Return the affected qubits.
void SetDelay(Time d) override
Set the delay of the operation.
Delay(Types::qubit_t qubit=0, Time duration=0)
Construct a new Delay object.
void Execute(const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
Execute the delay operation on the simulator.
OperationType GetType() const override
Get the operation type.
void SetQubit(Types::qubit_t q)
Set the target qubit.
bool CanAffectQuantumState() const override
Find if the operation can affect the quantum state.
Types::qubit_t GetQubit() const
Get the target qubit.
void SetDuration(Time d)
Set the delay duration.
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.
Time GetDelay() const
Get the delay of the operation.
virtual void SetDelay(Time d)
Set the delay of the operation.
IOperation(Types::time_type delay=0)
The state class that stores the classical state of a quantum circuit execution.
OperationType
The type of operations.
@ kDelay
a delay or idle period on one or more qubits
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
uint_fast64_t qubit_t
The type of a qubit.