Maestro 0.2.5
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Circuits::ConditionalGate< Time > Class Template Reference

A conditional quantum gate. More...

#include <Conditional.h>

+ Inheritance diagram for Circuits::ConditionalGate< Time >:
+ Collaboration diagram for Circuits::ConditionalGate< Time >:

Public Member Functions

 ConditionalGate (const std::shared_ptr< IGateOperation< Time > > &operation, const std::shared_ptr< ICondition > &condition, Time delay=0)
 Construct a new ConditionalGate object.
 
std::vector< size_t > AffectedBits () const override
 Get bits that are involved in the condition.
 
Types::qubits_vector AffectedQubits () const override
 Get the qubits affected by the operation.
 
virtual bool CanAffectQuantumState () const
 Find if the operation can affect the quantum state.
 
std::shared_ptr< IOperation< Time > > Clone () const override
 Get a shared pointer to a clone of this object.
 
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute the operation.
 
std::shared_ptr< IConditionGetCondition () const
 Get the condition for the conditional operation.
 
Time GetDelay () const
 Get the delay of the operation.
 
std::shared_ptr< IOperation< Time > > GetOperation () const
 Get the operation for the conditional operation.
 
std::shared_ptr< IOperation< Time > > getptr ()
 Get a shared pointer to this object.
 
OperationType GetType () const override
 Get the type of the operation.
 
bool IsClifford () const override
 Checks if the operation is a Clifford one.
 
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
 
virtual bool NeedsEntanglementForDistribution () const
 Find if the operation needs entanglement for distribution.
 
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.
 
void SetCondition (const std::shared_ptr< ICondition > &cond)
 Set the condition for the conditional operation.
 
void SetDelay (Time d)
 Set the delay of the operation.
 
void SetOperation (const std::shared_ptr< IOperation< Time > > &op)
 Set the operation for the conditional operation.
 

Detailed Description

template<typename Time = Types::time_type>
class Circuits::ConditionalGate< Time >

A conditional quantum gate.

A quantum gate that is executed only if a condition is met.

Template Parameters
TimeThe type of the time parameter that is used for operations timing.
See also
IConditionalOperation

Definition at line 387 of file Conditional.h.

Constructor & Destructor Documentation

◆ ConditionalGate()

template<typename Time = Types::time_type>
Circuits::ConditionalGate< Time >::ConditionalGate ( const std::shared_ptr< IGateOperation< Time > > &  operation,
const std::shared_ptr< ICondition > &  condition,
Time  delay = 0 
)
inline

Construct a new ConditionalGate object.

Construct a new ConditionalGate object with the given gate, condition and delay.

Parameters
operationThe gate to execute if the condition is met.
conditionThe condition to check.
delayThe delay of the gate.
See also
IConditionalOperation
IGateOperation
ICondition

Definition at line 401 of file Conditional.h.

Member Function Documentation

◆ AffectedBits()

template<typename Time = Types::time_type>
std::vector< size_t > Circuits::IConditionalOperation< Time >::AffectedBits ( ) const
inlineoverridevirtualinherited

Get bits that are involved in the condition.

Get the classical bits that are involved in the condition.

Returns
The bits involved.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 315 of file Conditional.h.

◆ AffectedQubits()

template<typename Time = Types::time_type>
Types::qubits_vector Circuits::IConditionalOperation< Time >::AffectedQubits ( ) const
inlineoverridevirtualinherited

Get the qubits affected by the operation.

Get the qubits affected by the operation.

Returns
The qubits affected by the operation.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 327 of file Conditional.h.

◆ CanAffectQuantumState()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::CanAffectQuantumState ( ) const
inlinevirtualinherited

Find if the operation can affect the quantum state.

Returns true if the operation can affect the quantum state, false otherwise.

Returns
True if the operation can affect the quantum state, false otherwise.

Reimplemented in Circuits::Circuit< Time >, and Circuits::Circuit< Types::time_type >.

Definition at line 429 of file Operations.h.

References Circuits::IOperation< Time >::GetType(), Circuits::kComposite, Circuits::kConditionalGate, Circuits::kConditionalMeasurement, Circuits::kGate, Circuits::kMeasurement, and Circuits::kReset.

