17#ifndef _CIRCUITCONVERTER_H_
18#define _CIRCUITCONVERTER_H_
33template <
typename Time = Types::time_type>
49 return Convert<Circuit<Time>>(operation);
65 return Convert<IQuantumGate<Time>>(operation);
79 if (!op || op->GetNumQubits() != 1)
return nullptr;
81 return Convert<SingleQubitGate<Time>>(operation);
95 if (!op || op->GetNumQubits() != 2)
return nullptr;
97 return Convert<TwoQubitsGate<Time>>(operation);
111 if (!op || op->GetNumQubits() != 3)
return nullptr;
113 return Convert<ThreeQubitsGate<Time>>(operation);
131 return Convert<Random<Time>>(operation);
147 return Convert<Reset<Time>>(operation);
163 return Convert<MeasurementOperation<Time>>(operation);
179 return Convert<ConditionalGate<Time>>(operation);
196 return Convert<ConditionalMeasurement<Time>>(operation);
213 return Convert<ConditionalRandomGen<Time>>(operation);
225 const std::shared_ptr<ICondition> &cond) {
226 if (!cond)
return nullptr;
228 return std::static_pointer_cast<EqualCondition>(cond);
232 template <
typename T>
233 static std::shared_ptr<T> Convert(
235 return std::static_pointer_cast<T>(operation);
static std::shared_ptr< ConditionalMeasurement< Time > > ToConditionalMeasurement(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Conditional...
static std::shared_ptr< Reset< Time > > ToReset(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Reset class...
static std::shared_ptr< ConditionalGate< Time > > ToConditionalGate(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Conditional...
static std::shared_ptr< IQuantumGate< Time > > ToQuantumGate(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the QuantumGate...
static std::shared_ptr< TwoQubitsGate< Time > > ToTwoQubitsGate(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the TwoQubitsGa...
static std::shared_ptr< Random< Time > > ToRandom(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Random clas...
static std::shared_ptr< ConditionalRandomGen< Time > > ToConditionalRandom(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Conditional...
static std::shared_ptr< ThreeQubitsGate< Time > > ToThreeQubitsGate(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the ThreeQubits...
static std::shared_ptr< EqualCondition > ToEqualCondition(const std::shared_ptr< ICondition > &cond)
Converts a smart pointer to the ICondition interface/base class to a smart pointer to the EqualCondit...
static std::shared_ptr< Circuit< Time > > ToCircuit(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Circuit cla...
static std::shared_ptr< MeasurementOperation< Time > > ToMeasurement(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the Measurement...
static std::shared_ptr< SingleQubitGate< Time > > ToSingleQubitGate(const std::shared_ptr< IOperation< Time > > &operation)
Converts a smart pointer to the IOperation interface/base class to a smart pointer to the SingleQubit...
@ kConditionalGate
conditional gate, similar with gate, but conditioned on something from 'OperationState'
@ kComposite
a composite operation, contains other operations - should not be used in the beginning,...
@ kRandomGen
random classical bit generator, result in 'OperationState'
@ kConditionalRandomGen
conditional random generator, similar with random gen, but conditioned on something from 'OperationSt...
@ kConditionalMeasurement
conditional measurement, similar with measurement, but conditioned on something from 'OperationState'
@ kMeasurement
measurement, result in 'OperationState'
@ kGate
the usual quantum gate, result stays in simulator's state
@ kReset
reset, no result in 'state', just apply measurement, then apply not on all qubits that were measured ...