9#ifndef _CIRCUIT_QUANTUM_CHANNEL_OPERATION_H_
10#define _CIRCUIT_QUANTUM_CHANNEL_OPERATION_H_
13#include <unordered_set>
25 :
IOperation<Time>(delay), targets_(targets), channel_(channel)
27 if (targets_.size() != channel_.GetNumberOfQubits())
28 throw std::invalid_argument(
"The number of channel targets does not match its Kraus operators");
29 if (targets_.empty() || targets_.size() > 2)
30 throw std::invalid_argument(
"Maestro circuit channels support only one or two qubits");
32 std::unordered_set<Types::qubit_t> uniqueTargets;
34 if (!uniqueTargets.insert(target).second)
35 throw std::invalid_argument(
"Quantum-channel target qubits must be distinct");
41 simulator->ApplyQuantumChannel(targets_, channel_);
61 return targets_.size() > 1;
69 std::shared_ptr<IOperation<Time>>
Clone()
const override
74 std::shared_ptr<IOperation<Time>>
Remap(
const std::unordered_map<Types::qubit_t, Types::qubit_t> &qubitsMap,
75 const std::unordered_map<Types::qubit_t, Types::qubit_t> &bitsMap = {})
const override
81 const auto mapped = qubitsMap.find(target);
82 if (mapped != qubitsMap.end())
83 target = mapped->second;
90 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.