◆ Clone()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::ConditionalGate< Time >::Clone ( ) const
inlineoverridevirtual

Get a shared pointer to a clone of this object.

Returns a shared pointer to a copy of this object.

Returns
A shared pointer to this object.

Implements Circuits::IOperation< Time >.

Definition at line 422 of file Conditional.h.

References Circuits::ConditionalGate< Time >::Clone(), Circuits::IOperation< Time >::GetDelay(), and Circuits::IConditionalOperation< Time >::GetOperation().

Referenced by Circuits::ConditionalGate< Time >::Clone().

◆ Execute()

template<typename Time = Types::time_type>
void Circuits::IConditionalOperation< Time >::Execute ( const std::shared_ptr< Simulators::ISimulator > &  sim,
OperationState state 
) const
inlineoverridevirtualinherited

Execute the operation.

Execute the operation if the condition is met with the specified classical state, in the specified simulator.

Parameters
simThe simulator to execute the operation on.
stateThe classical state to execute the operation on (check condition against it and if it has a classical result, put the results there).
See also
ISimulator
OperationState

Implements Circuits::IOperation< Time >.

Definition at line 248 of file Conditional.h.

◆ GetCondition()

template<typename Time = Types::time_type>
std::shared_ptr< ICondition > Circuits::IConditionalOperation< Time >::GetCondition ( ) const
inlineinherited

Get the condition for the conditional operation.

Get the condition to check.

Returns
The condition to check.
See also
ICondition

Definition at line 307 of file Conditional.h.

◆ GetDelay()

template<typename Time = Types::time_type>
Time Circuits::IOperation< Time >::GetDelay ( ) const
inlineinherited

Get the delay of the operation.

Returns the delay due of the execution time of the operation.

Returns
The delay of the operation.

Definition at line 497 of file Operations.h.

Referenced by Circuits::ConditionalGate< Time >::Clone(), Circuits::MeasurementOperation< Time >::Clone(), Circuits::NoOperation< Time >::Clone(), Circuits::PhaseGate< Time >::Clone(), Circuits::XGate< Time >::Clone(), Circuits::YGate< Time >::Clone(), Circuits::ZGate< Time >::Clone(), Circuits::HadamardGate< Time >::Clone(), Circuits::SGate< Time >::Clone(), Circuits::SdgGate< Time >::Clone(), Circuits::TGate< Time >::Clone(), Circuits::TdgGate< Time >::Clone(), Circuits::SxGate< Time >::Clone(), Circuits::SxDagGate< Time >::Clone(), Circuits::KGate< Time >::Clone(), Circuits::RxGate< Time >::Clone(), Circuits::RyGate< Time >::Clone(), Circuits::RzGate< Time >::Clone(), Circuits::UGate< Time >::Clone(), Circuits::SwapGate< Time >::Clone(), Circuits::CXGate< Time >::Clone(), Circuits::CYGate< Time >::Clone(), Circuits::CZGate< Time >::Clone(), Circuits::CPGate< Time >::Clone(), Circuits::CRxGate< Time >::Clone(), Circuits::CRyGate< Time >::Clone(), Circuits::CRzGate< Time >::Clone(), Circuits::CHGate< Time >::Clone(), Circuits::CSxGate< Time >::Clone(), Circuits::CSxDagGate< Time >::Clone(), Circuits::CUGate< Time >::Clone(), Circuits::CCXGate< Time >::Clone(), Circuits::CSwapGate< Time >::Clone(), Circuits::Random< Time >::Clone(), Circuits::Reset< Time >::Clone(), and Circuits::ComparableCircuit< Time >::operator==().

◆ GetOperation()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IConditionalOperation< Time >::GetOperation ( ) const
inlineinherited

Get the operation for the conditional operation.

Get the operation to execute if the condition is met.

Returns
The operation to execute if the condition is met.
See also
IOperation

Definition at line 287 of file Conditional.h.

Referenced by Circuits::ConditionalGate< Time >::Clone(), Circuits::ConditionalMeasurement< Time >::Clone(), and Circuits::ConditionalRandomGen< Time >::Clone().

