9#ifndef _CIRCUIT_QUANTUM_CHANNEL_OPERATION_H_
10#define _CIRCUIT_QUANTUM_CHANNEL_OPERATION_H_
13#include <unordered_set>
20template <
typename Time = Types::time_type>
26 :
IOperation<Time>(delay), targets_(targets), channel_(channel) {
27 if (targets_.size() != channel_.GetNumberOfQubits())
28 throw std::invalid_argument(
29 "The number of channel targets does not match its Kraus operators");
30 if (targets_.empty() || targets_.size() > 2)
31 throw std::invalid_argument(
32 "Maestro circuit channels support only one or two qubits");
34 std::unordered_set<Types::qubit_t> uniqueTargets;
36 if (!uniqueTargets.insert(target).second)
37 throw std::invalid_argument(
38 "Quantum-channel target qubits must be distinct");
41 void Execute(
const std::shared_ptr<Simulators::ISimulator>& simulator,
44 simulator->ApplyQuantumChannel(targets_, channel_);
56 return targets_.size() > 1;
61 std::shared_ptr<IOperation<Time>>
Clone()
const override {
62 return std::make_shared<QuantumChannelOperation<Time>>(
66 std::shared_ptr<IOperation<Time>>
Remap(
67 const std::unordered_map<Types::qubit_t, Types::qubit_t>& qubitsMap,
68 const std::unordered_map<Types::qubit_t, Types::qubit_t>& bitsMap = {})
73 const auto mapped = qubitsMap.find(target);
74 if (mapped != qubitsMap.end()) target = mapped->second;
76 return std::make_shared<QuantumChannelOperation<Time>>(
82 Simulators::QuantumChannel channel_;
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 Execute(const std::shared_ptr< Simulators::ISimulator > &simulator, OperationState &state) const override
Execute the operation.
bool CanAffectQuantumState() const override
Find if the operation can affect the quantum state.
OperationType GetType() const override
Get the type of the operation.
QuantumChannelOperation(const Types::qubits_vector &targets, const Simulators::QuantumChannel &channel, Time delay=0)
Types::qubits_vector AffectedQubits() const override
Returns the affected qubits.
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.
std::shared_ptr< IOperation< Time > > Clone() const override
Get a shared pointer to a clone of this object.
bool NeedsEntanglementForDistribution() const override
Find if the operation needs entanglement for distribution.
const Simulators::QuantumChannel & GetChannel() const
A local completely-positive, trace-preserving map in Kraus form.
OperationType
The type of operations.
@ kQuantumChannel
a non-unitary CPTP operation on the simulator state
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
uint_fast64_t qubit_t
The type of a qubit.