◆ getptr()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IOperation< Time >::getptr ( )
inlineinherited

Get a shared pointer to this object.

Returns a shared pointer to this object. The object needs to be already wrapped in a shared pointer.

Returns
A shared pointer to this object.

Definition at line 487 of file Operations.h.

◆ GetType()

template<typename Time = Types::time_type>
OperationType Circuits::ConditionalGate< Time >::GetType ( ) const
inlineoverridevirtual

Get the type of the operation.

Returns the type of the operation.

Returns
The type of the operation.
See also
OperationType

Reimplemented from Circuits::IOperation< Time >.

Definition at line 412 of file Conditional.h.

References Circuits::kConditionalGate.

◆ IsClifford()

template<typename Time = Types::time_type>
bool Circuits::IConditionalOperation< Time >::IsClifford ( ) const
inlineoverridevirtualinherited

Checks if the operation is a Clifford one.

Checks if the operation is a Clifford one, allowing to be simulated in a stabilizers simulator.

Returns
True if it can be applied in a stabilizers simulator, false otherwise.

Reimplemented from Circuits::IOperation< Time >.

Definition at line 365 of file Conditional.h.

◆ IsConditional()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::IsConditional ( ) const
inlinevirtualinherited

Find if the operation is a conditional operation.

Returns true if the operation is conditional, false otherwise.

Returns
True if the operation is conditional, false otherwise.

Definition at line 458 of file Operations.h.

References Circuits::IOperation< Time >::GetType(), Circuits::kConditionalGate, Circuits::kConditionalMeasurement, and Circuits::kConditionalRandomGen.

◆ NeedsEntanglementForDistribution()

template<typename Time = Types::time_type>
virtual bool Circuits::IOperation< Time >::NeedsEntanglementForDistribution ( ) const
inlinevirtualinherited

Find if the operation needs entanglement for distribution.

Returns true if the operation needs entanglement for distribution, false otherwise.

Returns
True if the operation needs entanglement for distribution, false otherwise.

Reimplemented in Circuits::Circuit< Time >, and Circuits::Circuit< Types::time_type >.

Definition at line 446 of file Operations.h.

References Circuits::IOperation< Time >::AffectedQubits(), Circuits::IOperation< Time >::GetType(), Circuits::kConditionalGate, and Circuits::kGate.

◆ Remap()

template<typename Time = Types::time_type>
std::shared_ptr< IOperation< Time > > Circuits::IConditionalOperation< 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
inlineoverridevirtualinherited

Get a shared pointer to a remapped operation.

Returns a shared pointer to a copy of the operation with qubits and classical bits changed according to the provided maps.

Parameters
qubitsMapThe map of qubits to remap.
bitsMapThe map of classical bits to remap.
Returns
A shared pointer to the remapped object.

Implements Circuits::IOperation< Time >.

Definition at line 343 of file Conditional.h.

◆ SetCondition()

template<typename Time = Types::time_type>
void Circuits::IConditionalOperation< Time >::SetCondition ( const std::shared_ptr< ICondition > &  cond)
inlineinherited

Set the condition for the conditional operation.

Assigns the condition to check.

Parameters
condThe assigned condition.
See also
ICondition

Definition at line 296 of file Conditional.h.

◆ SetDelay()

template<typename Time = Types::time_type>
void Circuits::IOperation< Time >::SetDelay ( Time  d)
inlineinherited

Set the delay of the operation.

Sets the delay due of the execution time of the operation.

Parameters
dThe delay of the operation.

Definition at line 505 of file Operations.h.

◆ SetOperation()

template<typename Time = Types::time_type>
void Circuits::IConditionalOperation< Time >::SetOperation ( const std::shared_ptr< IOperation< Time > > &  op)
inlineinherited

Set the operation for the conditional operation.

Assigns the operation to execute if the condition is met.

Parameters
opThe assigned operation.

Definition at line 264 of file Conditional.h.

References Circuits::kConditionalGate, Circuits::kConditionalMeasurement, Circuits::kConditionalRandomGen, Circuits::kGate, Circuits::kMeasurement, and Circuits::kRandomGen.


The documentation for this class was generated from the following file: